@crowdedkingdoms/crowdyjs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATION.md +247 -0
  3. package/README.md +303 -0
  4. package/dist/auth-state.d.ts +11 -0
  5. package/dist/auth-state.d.ts.map +1 -0
  6. package/dist/auth-state.js +13 -0
  7. package/dist/client.d.ts +135 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +150 -0
  10. package/dist/crowdy-client.d.ts +182 -0
  11. package/dist/crowdy-client.d.ts.map +1 -0
  12. package/dist/crowdy-client.js +146 -0
  13. package/dist/domains/actors.d.ts +117 -0
  14. package/dist/domains/actors.d.ts.map +1 -0
  15. package/dist/domains/actors.js +140 -0
  16. package/dist/domains/admin.d.ts +61 -0
  17. package/dist/domains/admin.d.ts.map +1 -0
  18. package/dist/domains/admin.js +33 -0
  19. package/dist/domains/appAccess.d.ts +141 -0
  20. package/dist/domains/appAccess.d.ts.map +1 -0
  21. package/dist/domains/appAccess.js +198 -0
  22. package/dist/domains/apps.d.ts +192 -0
  23. package/dist/domains/apps.d.ts.map +1 -0
  24. package/dist/domains/apps.js +217 -0
  25. package/dist/domains/auth.d.ts +163 -0
  26. package/dist/domains/auth.d.ts.map +1 -0
  27. package/dist/domains/auth.js +208 -0
  28. package/dist/domains/avatars.d.ts +94 -0
  29. package/dist/domains/avatars.d.ts.map +1 -0
  30. package/dist/domains/avatars.js +137 -0
  31. package/dist/domains/billing.d.ts +97 -0
  32. package/dist/domains/billing.d.ts.map +1 -0
  33. package/dist/domains/billing.js +131 -0
  34. package/dist/domains/channels.d.ts +293 -0
  35. package/dist/domains/channels.d.ts.map +1 -0
  36. package/dist/domains/channels.js +353 -0
  37. package/dist/domains/chunks.d.ts +133 -0
  38. package/dist/domains/chunks.d.ts.map +1 -0
  39. package/dist/domains/chunks.js +153 -0
  40. package/dist/domains/controlPlane.d.ts +174 -0
  41. package/dist/domains/controlPlane.d.ts.map +1 -0
  42. package/dist/domains/controlPlane.js +252 -0
  43. package/dist/domains/environments.d.ts +155 -0
  44. package/dist/domains/environments.d.ts.map +1 -0
  45. package/dist/domains/environments.js +223 -0
  46. package/dist/domains/gameApps.d.ts +114 -0
  47. package/dist/domains/gameApps.d.ts.map +1 -0
  48. package/dist/domains/gameApps.js +169 -0
  49. package/dist/domains/gameModel.d.ts +668 -0
  50. package/dist/domains/gameModel.d.ts.map +1 -0
  51. package/dist/domains/gameModel.js +816 -0
  52. package/dist/domains/host.d.ts +35 -0
  53. package/dist/domains/host.d.ts.map +1 -0
  54. package/dist/domains/host.js +40 -0
  55. package/dist/domains/organizations.d.ts +179 -0
  56. package/dist/domains/organizations.d.ts.map +1 -0
  57. package/dist/domains/organizations.js +269 -0
  58. package/dist/domains/payments.d.ts +104 -0
  59. package/dist/domains/payments.d.ts.map +1 -0
  60. package/dist/domains/payments.js +129 -0
  61. package/dist/domains/platform.d.ts +49 -0
  62. package/dist/domains/platform.d.ts.map +1 -0
  63. package/dist/domains/platform.js +50 -0
  64. package/dist/domains/quotas.d.ts +62 -0
  65. package/dist/domains/quotas.d.ts.map +1 -0
  66. package/dist/domains/quotas.js +79 -0
  67. package/dist/domains/serverStatus.d.ts +90 -0
  68. package/dist/domains/serverStatus.d.ts.map +1 -0
  69. package/dist/domains/serverStatus.js +104 -0
  70. package/dist/domains/sharedEnvironment.d.ts +133 -0
  71. package/dist/domains/sharedEnvironment.d.ts.map +1 -0
  72. package/dist/domains/sharedEnvironment.js +179 -0
  73. package/dist/domains/state.d.ts +64 -0
  74. package/dist/domains/state.d.ts.map +1 -0
  75. package/dist/domains/state.js +75 -0
  76. package/dist/domains/teams.d.ts +292 -0
  77. package/dist/domains/teams.d.ts.map +1 -0
  78. package/dist/domains/teams.js +352 -0
  79. package/dist/domains/teleport.d.ts +41 -0
  80. package/dist/domains/teleport.d.ts.map +1 -0
  81. package/dist/domains/teleport.js +43 -0
  82. package/dist/domains/udp.d.ts +405 -0
  83. package/dist/domains/udp.d.ts.map +1 -0
  84. package/dist/domains/udp.js +457 -0
  85. package/dist/domains/usage.d.ts +76 -0
  86. package/dist/domains/usage.d.ts.map +1 -0
  87. package/dist/domains/usage.js +110 -0
  88. package/dist/domains/users.d.ts +147 -0
  89. package/dist/domains/users.d.ts.map +1 -0
  90. package/dist/domains/users.js +195 -0
  91. package/dist/domains/voxels.d.ts +136 -0
  92. package/dist/domains/voxels.d.ts.map +1 -0
  93. package/dist/domains/voxels.js +153 -0
  94. package/dist/errors.d.ts +158 -0
  95. package/dist/errors.d.ts.map +1 -0
  96. package/dist/errors.js +142 -0
  97. package/dist/generated/graphql.d.ts +12206 -0
  98. package/dist/generated/graphql.d.ts.map +1 -0
  99. package/dist/generated/graphql.js +474 -0
  100. package/dist/index.d.ts +84 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +85 -0
  103. package/dist/logger.d.ts +8 -0
  104. package/dist/logger.d.ts.map +1 -0
  105. package/dist/logger.js +1 -0
  106. package/dist/realtime.d.ts +319 -0
  107. package/dist/realtime.d.ts.map +1 -0
  108. package/dist/realtime.js +390 -0
  109. package/dist/session.d.ts +73 -0
  110. package/dist/session.d.ts.map +1 -0
  111. package/dist/session.js +96 -0
  112. package/dist/subscriptions.d.ts +2 -0
  113. package/dist/subscriptions.d.ts.map +1 -0
  114. package/dist/subscriptions.js +1 -0
  115. package/dist/types.d.ts +658 -0
  116. package/dist/types.d.ts.map +1 -0
  117. package/dist/types.js +61 -0
  118. package/dist/utils.d.ts +98 -0
  119. package/dist/utils.d.ts.map +1 -0
  120. package/dist/utils.js +136 -0
  121. package/dist/world.d.ts +236 -0
  122. package/dist/world.d.ts.map +1 -0
  123. package/dist/world.js +275 -0
  124. package/package.json +73 -0
@@ -0,0 +1,117 @@
1
+ import type { GraphQLClient } from '../client.js';
2
+ import { type ActorQuery, type ActorQueryVariables, type ActorsQuery, type ActorsQueryVariables, type ActorsConnectionQuery, type ActorsConnectionQueryVariables, type BatchLookupActorsQuery, type BatchLookupActorsQueryVariables, type CreateActorMutation, type CreateActorMutationVariables, type UpdateActorMutation, type UpdateActorMutationVariables, type DeleteActorMutation, type DeleteActorMutationVariables, type UpdateActorStateMutation, type UpdateActorStateMutationVariables } from '../generated/graphql.js';
3
+ /**
4
+ * Persisted-actor (player / NPC) CRUD and filtering on the **game-api**.
5
+ * Exposed as `client.actors`.
6
+ *
7
+ * An "actor" here is the durable, server-stored record of a participant
8
+ * (identity, owning app, optional avatar, last-known chunk, and a state blob) —
9
+ * not the high-frequency spatial replication stream. For real-time position
10
+ * and state fan-out use the UDP path instead (`client.udp.sendActorUpdate(...)`
11
+ * or the ergonomic `client.world(appId).actor()` helper), which is unchanged
12
+ * and far cheaper per update.
13
+ *
14
+ * Actor ids are exactly **32 ASCII characters** (the UDP-wire actor id), **not**
15
+ * a hyphenated RFC-4122 UUID. Use {@link generateCrowdyUuid} to mint one.
16
+ * `BigInt` values (`appId`, `avatarId`, `userId`) are sent and received as
17
+ * decimal strings.
18
+ *
19
+ * Every method requires an authenticated session (a Bearer token set via
20
+ * `client.auth.login()` or `client.setToken()`) and that the caller is
21
+ * entitled to the target app, or it throws {@link CrowdyGraphQLError}
22
+ * (`UNAUTHENTICATED` / `FORBIDDEN`).
23
+ */
24
+ export declare class ActorsAPI {
25
+ private gql;
26
+ constructor(gql: GraphQLClient);
27
+ /**
28
+ * Fetch a single persisted actor by its 32-character actor id.
29
+ *
30
+ * @param uuid - The actor's 32-ASCII-character id.
31
+ * @returns The {@link Actor}, or `null` if no actor with that id exists.
32
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
33
+ * isn't entitled to the actor's app.
34
+ */
35
+ get(uuid: ActorQueryVariables['uuid']): Promise<ActorQuery['actor']>;
36
+ /**
37
+ * List persisted actors, optionally narrowed by an {@link ActorFilterInput}
38
+ * (e.g. by app, owning user, or avatar). Omit the filter to use its defaults.
39
+ *
40
+ * @param filter - Optional filter; fields are ANDed together.
41
+ * @returns The matching actors.
42
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
43
+ */
44
+ list(filter?: ActorsQueryVariables['filter']): Promise<ActorsQuery['actors']>;
45
+ /**
46
+ * Relay-style cursor pagination over the caller's actors — the preferred
47
+ * alternative to {@link list} for large result sets. Page with `first` plus
48
+ * the previous page's `pageInfo.endCursor` as `after`; `filter` fields are
49
+ * ANDed together. See https://docs.crowdedkingdoms.com/overview/pagination.
50
+ *
51
+ * @param args - Optional `first` (default 50, max 200), `after` cursor, and
52
+ * {@link ActorFilterInput}.
53
+ * @returns An {@link ActorsConnection} (`edges { cursor node }`, `pageInfo`,
54
+ * `totalCount`).
55
+ */
56
+ listConnection(args?: ActorsConnectionQueryVariables): Promise<ActorsConnectionQuery['actorsConnection']>;
57
+ /**
58
+ * Resolve many actors in one round-trip by id (and/or the other keys the
59
+ * {@link BatchActorLookupInput} accepts). Prefer this over calling
60
+ * {@link get} in a loop — it avoids N requests and N auth checks.
61
+ *
62
+ * @param input - The batch lookup keys.
63
+ * @returns The actors that were found (missing ids are simply omitted).
64
+ */
65
+ batchLookup(input: BatchLookupActorsQueryVariables['input']): Promise<BatchLookupActorsQuery['batchLookupActors']>;
66
+ /**
67
+ * Create a persisted actor. `input.uuid` must be a unique 32-ASCII-character
68
+ * id and `input.appId` the owning app; `chunk` is the initial grid position.
69
+ * `avatarId`, `privateState`, and `publicState` are optional (state blobs are
70
+ * base64-encoded binary).
71
+ *
72
+ * @param input - {@link CreateActorInput}.
73
+ * @returns The newly created {@link Actor}.
74
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. malformed/duplicate
75
+ * uuid), `FORBIDDEN` if not entitled to the app, or `UNAUTHENTICATED`.
76
+ */
77
+ create(input: CreateActorMutationVariables['input']): Promise<CreateActorMutation['createActor']>;
78
+ /**
79
+ * Patch an existing actor. Only the fields present on `input` change; omitted
80
+ * fields are left untouched.
81
+ *
82
+ * @param uuid - The actor's 32-character id.
83
+ * @param input - Fields to change ({@link UpdateActorInput}).
84
+ * @returns The updated {@link Actor}.
85
+ * @throws {CrowdyGraphQLError} if the actor doesn't exist or the caller lacks
86
+ * access.
87
+ */
88
+ update(uuid: UpdateActorMutationVariables['uuid'], input: UpdateActorMutationVariables['input']): Promise<UpdateActorMutation['updateActor']>;
89
+ /**
90
+ * Delete a persisted actor.
91
+ *
92
+ * Pass an `idempotencyKey` to make retries safe: replaying with the same key
93
+ * returns the first result instead of re-applying, while the same key with a
94
+ * **different** `uuid` throws {@link CrowdyGraphQLError} with
95
+ * `code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h.
96
+ * Requires game-api ≥ v0.10.3.
97
+ *
98
+ * @param uuid - The actor's 32-character id.
99
+ * @param idempotencyKey - Optional client-supplied key for safe retries.
100
+ * @returns The deleted {@link Actor} (its identifying fields).
101
+ * @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT`, `FORBIDDEN`, or
102
+ * `UNAUTHENTICATED`.
103
+ */
104
+ delete(uuid: DeleteActorMutationVariables['uuid'], idempotencyKey?: DeleteActorMutationVariables['idempotencyKey']): Promise<DeleteActorMutation['deleteActor']>;
105
+ /**
106
+ * Replace just an actor's state blob(s) without touching its other fields —
107
+ * a lighter write than {@link update} when only `privateState`/`publicState`
108
+ * change. State is base64-encoded binary.
109
+ *
110
+ * @param uuid - The actor's 32-character id.
111
+ * @param input - {@link UpdateActorStateInput}.
112
+ * @returns The updated {@link Actor}.
113
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
114
+ */
115
+ updateState(uuid: UpdateActorStateMutationVariables['uuid'], input: UpdateActorStateMutationVariables['input']): Promise<UpdateActorStateMutation['updateActorState']>;
116
+ }
117
+ //# sourceMappingURL=actors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../src/domains/actors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa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CAAC,OAAO,CAAC,GAC3C,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAK9C;;;;;;;;;;;;;;OAcG;IACG,MAAM,CACV,IAAI,EAAE,4BAA4B,CAAC,MAAM,CAAC,EAC1C,cAAc,CAAC,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,GAC9D,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAK9C;;;;;;;;;OASG;IACG,WAAW,CACf,IAAI,EAAE,iCAAiC,CAAC,MAAM,CAAC,EAC/C,KAAK,EAAE,iCAAiC,CAAC,OAAO,CAAC,GAChD,OAAO,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;CAIzD"}
@@ -0,0 +1,140 @@
1
+ import { ActorDocument, ActorsDocument, ActorsConnectionDocument, BatchLookupActorsDocument, CreateActorDocument, UpdateActorDocument, DeleteActorDocument, UpdateActorStateDocument, } from '../generated/graphql.js';
2
+ /**
3
+ * Persisted-actor (player / NPC) CRUD and filtering on the **game-api**.
4
+ * Exposed as `client.actors`.
5
+ *
6
+ * An "actor" here is the durable, server-stored record of a participant
7
+ * (identity, owning app, optional avatar, last-known chunk, and a state blob) —
8
+ * not the high-frequency spatial replication stream. For real-time position
9
+ * and state fan-out use the UDP path instead (`client.udp.sendActorUpdate(...)`
10
+ * or the ergonomic `client.world(appId).actor()` helper), which is unchanged
11
+ * and far cheaper per update.
12
+ *
13
+ * Actor ids are exactly **32 ASCII characters** (the UDP-wire actor id), **not**
14
+ * a hyphenated RFC-4122 UUID. Use {@link generateCrowdyUuid} to mint one.
15
+ * `BigInt` values (`appId`, `avatarId`, `userId`) are sent and received as
16
+ * decimal strings.
17
+ *
18
+ * Every method requires an authenticated session (a Bearer token set via
19
+ * `client.auth.login()` or `client.setToken()`) and that the caller is
20
+ * entitled to the target app, or it throws {@link CrowdyGraphQLError}
21
+ * (`UNAUTHENTICATED` / `FORBIDDEN`).
22
+ */
23
+ export class ActorsAPI {
24
+ constructor(gql) {
25
+ this.gql = gql;
26
+ }
27
+ /**
28
+ * Fetch a single persisted actor by its 32-character actor id.
29
+ *
30
+ * @param uuid - The actor's 32-ASCII-character id.
31
+ * @returns The {@link Actor}, or `null` if no actor with that id exists.
32
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` if the caller
33
+ * isn't entitled to the actor's app.
34
+ */
35
+ async get(uuid) {
36
+ const data = await this.gql.request(ActorDocument, { uuid });
37
+ return data.actor;
38
+ }
39
+ /**
40
+ * List persisted actors, optionally narrowed by an {@link ActorFilterInput}
41
+ * (e.g. by app, owning user, or avatar). Omit the filter to use its defaults.
42
+ *
43
+ * @param filter - Optional filter; fields are ANDed together.
44
+ * @returns The matching actors.
45
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
46
+ */
47
+ async list(filter) {
48
+ const data = await this.gql.request(ActorsDocument, { filter });
49
+ return data.actors;
50
+ }
51
+ /**
52
+ * Relay-style cursor pagination over the caller's actors — the preferred
53
+ * alternative to {@link list} for large result sets. Page with `first` plus
54
+ * the previous page's `pageInfo.endCursor` as `after`; `filter` fields are
55
+ * ANDed together. See https://docs.crowdedkingdoms.com/overview/pagination.
56
+ *
57
+ * @param args - Optional `first` (default 50, max 200), `after` cursor, and
58
+ * {@link ActorFilterInput}.
59
+ * @returns An {@link ActorsConnection} (`edges { cursor node }`, `pageInfo`,
60
+ * `totalCount`).
61
+ */
62
+ async listConnection(args = {}) {
63
+ const data = await this.gql.request(ActorsConnectionDocument, args);
64
+ return data.actorsConnection;
65
+ }
66
+ /**
67
+ * Resolve many actors in one round-trip by id (and/or the other keys the
68
+ * {@link BatchActorLookupInput} accepts). Prefer this over calling
69
+ * {@link get} in a loop — it avoids N requests and N auth checks.
70
+ *
71
+ * @param input - The batch lookup keys.
72
+ * @returns The actors that were found (missing ids are simply omitted).
73
+ */
74
+ async batchLookup(input) {
75
+ const data = await this.gql.request(BatchLookupActorsDocument, { input });
76
+ return data.batchLookupActors;
77
+ }
78
+ /**
79
+ * Create a persisted actor. `input.uuid` must be a unique 32-ASCII-character
80
+ * id and `input.appId` the owning app; `chunk` is the initial grid position.
81
+ * `avatarId`, `privateState`, and `publicState` are optional (state blobs are
82
+ * base64-encoded binary).
83
+ *
84
+ * @param input - {@link CreateActorInput}.
85
+ * @returns The newly created {@link Actor}.
86
+ * @throws {CrowdyGraphQLError} `BAD_USER_INPUT` (e.g. malformed/duplicate
87
+ * uuid), `FORBIDDEN` if not entitled to the app, or `UNAUTHENTICATED`.
88
+ */
89
+ async create(input) {
90
+ const data = await this.gql.request(CreateActorDocument, { input });
91
+ return data.createActor;
92
+ }
93
+ /**
94
+ * Patch an existing actor. Only the fields present on `input` change; omitted
95
+ * fields are left untouched.
96
+ *
97
+ * @param uuid - The actor's 32-character id.
98
+ * @param input - Fields to change ({@link UpdateActorInput}).
99
+ * @returns The updated {@link Actor}.
100
+ * @throws {CrowdyGraphQLError} if the actor doesn't exist or the caller lacks
101
+ * access.
102
+ */
103
+ async update(uuid, input) {
104
+ const data = await this.gql.request(UpdateActorDocument, { uuid, input });
105
+ return data.updateActor;
106
+ }
107
+ /**
108
+ * Delete a persisted actor.
109
+ *
110
+ * Pass an `idempotencyKey` to make retries safe: replaying with the same key
111
+ * returns the first result instead of re-applying, while the same key with a
112
+ * **different** `uuid` throws {@link CrowdyGraphQLError} with
113
+ * `code === 'IDEMPOTENCY_CONFLICT'`. Keys expire server-side after 24h.
114
+ * Requires game-api ≥ v0.10.3.
115
+ *
116
+ * @param uuid - The actor's 32-character id.
117
+ * @param idempotencyKey - Optional client-supplied key for safe retries.
118
+ * @returns The deleted {@link Actor} (its identifying fields).
119
+ * @throws {CrowdyGraphQLError} `IDEMPOTENCY_CONFLICT`, `FORBIDDEN`, or
120
+ * `UNAUTHENTICATED`.
121
+ */
122
+ async delete(uuid, idempotencyKey) {
123
+ const data = await this.gql.request(DeleteActorDocument, { uuid, idempotencyKey });
124
+ return data.deleteActor;
125
+ }
126
+ /**
127
+ * Replace just an actor's state blob(s) without touching its other fields —
128
+ * a lighter write than {@link update} when only `privateState`/`publicState`
129
+ * change. State is base64-encoded binary.
130
+ *
131
+ * @param uuid - The actor's 32-character id.
132
+ * @param input - {@link UpdateActorStateInput}.
133
+ * @returns The updated {@link Actor}.
134
+ * @throws {CrowdyGraphQLError} on auth/validation failures.
135
+ */
136
+ async updateState(uuid, input) {
137
+ const data = await this.gql.request(UpdateActorStateDocument, { uuid, input });
138
+ return data.updateActorState;
139
+ }
140
+ }
@@ -0,0 +1,61 @@
1
+ import type { OrganizationsAPI } from './organizations.js';
2
+ import type { AppAccessAPI } from './appAccess.js';
3
+ import type { BillingAPI } from './billing.js';
4
+ import type { PaymentsAPI } from './payments.js';
5
+ import type { QuotasAPI } from './quotas.js';
6
+ import type { EnvironmentsAPI } from './environments.js';
7
+ import type { UsageAPI } from './usage.js';
8
+ import type { SharedEnvironmentAPI } from './sharedEnvironment.js';
9
+ import type { GameAppsAPI } from './gameApps.js';
10
+ /**
11
+ * Studio-admin facade — exposed as `client.admin`.
12
+ *
13
+ * Groups the privileged studio-administration sub-clients under one namespace so
14
+ * the browser-first, end-user surface (`client.auth`, `client.udp`,
15
+ * `client.world(...)`, ...) stays visually distinct from the management/admin
16
+ * surface a studio backend drives with a privileged token. These are the same
17
+ * instances also reachable at the top level (e.g. `client.billing`), grouped
18
+ * here for discoverability.
19
+ *
20
+ * Operator-only platform operations live separately under `client.operator`
21
+ * (requires `is_operator`).
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const org = await client.admin.organizations.create({ name, slug });
26
+ * const tier = await client.admin.appAccess.createTier({ ... });
27
+ * await client.admin.billing.setAppBudget(orgId, appId, '5000');
28
+ * ```
29
+ */
30
+ export declare class AdminAPI {
31
+ /** Organizations, members, RBAC roles, and org API tokens. */
32
+ readonly organizations: OrganizationsAPI;
33
+ /** App access tiers + per-user access grants. */
34
+ readonly appAccess: AppAccessAPI;
35
+ /** Org wallet + per-app spend budgets. */
36
+ readonly billing: BillingAPI;
37
+ /** Payment checkouts (wallet top-ups, plan purchases). */
38
+ readonly payments: PaymentsAPI;
39
+ /** Usage quotas at the org/app scope. */
40
+ readonly quotas: QuotasAPI;
41
+ /** Dedicated customer environments: provision, scale, deploy. */
42
+ readonly environments: EnvironmentsAPI;
43
+ /** Replication + GraphQL usage reporting. */
44
+ readonly usage: UsageAPI;
45
+ /** Shared-environment publishing, runtime gating, auto-billing. */
46
+ readonly sharedEnvironment: SharedEnvironmentAPI;
47
+ /** App grids + grid runtime-permission administration. */
48
+ readonly grids: GameAppsAPI;
49
+ constructor(deps: {
50
+ organizations: OrganizationsAPI;
51
+ appAccess: AppAccessAPI;
52
+ billing: BillingAPI;
53
+ payments: PaymentsAPI;
54
+ quotas: QuotasAPI;
55
+ environments: EnvironmentsAPI;
56
+ usage: UsageAPI;
57
+ sharedEnvironment: SharedEnvironmentAPI;
58
+ grids: GameAppsAPI;
59
+ });
60
+ }
61
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/domains/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,QAAQ;IACnB,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC;IACzC,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;IACjD,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;gBAEhB,IAAI,EAAE;QAChB,aAAa,EAAE,gBAAgB,CAAC;QAChC,SAAS,EAAE,YAAY,CAAC;QACxB,OAAO,EAAE,UAAU,CAAC;QACpB,QAAQ,EAAE,WAAW,CAAC;QACtB,MAAM,EAAE,SAAS,CAAC;QAClB,YAAY,EAAE,eAAe,CAAC;QAC9B,KAAK,EAAE,QAAQ,CAAC;QAChB,iBAAiB,EAAE,oBAAoB,CAAC;QACxC,KAAK,EAAE,WAAW,CAAC;KACpB;CAWF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Studio-admin facade — exposed as `client.admin`.
3
+ *
4
+ * Groups the privileged studio-administration sub-clients under one namespace so
5
+ * the browser-first, end-user surface (`client.auth`, `client.udp`,
6
+ * `client.world(...)`, ...) stays visually distinct from the management/admin
7
+ * surface a studio backend drives with a privileged token. These are the same
8
+ * instances also reachable at the top level (e.g. `client.billing`), grouped
9
+ * here for discoverability.
10
+ *
11
+ * Operator-only platform operations live separately under `client.operator`
12
+ * (requires `is_operator`).
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const org = await client.admin.organizations.create({ name, slug });
17
+ * const tier = await client.admin.appAccess.createTier({ ... });
18
+ * await client.admin.billing.setAppBudget(orgId, appId, '5000');
19
+ * ```
20
+ */
21
+ export class AdminAPI {
22
+ constructor(deps) {
23
+ this.organizations = deps.organizations;
24
+ this.appAccess = deps.appAccess;
25
+ this.billing = deps.billing;
26
+ this.payments = deps.payments;
27
+ this.quotas = deps.quotas;
28
+ this.environments = deps.environments;
29
+ this.usage = deps.usage;
30
+ this.sharedEnvironment = deps.sharedEnvironment;
31
+ this.grids = deps.grids;
32
+ }
33
+ }
@@ -0,0 +1,141 @@
1
+ import type { GraphQLClient } from '../client.js';
2
+ import { type AppAccessTiersQuery, type MyAppAccessQuery, type AppUserAccessByAppQuery, type AppUserAccessConnectionQuery, type AppUserAccessConnectionQueryVariables, type RuntimePermissionsQuery, type AppGrantMemberCandidatesQuery, type ClaimFreeAppAccessMutation, type GrantMyAppAccessMutation, type CreateAccessTierMutation, type UpdateAccessTierMutation, type ArchiveAccessTierMutation, type GrantAppAccessMutation, type RevokeAppAccessMutation, type CreateAccessTierInput, type UpdateAccessTierInput, type GrantAppAccessInput } from '../generated/graphql.js';
3
+ /**
4
+ * App access tiers + per-user access grants — exposed as `client.appAccess`
5
+ * (and grouped under `client.admin`).
6
+ *
7
+ * Targets the **management-api**. Tiers define the runtime-permission bundles
8
+ * (`access`, `teleport`, `update_voxel_data`, `use_voice_chat`, ...) a player
9
+ * gets; grants attach a user to a tier. New apps auto-provision an open default
10
+ * tier, so most players need no explicit grant.
11
+ *
12
+ * Reads of the tier catalog ({@link tiers}) are public; {@link myAccess} needs
13
+ * a session; tier admin and grant/revoke require the `manage_access_tiers` app
14
+ * permission. `BigInt` ids are decimal strings.
15
+ *
16
+ * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` / `FORBIDDEN` / `SCOPE_MISSING`
17
+ * per the permission notes above.
18
+ */
19
+ export declare class AppAccessAPI {
20
+ private readonly management;
21
+ constructor(management: GraphQLClient);
22
+ /**
23
+ * List the access tiers defined for an app. **Public.**
24
+ *
25
+ * @param appId - Numeric app id (`BigInt` as a decimal string).
26
+ * @returns The app's tiers, ordered.
27
+ */
28
+ tiers(appId: string): Promise<AppAccessTiersQuery['appAccessTiers']>;
29
+ /**
30
+ * Return the authenticated caller's access record for an app (which tier they
31
+ * hold and its status), or `null` if they have none.
32
+ *
33
+ * @param appId - Numeric app id.
34
+ * @returns The caller's {@link AppUserAccess}, or `null`.
35
+ */
36
+ myAccess(appId: string): Promise<MyAppAccessQuery['myAppAccess']>;
37
+ /**
38
+ * List the users who hold access to an app (paginated). Requires the
39
+ * `manage_access_tiers` app permission.
40
+ *
41
+ * @param appId - Numeric app id.
42
+ * @param opts - Optional `status` filter and `limit` / `offset` (default
43
+ * limit 50).
44
+ * @returns The matching access records.
45
+ */
46
+ usersByApp(appId: string, opts?: {
47
+ status?: string;
48
+ limit?: number;
49
+ offset?: number;
50
+ }): Promise<AppUserAccessByAppQuery['appUserAccessByApp']>;
51
+ /**
52
+ * Relay-style cursor pagination over an app's access grants — the preferred
53
+ * alternative to {@link usersByApp}. Page with `first` plus the previous
54
+ * page's `pageInfo.endCursor` as `after`; optional `status` filter. Requires
55
+ * the `manage_access_tiers` app permission. See
56
+ * https://docs.crowdedkingdoms.com/overview/pagination.
57
+ *
58
+ * @param args - `appId` plus optional `status`, `first`, and `after`.
59
+ * @returns An {@link AppUserAccessConnection}.
60
+ */
61
+ usersByAppConnection(args: AppUserAccessConnectionQueryVariables): Promise<AppUserAccessConnectionQuery['appUserAccessConnection']>;
62
+ /**
63
+ * List every valid runtime permission key (e.g. `access`, `teleport`,
64
+ * `update_voxel_data`, `use_voice_chat`) that a tier or grid grant can
65
+ * reference. **Public.**
66
+ *
67
+ * @returns The runtime permission keys.
68
+ */
69
+ runtimePermissions(): Promise<RuntimePermissionsQuery['runtimePermissions']>;
70
+ /**
71
+ * List org members eligible for a manual app-access grant (those without an
72
+ * active grant yet). Requires the `manage_access_tiers` app permission. Pair
73
+ * with {@link grant} to grant the chosen candidate.
74
+ *
75
+ * @param appId - Numeric app id.
76
+ * @returns The candidate users (id + email/gamertag where known).
77
+ */
78
+ grantMemberCandidates(appId: string): Promise<AppGrantMemberCandidatesQuery['appGrantMemberCandidates']>;
79
+ /**
80
+ * Self-service: claim the app's free/default tier for the authenticated
81
+ * caller (no admin permission required). Use when an app exposes a free tier
82
+ * a player can opt into themselves.
83
+ *
84
+ * @param appId - Numeric app id.
85
+ * @returns The caller's new {@link AppUserAccess} record.
86
+ */
87
+ claimFree(appId: string): Promise<ClaimFreeAppAccessMutation['claimFreeAppAccess']>;
88
+ /**
89
+ * Self-grant access to an app via its default tier for the authenticated
90
+ * caller, when the caller is an org member of the app's owning org.
91
+ *
92
+ * @param appId - Numeric app id.
93
+ * @returns The caller's new {@link AppUserAccess} record.
94
+ */
95
+ grantMine(appId: string): Promise<GrantMyAppAccessMutation['grantMyAppAccess']>;
96
+ /**
97
+ * Create a new access tier for an app. Requires the `manage_access_tiers` app
98
+ * permission.
99
+ *
100
+ * @param input - {@link CreateAccessTierInput}: `appId`, `name`, runtime
101
+ * `permissions`, pricing/free flags.
102
+ * @returns The created tier.
103
+ */
104
+ createTier(input: CreateAccessTierInput): Promise<CreateAccessTierMutation['createAccessTier']>;
105
+ /**
106
+ * Update an existing access tier. Requires the `manage_access_tiers` app
107
+ * permission.
108
+ *
109
+ * @param tierId - Numeric tier id.
110
+ * @param input - {@link UpdateAccessTierInput} fields to change.
111
+ * @returns The updated tier.
112
+ */
113
+ updateTier(tierId: string, input: UpdateAccessTierInput): Promise<UpdateAccessTierMutation['updateAccessTier']>;
114
+ /**
115
+ * Archive (soft-delete) an access tier so it can no longer be granted.
116
+ * Requires the `manage_access_tiers` app permission.
117
+ *
118
+ * @param tierId - Numeric tier id.
119
+ * @returns The archived tier's new status.
120
+ */
121
+ archiveTier(tierId: string): Promise<ArchiveAccessTierMutation['archiveAccessTier']>;
122
+ /**
123
+ * Grant a user access to an app at a given tier. Requires the
124
+ * `manage_access_tiers` app permission. Triggers replica-sync so the grant
125
+ * (and its grid permissions) reaches the game DB / Buddy.
126
+ *
127
+ * @param input - {@link GrantAppAccessInput}: `appId`, `userId`, `tierId`.
128
+ * @returns The created/updated access record.
129
+ */
130
+ grant(input: GrantAppAccessInput): Promise<GrantAppAccessMutation['grantAppAccess']>;
131
+ /**
132
+ * Revoke a user's access to an app. Requires the `manage_access_tiers` app
133
+ * permission.
134
+ *
135
+ * @param appId - Numeric app id.
136
+ * @param userId - Numeric id of the user whose access is revoked.
137
+ * @returns `true` on success.
138
+ */
139
+ revoke(appId: string, userId: string): Promise<RevokeAppAccessMutation['revokeAppAccess']>;
140
+ }
141
+ //# sourceMappingURL=appAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appAccess.d.ts","sourceRoot":"","sources":["../../src/domains/appAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAcL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAC1C,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,aAAa;IAEtD;;;;;OAKG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAO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