@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.
Files changed (58) hide show
  1. package/README.md +125 -57
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +3 -1
  4. package/dist/crowdy-client.d.ts +49 -13
  5. package/dist/crowdy-client.d.ts.map +1 -1
  6. package/dist/crowdy-client.js +47 -16
  7. package/dist/domains/apps.d.ts +59 -20
  8. package/dist/domains/apps.d.ts.map +1 -1
  9. package/dist/domains/apps.js +61 -35
  10. package/dist/domains/auth.d.ts +33 -22
  11. package/dist/domains/auth.d.ts.map +1 -1
  12. package/dist/domains/auth.js +51 -33
  13. package/dist/domains/channels.d.ts +34 -0
  14. package/dist/domains/channels.d.ts.map +1 -0
  15. package/dist/domains/channels.js +94 -0
  16. package/dist/domains/gameModel.d.ts +40 -0
  17. package/dist/domains/gameModel.d.ts.map +1 -0
  18. package/dist/domains/gameModel.js +114 -0
  19. package/dist/domains/platform.d.ts +33 -0
  20. package/dist/domains/platform.d.ts.map +1 -0
  21. package/dist/domains/platform.js +39 -0
  22. package/dist/domains/udp.d.ts +17 -1
  23. package/dist/domains/udp.d.ts.map +1 -1
  24. package/dist/domains/udp.js +25 -1
  25. package/dist/domains/users.d.ts +19 -16
  26. package/dist/domains/users.d.ts.map +1 -1
  27. package/dist/domains/users.js +21 -39
  28. package/dist/generated/graphql.d.ts +2912 -63
  29. package/dist/generated/graphql.d.ts.map +1 -1
  30. package/dist/generated/graphql.js +82 -10
  31. package/dist/index.d.ts +32 -14
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +33 -15
  34. package/dist/realtime.d.ts +6 -0
  35. package/dist/realtime.d.ts.map +1 -1
  36. package/dist/realtime.js +6 -0
  37. package/dist/types.d.ts +2 -31
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js +5 -33
  40. package/dist/world.d.ts +9 -0
  41. package/dist/world.d.ts.map +1 -1
  42. package/dist/world.js +17 -0
  43. package/package.json +2 -2
  44. package/dist/domains/appAccess.d.ts +0 -23
  45. package/dist/domains/appAccess.d.ts.map +0 -1
  46. package/dist/domains/appAccess.js +0 -42
  47. package/dist/domains/billing.d.ts +0 -17
  48. package/dist/domains/billing.d.ts.map +0 -1
  49. package/dist/domains/billing.js +0 -31
  50. package/dist/domains/organizations.d.ts +0 -33
  51. package/dist/domains/organizations.d.ts.map +0 -1
  52. package/dist/domains/organizations.js +0 -90
  53. package/dist/domains/payments.d.ts +0 -20
  54. package/dist/domains/payments.d.ts.map +0 -1
  55. package/dist/domains/payments.js +0 -28
  56. package/dist/domains/quotas.d.ts +0 -20
  57. package/dist/domains/quotas.d.ts.map +0 -1
  58. package/dist/domains/quotas.js +0 -34
@@ -1,49 +1,75 @@
1
- import { AppDocument, AppBySlugDocument, MyAppsDocument, AppsForOrgDocument, MarketplaceAppsDocument, CreateAppDocument, UpdateAppDocument, ArchiveAppDocument, SetAppVisibilityDocument, } from '../generated/graphql.js';
2
1
  /**
3
- * App (game / world) lifecycle and discovery. Exposed as `client.apps`.
2
+ * Apps sub-client. Targets `cks-management-api` (where the apps catalog
3
+ * lives). After the DB split each app may be served by its own per-tenant
4
+ * cks-game-api; the marketplace returns `gameApiUrl` for those rows so the
5
+ * caller can build a per-app `CrowdyClient` against the correct endpoint.
4
6
  *
5
- * `marketplace()` is a public listing (no auth) of every app where
6
- * visibility = PUBLIC and status = LIVE; the rest of the methods require
7
- * either org-membership permissions or super admin.
7
+ * Typical pattern:
8
+ *
9
+ * const baseClient = createCrowdyClient({
10
+ * managementUrl: 'https://api.example.com',
11
+ * httpUrl: 'https://legacy-game-api.example.com', // pre-split fallback
12
+ * });
13
+ * await baseClient.auth.login({ email, password });
14
+ *
15
+ * const route = await baseClient.apps.routeFor(appId);
16
+ * if (route.gameApiUrl) {
17
+ * // Set for both dedicated (split-mode) AND shared-environment apps.
18
+ * const perAppClient = createCrowdyClient({
19
+ * managementUrl: 'https://api.example.com',
20
+ * httpUrl: route.gameApiUrl,
21
+ * wsUrl: route.gameApiUrl.replace(/^http/, 'ws'),
22
+ * tokenStore: baseClient.session.tokenStore,
23
+ * });
24
+ * // drive gameplay through perAppClient
25
+ * }
8
26
  */
27
+ import { AppDocument, AppBySlugDocument, MyAppsDocument, } from '../generated/graphql.js';
28
+ function appRouteFromAppRow(row) {
29
+ if (!row || typeof row !== 'object')
30
+ return null;
31
+ const r = row;
32
+ if (typeof r.appId !== 'string')
33
+ return null;
34
+ return {
35
+ appId: r.appId,
36
+ splitMode: typeof r.splitMode === 'boolean' ? r.splitMode : false,
37
+ deploymentTarget: typeof r.deploymentTarget === 'string' ? r.deploymentTarget : null,
38
+ gameApiUrl: typeof r.gameApiUrl === 'string' && r.gameApiUrl ? r.gameApiUrl : null,
39
+ };
40
+ }
9
41
  export class AppsAPI {
10
- constructor(gql) {
11
- this.gql = gql;
12
- }
13
- async marketplace(args = {}) {
14
- const data = await this.gql.request(MarketplaceAppsDocument, args);
15
- return data.apps;
42
+ constructor(management) {
43
+ this.management = management;
16
44
  }
17
- async byId(appId) {
18
- const data = await this.gql.request(AppDocument, { appId });
45
+ /** Fetch a single app by id. */
46
+ async app(appId) {
47
+ const data = await this.management.request(AppDocument, { appId });
19
48
  return data.app;
20
49
  }
21
- async bySlug(args) {
22
- const data = await this.gql.request(AppBySlugDocument, args);
50
+ /** Fetch by org slug + app slug (marketplace links). */
51
+ async appBySlug(orgSlug, appSlug) {
52
+ const data = await this.management.request(AppBySlugDocument, { orgSlug, appSlug });
23
53
  return data.appBySlug;
24
54
  }
55
+ /** Apps the caller can play (org membership OR active access). */
25
56
  async myApps() {
26
- const data = await this.gql.request(MyAppsDocument, undefined);
57
+ const data = await this.management.request(MyAppsDocument, {});
27
58
  return data.myApps;
28
59
  }
29
- async forOrg(orgSlug) {
30
- const data = await this.gql.request(AppsForOrgDocument, { orgSlug });
31
- return data.appsForOrg;
32
- }
33
- async create(input) {
34
- const data = await this.gql.request(CreateAppDocument, { input });
35
- return data.createApp;
36
- }
37
- async update(args) {
38
- const data = await this.gql.request(UpdateAppDocument, args);
39
- return data.updateApp;
40
- }
41
- async archive(appId) {
42
- const data = await this.gql.request(ArchiveAppDocument, { appId });
43
- return data.archiveApp;
44
- }
45
- async setVisibility(args) {
46
- const data = await this.gql.request(SetAppVisibilityDocument, args);
47
- return data.setAppVisibility;
60
+ /**
61
+ * Convenience: returns just the routing tuple for a given app. If the
62
+ * app row is missing or the API does not expose split-mode fields yet,
63
+ * returns `{ appId, splitMode: false, gameApiUrl: null }` so the caller
64
+ * keeps using the legacy single-endpoint deployment.
65
+ */
66
+ async routeFor(appId) {
67
+ const row = await this.app(appId);
68
+ return (appRouteFromAppRow(row) ?? {
69
+ appId,
70
+ splitMode: false,
71
+ deploymentTarget: null,
72
+ gameApiUrl: null,
73
+ });
48
74
  }
49
75
  }
@@ -1,32 +1,43 @@
1
- import type { GraphQLClient } from '../client.js';
2
- import type { AuthState } from '../auth-state.js';
3
- import { type LoginMutation, type LoginMutationVariables, type RegisterMutation, type RegisterMutationVariables, type LogoutMutation, type LogoutAllDevicesMutation, type ConfirmEmailMutationVariables, type RequestPasswordResetMutationVariables, type ResetPasswordMutationVariables, type ResendConfirmationEmailMutationVariables } from '../generated/graphql.js';
4
1
  /**
5
- * Authentication operations. Exposed as `client.auth.<method>`.
2
+ * Auth sub-client. Talks to `cks-management-api` (NOT the game API) because
3
+ * the management API owns the `game_tokens` table that backs every login /
4
+ * register / password / email-confirm flow.
6
5
  *
7
- * `login` / `register` write the returned token into the shared `AuthState`
8
- * so the WebSocket subscription manager picks it up automatically. `logout`
9
- * / `logoutAllDevices` clear it.
6
+ * The returned `token` is a `game_tokens` row that game-api will validate
7
+ * against the same shared Postgres. Once the SDK has a token, the rest of
8
+ * the sub-clients (chunks, voxels, actors, udp, ...) use it transparently
9
+ * via the shared `AuthState`.
10
10
  */
11
+ import type { GraphQLClient } from '../client.js';
12
+ import type { AuthState } from '../auth-state.js';
13
+ import { type LoginMutation, type LoginUserInput, type RegisterMutation, type RegisterUserInput, type ResetPasswordInput } from '../generated/graphql.js';
11
14
  export declare class AuthAPI {
12
- private gql;
13
- private authState;
14
- constructor(gql: GraphQLClient, authState: AuthState);
15
- login(input: LoginMutationVariables['input']): Promise<LoginMutation['login']>;
16
- register(input: RegisterMutationVariables['input']): Promise<RegisterMutation['register']>;
17
- logout(): Promise<LogoutMutation['logout']>;
18
- logoutAllDevices(): Promise<LogoutAllDevicesMutation['logoutAllDevices']>;
15
+ private readonly graphql;
16
+ private readonly session;
17
+ constructor(graphql: GraphQLClient, session: AuthState);
19
18
  /**
20
- * Manual token override - lets callers seed an existing session token
21
- * (e.g. on app reload) or stamp out the in-memory token without firing
22
- * a logout mutation. Pass `null` to clear.
19
+ * Log in and persist the resulting `game_tokens` bearer token via the
20
+ * shared `AuthState`. All subsequent SDK calls (game-api or
21
+ * management-api) include it automatically.
23
22
  */
23
+ login(input: LoginUserInput): Promise<LoginMutation['login']>;
24
+ /** Register a new user. Same token-persistence behaviour as `login`. */
25
+ register(input: RegisterUserInput): Promise<RegisterMutation['register']>;
26
+ /**
27
+ * Single-device logout. Clears the in-memory token after a successful
28
+ * server-side revoke so other sub-clients don't keep using it.
29
+ */
30
+ logout(): Promise<boolean>;
31
+ /** Revoke every `game_tokens` row for the current user. */
32
+ logoutAllDevices(): Promise<boolean>;
33
+ confirmEmail(token: string): Promise<boolean>;
34
+ requestPasswordReset(email: string): Promise<boolean>;
35
+ resetPassword(input: ResetPasswordInput): Promise<boolean>;
36
+ resendConfirmationEmail(email: string): Promise<boolean>;
37
+ changePassword(currentPassword: string, newPassword: string): Promise<boolean>;
38
+ /** Imperatively replace the in-memory bearer token (e.g. on rehydrate). */
24
39
  setToken(token: string | null): void;
40
+ /** Read the current bearer token. */
25
41
  getToken(): string | null;
26
- confirmEmail(token: ConfirmEmailMutationVariables['token']): Promise<boolean>;
27
- requestPasswordReset(email: RequestPasswordResetMutationVariables['email']): Promise<boolean>;
28
- resetPassword(input: ResetPasswordMutationVariables['input']): Promise<boolean>;
29
- resendConfirmationEmail(email: ResendConfirmationEmailMutationVariables['email']): Promise<boolean>;
30
- changePassword(currentPassword: string, newPassword: string): Promise<boolean>;
31
42
  }
32
43
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/domains/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAE9B,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAE7B,KAAK,6BAA6B,EAElC,KAAK,qCAAqC,EAE1C,KAAK,8BAA8B,EAEnC,KAAK,wCAAwC,EAG9C,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,qBAAa,OAAO;IAEhB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,SAAS;gBADT,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,SAAS;IAGxB,KAAK,CAAC,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAQ9E,QAAQ,CACZ,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACxC,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAQlC,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAM3C,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAM/E;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIpC,QAAQ,IAAI,MAAM,GA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gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAKpC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK7C,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOrD,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAO1D,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOxD,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;IAQnB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIpC,qCAAqC;IACrC,QAAQ,IAAI,MAAM,GAAG,IAAI;CAG1B"}
@@ -1,70 +1,88 @@
1
- import { LoginDocument, RegisterDocument, LogoutDocument, LogoutAllDevicesDocument, ConfirmEmailDocument, RequestPasswordResetDocument, ResetPasswordDocument, ResendConfirmationEmailDocument, ChangePasswordDocument, } from '../generated/graphql.js';
2
1
  /**
3
- * Authentication operations. Exposed as `client.auth.<method>`.
2
+ * Auth sub-client. Talks to `cks-management-api` (NOT the game API) because
3
+ * the management API owns the `game_tokens` table that backs every login /
4
+ * register / password / email-confirm flow.
4
5
  *
5
- * `login` / `register` write the returned token into the shared `AuthState`
6
- * so the WebSocket subscription manager picks it up automatically. `logout`
7
- * / `logoutAllDevices` clear it.
6
+ * The returned `token` is a `game_tokens` row that game-api will validate
7
+ * against the same shared Postgres. Once the SDK has a token, the rest of
8
+ * the sub-clients (chunks, voxels, actors, udp, ...) use it transparently
9
+ * via the shared `AuthState`.
8
10
  */
11
+ import { ChangePasswordDocument, ConfirmEmailDocument, LoginDocument, LogoutAllDevicesDocument, LogoutDocument, RegisterDocument, RequestPasswordResetDocument, ResendConfirmationEmailDocument, ResetPasswordDocument, } from '../generated/graphql.js';
9
12
  export class AuthAPI {
10
- constructor(gql, authState) {
11
- this.gql = gql;
12
- this.authState = authState;
13
+ constructor(graphql, session) {
14
+ this.graphql = graphql;
15
+ this.session = session;
13
16
  }
17
+ /**
18
+ * Log in and persist the resulting `game_tokens` bearer token via the
19
+ * shared `AuthState`. All subsequent SDK calls (game-api or
20
+ * management-api) include it automatically.
21
+ */
14
22
  async login(input) {
15
- const data = await this.gql.request(LoginDocument, { input });
23
+ const data = await this.graphql.request(LoginDocument, { input });
16
24
  if (data.login?.token) {
17
- this.authState.setToken(data.login.token);
25
+ this.session.setToken(data.login.token);
18
26
  }
19
27
  return data.login;
20
28
  }
29
+ /** Register a new user. Same token-persistence behaviour as `login`. */
21
30
  async register(input) {
22
- const data = await this.gql.request(RegisterDocument, { input });
31
+ const data = await this.graphql.request(RegisterDocument, { input });
23
32
  if (data.register?.token) {
24
- this.authState.setToken(data.register.token);
33
+ this.session.setToken(data.register.token);
25
34
  }
26
35
  return data.register;
27
36
  }
37
+ /**
38
+ * Single-device logout. Clears the in-memory token after a successful
39
+ * server-side revoke so other sub-clients don't keep using it.
40
+ */
28
41
  async logout() {
29
- const data = await this.gql.request(LogoutDocument, undefined);
30
- this.authState.setToken(null);
42
+ const data = await this.graphql.request(LogoutDocument);
43
+ this.session.setToken(null);
31
44
  return data.logout;
32
45
  }
46
+ /** Revoke every `game_tokens` row for the current user. */
33
47
  async logoutAllDevices() {
34
- const data = await this.gql.request(LogoutAllDevicesDocument, undefined);
35
- this.authState.setToken(null);
48
+ const data = await this.graphql.request(LogoutAllDevicesDocument);
36
49
  return data.logoutAllDevices;
37
50
  }
38
- /**
39
- * Manual token override - lets callers seed an existing session token
40
- * (e.g. on app reload) or stamp out the in-memory token without firing
41
- * a logout mutation. Pass `null` to clear.
42
- */
43
- setToken(token) {
44
- this.authState.setToken(token);
45
- }
46
- getToken() {
47
- return this.authState.getToken();
48
- }
49
51
  async confirmEmail(token) {
50
- const data = await this.gql.request(ConfirmEmailDocument, { token });
52
+ const data = await this.graphql.request(ConfirmEmailDocument, { token });
51
53
  return data.confirmEmail;
52
54
  }
53
55
  async requestPasswordReset(email) {
54
- const data = await this.gql.request(RequestPasswordResetDocument, { email });
56
+ const data = await this.graphql.request(RequestPasswordResetDocument, {
57
+ email,
58
+ });
55
59
  return data.requestPasswordReset;
56
60
  }
57
61
  async resetPassword(input) {
58
- const data = await this.gql.request(ResetPasswordDocument, { input });
62
+ const data = await this.graphql.request(ResetPasswordDocument, {
63
+ input,
64
+ });
59
65
  return data.resetPassword;
60
66
  }
61
67
  async resendConfirmationEmail(email) {
62
- const data = await this.gql.request(ResendConfirmationEmailDocument, { email });
68
+ const data = await this.graphql.request(ResendConfirmationEmailDocument, {
69
+ email,
70
+ });
63
71
  return data.resendConfirmationEmail;
64
72
  }
65
73
  async changePassword(currentPassword, newPassword) {
66
- const vars = { currentPassword, newPassword };
67
- const data = await this.gql.request(ChangePasswordDocument, vars);
74
+ const data = await this.graphql.request(ChangePasswordDocument, {
75
+ currentPassword,
76
+ newPassword,
77
+ });
68
78
  return data.changePassword;
69
79
  }
80
+ /** Imperatively replace the in-memory bearer token (e.g. on rehydrate). */
81
+ setToken(token) {
82
+ this.session.setToken(token);
83
+ }
84
+ /** Read the current bearer token. */
85
+ getToken() {
86
+ return this.session.getToken();
87
+ }
70
88
  }
@@ -0,0 +1,34 @@
1
+ import type { GraphQLClient } from '../client.js';
2
+ import { type MyChannelsQuery, type MyChannelsQueryVariables, type ChannelsQuery, type ChannelsQueryVariables, type ChannelQuery, type ChannelQueryVariables, type ChannelMembersQuery, type ChannelMembersQueryVariables, type ChannelRolesQuery, type ChannelRolesQueryVariables, type ChannelPolicyQuery, type ChannelPolicyQueryVariables, type SetChannelPolicyMutation, type SetChannelPolicyMutationVariables, type CreateChannelMutation, type CreateChannelMutationVariables, type UpdateChannelMutation, type UpdateChannelMutationVariables, type DeleteChannelMutationVariables, type JoinChannelMutation, type JoinChannelMutationVariables, type RequestToJoinChannelMutation, type RequestToJoinChannelMutationVariables, type LeaveChannelMutationVariables, type AddChannelMemberMutation, type AddChannelMemberMutationVariables, type RemoveChannelMemberMutationVariables, type SetChannelMemberRolesMutation, type SetChannelMemberRolesMutationVariables, type CreateChannelRoleMutation, type CreateChannelRoleMutationVariables, type UpdateChannelRoleMutation, type UpdateChannelRoleMutationVariables, type DeleteChannelRoleMutationVariables } from '../generated/graphql.js';
3
+ /**
4
+ * Channels: app-scoped player groups with role-gated messaging, built on the
5
+ * same generic groups subsystem as Teams (group_type='channel'). Channel
6
+ * CRUD/membership runs over the game-api GraphQL endpoint; publishing and
7
+ * receiving channel messages happens over the realtime UDP path (`client.udp`).
8
+ *
9
+ * Exposed as `client.channels`.
10
+ */
11
+ export declare class ChannelsAPI {
12
+ private gql;
13
+ constructor(gql: GraphQLClient);
14
+ mine(appId: MyChannelsQueryVariables['appId']): Promise<MyChannelsQuery['myChannels']>;
15
+ list(appId: ChannelsQueryVariables['appId']): Promise<ChannelsQuery['channels']>;
16
+ get(groupId: ChannelQueryVariables['groupId']): Promise<ChannelQuery['channel']>;
17
+ members(groupId: ChannelMembersQueryVariables['groupId']): Promise<ChannelMembersQuery['channelMembers']>;
18
+ roles(groupId: ChannelRolesQueryVariables['groupId']): Promise<ChannelRolesQuery['channelRoles']>;
19
+ policy(appId: ChannelPolicyQueryVariables['appId']): Promise<ChannelPolicyQuery['channelPolicy']>;
20
+ create(input: CreateChannelMutationVariables['input']): Promise<CreateChannelMutation['createChannel']>;
21
+ update(input: UpdateChannelMutationVariables['input']): Promise<UpdateChannelMutation['updateChannel']>;
22
+ remove(groupId: DeleteChannelMutationVariables['groupId']): Promise<boolean>;
23
+ setPolicy(input: SetChannelPolicyMutationVariables['input']): Promise<SetChannelPolicyMutation['setChannelPolicy']>;
24
+ join(groupId: JoinChannelMutationVariables['groupId']): Promise<JoinChannelMutation['joinChannel']>;
25
+ requestToJoin(groupId: RequestToJoinChannelMutationVariables['groupId']): Promise<RequestToJoinChannelMutation['requestToJoinChannel']>;
26
+ leave(groupId: LeaveChannelMutationVariables['groupId']): Promise<boolean>;
27
+ addMember(groupId: AddChannelMemberMutationVariables['groupId'], userId: AddChannelMemberMutationVariables['userId']): Promise<AddChannelMemberMutation['addChannelMember']>;
28
+ removeMember(groupId: RemoveChannelMemberMutationVariables['groupId'], userId: RemoveChannelMemberMutationVariables['userId']): Promise<boolean>;
29
+ setMemberRoles(input: SetChannelMemberRolesMutationVariables['input']): Promise<SetChannelMemberRolesMutation['setChannelMemberRoles']>;
30
+ createRole(input: CreateChannelRoleMutationVariables['input']): Promise<CreateChannelRoleMutation['createChannelRole']>;
31
+ updateRole(input: UpdateChannelRoleMutationVariables['input']): Promise<UpdateChannelRoleMutation['updateChannelRole']>;
32
+ deleteRole(groupRoleId: DeleteChannelRoleMutationVariables['groupRoleId']): Promise<boolean>;
33
+ }
34
+ //# sourceMappingURL=channels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/domains/channels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAE7B,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAE1B,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAE/B,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAEhC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EAEtC,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,8BAA8B,EAEnC,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAEjC,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAE1C,KAAK,6BAA6B,EAElC,KAAK,wBAAwB,EA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annelPolicyDocument, SetChannelPolicyDocument, CreateChannelDocument, UpdateChannelDocument, DeleteChannelDocument, JoinChannelDocument, RequestToJoinChannelDocument, LeaveChannelDocument, AddChannelMemberDocument, RemoveChannelMemberDocument, SetChannelMemberRolesDocument, CreateChannelRoleDocument, UpdateChannelRoleDocument, DeleteChannelRoleDocument, } from '../generated/graphql.js';
2
+ /**
3
+ * Channels: app-scoped player groups with role-gated messaging, built on the
4
+ * same generic groups subsystem as Teams (group_type='channel'). Channel
5
+ * CRUD/membership runs over the game-api GraphQL endpoint; publishing and
6
+ * receiving channel messages happens over the realtime UDP path (`client.udp`).
7
+ *
8
+ * Exposed as `client.channels`.
9
+ */
10
+ export class ChannelsAPI {
11
+ constructor(gql) {
12
+ this.gql = gql;
13
+ }
14
+ // -- Queries --------------------------------------------------------------
15
+ async mine(appId) {
16
+ const data = await this.gql.request(MyChannelsDocument, { appId });
17
+ return data.myChannels;
18
+ }
19
+ async list(appId) {
20
+ const data = await this.gql.request(ChannelsDocument, { appId });
21
+ return data.channels;
22
+ }
23
+ async get(groupId) {
24
+ const data = await this.gql.request(ChannelDocument, { groupId });
25
+ return data.channel;
26
+ }
27
+ async members(groupId) {
28
+ const data = await this.gql.request(ChannelMembersDocument, { groupId });
29
+ return data.channelMembers;
30
+ }
31
+ async roles(groupId) {
32
+ const data = await this.gql.request(ChannelRolesDocument, { groupId });
33
+ return data.channelRoles;
34
+ }
35
+ async policy(appId) {
36
+ const data = await this.gql.request(ChannelPolicyDocument, { appId });
37
+ return data.channelPolicy;
38
+ }
39
+ // -- Channel mutations ----------------------------------------------------
40
+ async create(input) {
41
+ const data = await this.gql.request(CreateChannelDocument, { input });
42
+ return data.createChannel;
43
+ }
44
+ async update(input) {
45
+ const data = await this.gql.request(UpdateChannelDocument, { input });
46
+ return data.updateChannel;
47
+ }
48
+ async remove(groupId) {
49
+ const data = await this.gql.request(DeleteChannelDocument, { groupId });
50
+ return data.deleteChannel;
51
+ }
52
+ async setPolicy(input) {
53
+ const data = await this.gql.request(SetChannelPolicyDocument, { input });
54
+ return data.setChannelPolicy;
55
+ }
56
+ // -- Membership mutations -------------------------------------------------
57
+ async join(groupId) {
58
+ const data = await this.gql.request(JoinChannelDocument, { groupId });
59
+ return data.joinChannel;
60
+ }
61
+ async requestToJoin(groupId) {
62
+ const data = await this.gql.request(RequestToJoinChannelDocument, { groupId });
63
+ return data.requestToJoinChannel;
64
+ }
65
+ async leave(groupId) {
66
+ const data = await this.gql.request(LeaveChannelDocument, { groupId });
67
+ return data.leaveChannel;
68
+ }
69
+ async addMember(groupId, userId) {
70
+ const data = await this.gql.request(AddChannelMemberDocument, { groupId, userId });
71
+ return data.addChannelMember;
72
+ }
73
+ async removeMember(groupId, userId) {
74
+ const data = await this.gql.request(RemoveChannelMemberDocument, { groupId, userId });
75
+ return data.removeChannelMember;
76
+ }
77
+ async setMemberRoles(input) {
78
+ const data = await this.gql.request(SetChannelMemberRolesDocument, { input });
79
+ return data.setChannelMemberRoles;
80
+ }
81
+ // -- Role mutations -------------------------------------------------------
82
+ async createRole(input) {
83
+ const data = await this.gql.request(CreateChannelRoleDocument, { input });
84
+ return data.createChannelRole;
85
+ }
86
+ async updateRole(input) {
87
+ const data = await this.gql.request(UpdateChannelRoleDocument, { input });
88
+ return data.updateChannelRole;
89
+ }
90
+ async deleteRole(groupRoleId) {
91
+ const data = await this.gql.request(DeleteChannelRoleDocument, { groupRoleId });
92
+ return data.deleteChannelRole;
93
+ }
94
+ }
@@ -0,0 +1,40 @@
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 } from '../generated/graphql.js';
3
+ /**
4
+ * Abstract game model sub-client (cks-game-api). Studios author the model
5
+ * (container types, property schemas, functions, tier features) and players
6
+ * query state + invoke functions at runtime.
7
+ *
8
+ * Arbitrary JSON values are passed/returned as JSON-encoded strings (the
9
+ * `*Json` fields); callers JSON.parse / JSON.stringify around them.
10
+ *
11
+ * Exposed as `client.gameModel`.
12
+ */
13
+ export declare class GameModelAPI {
14
+ private gql;
15
+ constructor(gql: GraphQLClient);
16
+ createSession(input: GameModelCreateSessionMutationVariables['input']): Promise<GameModelCreateSessionMutation['gameModelCreateSession']>;
17
+ joinSession(input: GameModelJoinSessionMutationVariables['input']): Promise<GameModelJoinSessionMutation['gameModelJoinSession']>;
18
+ setSessionTurn(input: GameModelSetSessionTurnMutationVariables['input']): Promise<GameModelSetSessionTurnMutation['gameModelSetSessionTurn']>;
19
+ createContainer(input: GameModelCreateContainerMutationVariables['input']): Promise<GameModelCreateContainerMutation['gameModelCreateContainer']>;
20
+ setProperty(input: GameModelSetPropertyMutationVariables['input']): Promise<GameModelSetPropertyMutation['gameModelSetProperty']>;
21
+ addEdge(input: GameModelAddEdgeMutationVariables['input']): Promise<GameModelAddEdgeMutation['gameModelAddEdge']>;
22
+ invoke(input: GameModelInvokeMutationVariables['input']): Promise<GameModelInvokeMutation['gameModelInvoke']>;
23
+ container(variables: GameModelContainerQueryVariables): Promise<GameModelContainerQuery['gameModelContainer']>;
24
+ containers(variables: GameModelContainersQueryVariables): Promise<GameModelContainersQuery['gameModelContainers']>;
25
+ containerState(variables: GameModelContainerStateQueryVariables): Promise<GameModelContainerStateQuery['gameModelContainerState']>;
26
+ traverse(variables: GameModelTraverseQueryVariables): Promise<GameModelTraverseQuery['gameModelTraverse']>;
27
+ session(variables: GameModelSessionQueryVariables): Promise<GameModelSessionQuery['gameModelSession']>;
28
+ sessions(variables: GameModelSessionsQueryVariables): Promise<GameModelSessionsQuery['gameModelSessions']>;
29
+ events(variables: GameModelEventsQueryVariables): Promise<GameModelEventsQuery['gameModelEvents']>;
30
+ seed(input: GameModelSeedMutationVariables['input']): Promise<GameModelSeedMutation['gameModelSeed']>;
31
+ upsertContainerType(input: GameModelUpsertContainerTypeMutationVariables['input']): Promise<GameModelUpsertContainerTypeMutation['gameModelUpsertContainerType']>;
32
+ upsertPropertyDef(input: GameModelUpsertPropertyDefMutationVariables['input']): Promise<GameModelUpsertPropertyDefMutation['gameModelUpsertPropertyDef']>;
33
+ upsertFunction(input: GameModelUpsertFunctionMutationVariables['input']): Promise<GameModelUpsertFunctionMutation['gameModelUpsertFunction']>;
34
+ deleteFunction(variables: GameModelDeleteFunctionMutationVariables): Promise<GameModelDeleteFunctionMutation['gameModelDeleteFunction']>;
35
+ defineFeature(input: GameModelDefineFeatureMutationVariables['input']): Promise<GameModelDefineFeatureMutation['gameModelDefineFeature']>;
36
+ grantTierFeature(input: GameModelGrantTierFeatureMutationVariables['input']): Promise<GameModelGrantTierFeatureMutation['gameModelGrantTierFeature']>;
37
+ setPolicy(input: GameModelSetPolicyMutationVariables['input']): Promise<GameModelSetPolicyMutation['gameModelSetPolicy']>;
38
+ typeSchema(variables: GameModelTypeSchemaQueryVariables): Promise<GameModelTypeSchemaQuery['gameModelTypeSchema']>;
39
+ }
40
+ //# sourceMappingURL=gameModel.d.ts.map
@@ -0,0 +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,EAGL,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAE5C,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAE1C,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,gCAAgC,EACrC,KAAK,yCAAyC,EAE9C,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAE1C,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EAEtC,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EAErC,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EAErC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EAEtC,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAE1C,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAGlC,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EAEnC,KAAK,oCAAoC,EACzC,KAAK,6CAA6C,EAElD,KAAK,kCAAkC,EACvC,KAAK,2CAA2C,EAEhD,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAE5C,KAAK,iCA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C,GAClD,OAAO,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAKtD,UAAU,CACd,SAAS,EAAE,iCAAiC,GAC3C,OAAO,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;CAI5D"}
@@ -0,0 +1,114 @@
1
+ import {
2
+ // Runtime (player) ops
3
+ GameModelCreateSessionDocument, GameModelJoinSessionDocument, GameModelSetSessionTurnDocument, GameModelCreateContainerDocument, GameModelSetPropertyDocument, GameModelAddEdgeDocument, GameModelInvokeDocument, GameModelContainerDocument, GameModelContainersDocument, GameModelContainerStateDocument, GameModelTraverseDocument, GameModelSessionDocument, GameModelSessionsDocument, GameModelEventsDocument,
4
+ // Studio authoring ops
5
+ GameModelSeedDocument, GameModelUpsertContainerTypeDocument, GameModelUpsertPropertyDefDocument, GameModelUpsertFunctionDocument, GameModelDeleteFunctionDocument, GameModelDefineFeatureDocument, GameModelGrantTierFeatureDocument, GameModelSetPolicyDocument, GameModelTypeSchemaDocument, } from '../generated/graphql.js';
6
+ /**
7
+ * Abstract game model sub-client (cks-game-api). Studios author the model
8
+ * (container types, property schemas, functions, tier features) and players
9
+ * query state + invoke functions at runtime.
10
+ *
11
+ * Arbitrary JSON values are passed/returned as JSON-encoded strings (the
12
+ * `*Json` fields); callers JSON.parse / JSON.stringify around them.
13
+ *
14
+ * Exposed as `client.gameModel`.
15
+ */
16
+ export class GameModelAPI {
17
+ constructor(gql) {
18
+ this.gql = gql;
19
+ }
20
+ // -- Runtime (player) -------------------------------------------------------
21
+ async createSession(input) {
22
+ const data = await this.gql.request(GameModelCreateSessionDocument, { input });
23
+ return data.gameModelCreateSession;
24
+ }
25
+ async joinSession(input) {
26
+ const data = await this.gql.request(GameModelJoinSessionDocument, { input });
27
+ return data.gameModelJoinSession;
28
+ }
29
+ async setSessionTurn(input) {
30
+ const data = await this.gql.request(GameModelSetSessionTurnDocument, { input });
31
+ return data.gameModelSetSessionTurn;
32
+ }
33
+ async createContainer(input) {
34
+ const data = await this.gql.request(GameModelCreateContainerDocument, { input });
35
+ return data.gameModelCreateContainer;
36
+ }
37
+ async setProperty(input) {
38
+ const data = await this.gql.request(GameModelSetPropertyDocument, { input });
39
+ return data.gameModelSetProperty;
40
+ }
41
+ async addEdge(input) {
42
+ const data = await this.gql.request(GameModelAddEdgeDocument, { input });
43
+ return data.gameModelAddEdge;
44
+ }
45
+ async invoke(input) {
46
+ const data = await this.gql.request(GameModelInvokeDocument, { input });
47
+ return data.gameModelInvoke;
48
+ }
49
+ async container(variables) {
50
+ const data = await this.gql.request(GameModelContainerDocument, variables);
51
+ return data.gameModelContainer;
52
+ }
53
+ async containers(variables) {
54
+ const data = await this.gql.request(GameModelContainersDocument, variables);
55
+ return data.gameModelContainers;
56
+ }
57
+ async containerState(variables) {
58
+ const data = await this.gql.request(GameModelContainerStateDocument, variables);
59
+ return data.gameModelContainerState;
60
+ }
61
+ async traverse(variables) {
62
+ const data = await this.gql.request(GameModelTraverseDocument, variables);
63
+ return data.gameModelTraverse;
64
+ }
65
+ async session(variables) {
66
+ const data = await this.gql.request(GameModelSessionDocument, variables);
67
+ return data.gameModelSession;
68
+ }
69
+ async sessions(variables) {
70
+ const data = await this.gql.request(GameModelSessionsDocument, variables);
71
+ return data.gameModelSessions;
72
+ }
73
+ async events(variables) {
74
+ const data = await this.gql.request(GameModelEventsDocument, variables);
75
+ return data.gameModelEvents;
76
+ }
77
+ // -- Studio authoring -------------------------------------------------------
78
+ async seed(input) {
79
+ const data = await this.gql.request(GameModelSeedDocument, { input });
80
+ return data.gameModelSeed;
81
+ }
82
+ async upsertContainerType(input) {
83
+ const data = await this.gql.request(GameModelUpsertContainerTypeDocument, { input });
84
+ return data.gameModelUpsertContainerType;
85
+ }
86
+ async upsertPropertyDef(input) {
87
+ const data = await this.gql.request(GameModelUpsertPropertyDefDocument, { input });
88
+ return data.gameModelUpsertPropertyDef;
89
+ }
90
+ async upsertFunction(input) {
91
+ const data = await this.gql.request(GameModelUpsertFunctionDocument, { input });
92
+ return data.gameModelUpsertFunction;
93
+ }
94
+ async deleteFunction(variables) {
95
+ const data = await this.gql.request(GameModelDeleteFunctionDocument, variables);
96
+ return data.gameModelDeleteFunction;
97
+ }
98
+ async defineFeature(input) {
99
+ const data = await this.gql.request(GameModelDefineFeatureDocument, { input });
100
+ return data.gameModelDefineFeature;
101
+ }
102
+ async grantTierFeature(input) {
103
+ const data = await this.gql.request(GameModelGrantTierFeatureDocument, { input });
104
+ return data.gameModelGrantTierFeature;
105
+ }
106
+ async setPolicy(input) {
107
+ const data = await this.gql.request(GameModelSetPolicyDocument, { input });
108
+ return data.gameModelSetPolicy;
109
+ }
110
+ async typeSchema(variables) {
111
+ const data = await this.gql.request(GameModelTypeSchemaDocument, variables);
112
+ return data.gameModelTypeSchema;
113
+ }
114
+ }