@crowdedkingdoms/crowdyjs 17.14.0-dev.1 → 18.0.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/MIGRATION.md +129 -1
  2. package/README.md +97 -164
  3. package/dist/crowdy-client.d.ts +12 -31
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +15 -37
  6. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  7. package/dist/crowdy-dsh/bridge.js +3 -6
  8. package/dist/crowdy-studio/controller.d.ts +34 -59
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +96 -225
  11. package/dist/crowdy-studio/diagnostics.d.ts +3 -12
  12. package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
  13. package/dist/crowdy-studio/dom-shell.d.ts +2 -4
  14. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  15. package/dist/crowdy-studio/dom-shell.js +16 -49
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -2
  17. package/dist/crowdy-studio/embed/hud-layer.d.ts.map +1 -1
  18. package/dist/crowdy-studio/embed/panel.d.ts +3 -13
  19. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  20. package/dist/crowdy-studio/embed/panel.js +3 -6
  21. package/dist/crowdy-studio/index.d.ts +1 -3
  22. package/dist/crowdy-studio/index.d.ts.map +1 -1
  23. package/dist/crowdy-studio/index.js +0 -2
  24. package/dist/crowdy-studio/models.d.ts +3 -4
  25. package/dist/crowdy-studio/models.d.ts.map +1 -1
  26. package/dist/crowdy-studio/starter-projects.d.ts +8 -12
  27. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  28. package/dist/crowdy-studio/starter-projects.js +12 -103
  29. package/dist/domains/appAccess.d.ts +14 -1
  30. package/dist/domains/appAccess.d.ts.map +1 -1
  31. package/dist/domains/appAccess.js +37 -1
  32. package/dist/domains/apps.d.ts +1 -10
  33. package/dist/domains/apps.d.ts.map +1 -1
  34. package/dist/domains/apps.js +1 -16
  35. package/dist/domains/host.d.ts +3 -3
  36. package/dist/domains/host.js +3 -3
  37. package/dist/domains/hosting.d.ts +0 -6
  38. package/dist/domains/hosting.d.ts.map +1 -1
  39. package/dist/domains/hosting.js +1 -16
  40. package/dist/domains/marketplace.d.ts +9 -70
  41. package/dist/domains/marketplace.d.ts.map +1 -1
  42. package/dist/domains/marketplace.js +9 -120
  43. package/dist/domains/organizations.d.ts +1 -9
  44. package/dist/domains/organizations.d.ts.map +1 -1
  45. package/dist/domains/organizations.js +1 -15
  46. package/dist/domains/payments.d.ts +5 -48
  47. package/dist/domains/payments.d.ts.map +1 -1
  48. package/dist/domains/payments.js +5 -57
  49. package/dist/domains/playerWallet.d.ts +6 -12
  50. package/dist/domains/playerWallet.d.ts.map +1 -1
  51. package/dist/domains/playerWallet.js +6 -21
  52. package/dist/domains/quotas.d.ts +20 -7
  53. package/dist/domains/quotas.d.ts.map +1 -1
  54. package/dist/domains/quotas.js +15 -6
  55. package/dist/domains/users.d.ts +7 -74
  56. package/dist/domains/users.d.ts.map +1 -1
  57. package/dist/domains/users.js +7 -105
  58. package/dist/errors.d.ts +7 -13
  59. package/dist/errors.d.ts.map +1 -1
  60. package/dist/errors.js +6 -10
  61. package/dist/generated/graphql.d.ts +955 -8272
  62. package/dist/generated/graphql.d.ts.map +1 -1
  63. package/dist/generated/graphql.js +5 -329
  64. package/dist/grid-mods/exec-client-halves.d.ts +19 -3
  65. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -1
  66. package/dist/grid-mods/exec-client-halves.js +17 -2
  67. package/dist/grid-mods/grid-host-calls.d.ts +29 -17
  68. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  69. package/dist/grid-mods/grid-host-calls.js +40 -46
  70. package/dist/grid-mods/mod-runtime.d.ts +18 -11
  71. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  72. package/dist/grid-mods/mod-runtime.js +4 -2
  73. package/dist/grid-scope.d.ts +0 -189
  74. package/dist/grid-scope.d.ts.map +1 -1
  75. package/dist/grid-scope.js +0 -70
  76. package/dist/index.d.ts +12 -18
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +10 -16
  79. package/dist/kit/actions.d.ts +5 -9
  80. package/dist/kit/actions.d.ts.map +1 -1
  81. package/dist/kit/actions.js +5 -9
  82. package/dist/kit/index.d.ts +2 -33
  83. package/dist/kit/index.d.ts.map +1 -1
  84. package/dist/kit/index.js +1 -32
  85. package/dist/kit/kit.d.ts +8 -208
  86. package/dist/kit/kit.d.ts.map +1 -1
  87. package/dist/kit/kit.js +5 -163
  88. package/dist/kit/social.d.ts +1 -3
  89. package/dist/kit/social.d.ts.map +1 -1
  90. package/dist/kit/social.js +1 -3
  91. package/dist/kit/wire.d.ts +16 -5
  92. package/dist/kit/wire.d.ts.map +1 -1
  93. package/dist/kit/wire.js +19 -5
  94. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  95. package/dist/live-coding/assets/manifest.json +1 -1
  96. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  97. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  98. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  99. package/dist/live-coding/rust-analysis.js +30 -34
  100. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  101. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  102. package/dist/player-runtime/client-host-calls.js +28 -0
  103. package/dist/player-runtime/glue-runtime.d.ts +24 -20
  104. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  105. package/dist/player-runtime/glue-runtime.js +26 -55
  106. package/dist/player-runtime/glue-sab.d.ts +2 -2
  107. package/dist/player-runtime/glue-sab.js +2 -2
  108. package/dist/player-runtime/player-code-broker.d.ts +70 -43
  109. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  110. package/dist/player-runtime/player-code-broker.js +159 -64
  111. package/dist/player-runtime/player-glue-worker.d.ts +8 -9
  112. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  113. package/dist/player-runtime/player-glue-worker.js +26 -11
  114. package/dist/stores/inbox.d.ts +1 -1
  115. package/dist/stores/inbox.d.ts.map +1 -1
  116. package/dist/stores/index.d.ts +0 -11
  117. package/dist/stores/index.d.ts.map +1 -1
  118. package/dist/stores/index.js +0 -4
  119. package/dist/stores/session.d.ts +0 -2
  120. package/dist/stores/session.d.ts.map +1 -1
  121. package/package.json +1 -1
  122. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  123. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  124. package/dist/crowdy-studio/model-lint-log.js +0 -93
  125. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  126. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  127. package/dist/crowdy-studio/model-lint.js +0 -45
  128. package/dist/domains/compute.d.ts +0 -208
  129. package/dist/domains/compute.d.ts.map +0 -1
  130. package/dist/domains/compute.js +0 -274
  131. package/dist/domains/controlPlane.d.ts +0 -38
  132. package/dist/domains/controlPlane.d.ts.map +0 -1
  133. package/dist/domains/controlPlane.js +0 -43
  134. package/dist/domains/gameModel.d.ts +0 -1174
  135. package/dist/domains/gameModel.d.ts.map +0 -1
  136. package/dist/domains/gameModel.js +0 -1333
  137. package/dist/domains/playerCompute.d.ts +0 -91
  138. package/dist/domains/playerCompute.d.ts.map +0 -1
  139. package/dist/domains/playerCompute.js +0 -136
  140. package/dist/domains/playerModel.d.ts +0 -20
  141. package/dist/domains/playerModel.d.ts.map +0 -1
  142. package/dist/domains/playerModel.js +0 -54
  143. package/dist/kit/abilities.d.ts +0 -66
  144. package/dist/kit/abilities.d.ts.map +0 -1
  145. package/dist/kit/abilities.js +0 -71
  146. package/dist/kit/blueprints/combat.d.ts +0 -81
  147. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  148. package/dist/kit/blueprints/combat.js +0 -357
  149. package/dist/kit/blueprints/core.d.ts +0 -222
  150. package/dist/kit/blueprints/core.d.ts.map +0 -1
  151. package/dist/kit/blueprints/core.js +0 -185
  152. package/dist/kit/blueprints/decks.d.ts +0 -50
  153. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  154. package/dist/kit/blueprints/decks.js +0 -163
  155. package/dist/kit/blueprints/economy.d.ts +0 -88
  156. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  157. package/dist/kit/blueprints/economy.js +0 -533
  158. package/dist/kit/blueprints/guild.d.ts +0 -51
  159. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  160. package/dist/kit/blueprints/guild.js +0 -50
  161. package/dist/kit/blueprints/index.d.ts +0 -23
  162. package/dist/kit/blueprints/index.d.ts.map +0 -1
  163. package/dist/kit/blueprints/index.js +0 -22
  164. package/dist/kit/blueprints/inventory.d.ts +0 -84
  165. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  166. package/dist/kit/blueprints/inventory.js +0 -257
  167. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  168. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  169. package/dist/kit/blueprints/leaderboards.js +0 -126
  170. package/dist/kit/blueprints/liveops.d.ts +0 -42
  171. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  172. package/dist/kit/blueprints/liveops.js +0 -170
  173. package/dist/kit/blueprints/locks.d.ts +0 -82
  174. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  175. package/dist/kit/blueprints/locks.js +0 -155
  176. package/dist/kit/blueprints/loot.d.ts +0 -90
  177. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  178. package/dist/kit/blueprints/loot.js +0 -229
  179. package/dist/kit/blueprints/matches.d.ts +0 -84
  180. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  181. package/dist/kit/blueprints/matches.js +0 -349
  182. package/dist/kit/blueprints/moderation.d.ts +0 -32
  183. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  184. package/dist/kit/blueprints/moderation.js +0 -140
  185. package/dist/kit/blueprints/npcs.d.ts +0 -78
  186. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  187. package/dist/kit/blueprints/npcs.js +0 -125
  188. package/dist/kit/blueprints/plots.d.ts +0 -63
  189. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  190. package/dist/kit/blueprints/plots.js +0 -151
  191. package/dist/kit/blueprints/progression.d.ts +0 -68
  192. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  193. package/dist/kit/blueprints/progression.js +0 -324
  194. package/dist/kit/blueprints/quests.d.ts +0 -72
  195. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  196. package/dist/kit/blueprints/quests.js +0 -285
  197. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  198. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  199. package/dist/kit/blueprints/worldsim.js +0 -468
  200. package/dist/kit/combat.d.ts +0 -141
  201. package/dist/kit/combat.d.ts.map +0 -1
  202. package/dist/kit/combat.js +0 -196
  203. package/dist/kit/decks.d.ts +0 -157
  204. package/dist/kit/decks.d.ts.map +0 -1
  205. package/dist/kit/decks.js +0 -186
  206. package/dist/kit/director.d.ts +0 -88
  207. package/dist/kit/director.d.ts.map +0 -1
  208. package/dist/kit/director.js +0 -86
  209. package/dist/kit/economy.d.ts +0 -289
  210. package/dist/kit/economy.d.ts.map +0 -1
  211. package/dist/kit/economy.js +0 -427
  212. package/dist/kit/engine.d.ts +0 -48
  213. package/dist/kit/engine.d.ts.map +0 -1
  214. package/dist/kit/engine.js +0 -113
  215. package/dist/kit/features.d.ts +0 -60
  216. package/dist/kit/features.d.ts.map +0 -1
  217. package/dist/kit/features.js +0 -65
  218. package/dist/kit/instances.d.ts +0 -52
  219. package/dist/kit/instances.d.ts.map +0 -1
  220. package/dist/kit/instances.js +0 -60
  221. package/dist/kit/inventory.d.ts +0 -129
  222. package/dist/kit/inventory.d.ts.map +0 -1
  223. package/dist/kit/inventory.js +0 -200
  224. package/dist/kit/leaderboards.d.ts +0 -86
  225. package/dist/kit/leaderboards.d.ts.map +0 -1
  226. package/dist/kit/leaderboards.js +0 -133
  227. package/dist/kit/liveops.d.ts +0 -112
  228. package/dist/kit/liveops.d.ts.map +0 -1
  229. package/dist/kit/liveops.js +0 -183
  230. package/dist/kit/loot.d.ts +0 -128
  231. package/dist/kit/loot.d.ts.map +0 -1
  232. package/dist/kit/loot.js +0 -160
  233. package/dist/kit/matches.d.ts +0 -301
  234. package/dist/kit/matches.d.ts.map +0 -1
  235. package/dist/kit/matches.js +0 -458
  236. package/dist/kit/matchmaking.d.ts +0 -57
  237. package/dist/kit/matchmaking.d.ts.map +0 -1
  238. package/dist/kit/matchmaking.js +0 -59
  239. package/dist/kit/minigames.d.ts +0 -30
  240. package/dist/kit/minigames.d.ts.map +0 -1
  241. package/dist/kit/minigames.js +0 -38
  242. package/dist/kit/mobs.d.ts +0 -90
  243. package/dist/kit/mobs.d.ts.map +0 -1
  244. package/dist/kit/mobs.js +0 -98
  245. package/dist/kit/moderation.d.ts +0 -73
  246. package/dist/kit/moderation.d.ts.map +0 -1
  247. package/dist/kit/moderation.js +0 -103
  248. package/dist/kit/movement.d.ts +0 -78
  249. package/dist/kit/movement.d.ts.map +0 -1
  250. package/dist/kit/movement.js +0 -103
  251. package/dist/kit/notifications.d.ts +0 -45
  252. package/dist/kit/notifications.d.ts.map +0 -1
  253. package/dist/kit/notifications.js +0 -67
  254. package/dist/kit/npcs.d.ts +0 -226
  255. package/dist/kit/npcs.d.ts.map +0 -1
  256. package/dist/kit/npcs.js +0 -141
  257. package/dist/kit/objects.d.ts +0 -116
  258. package/dist/kit/objects.d.ts.map +0 -1
  259. package/dist/kit/objects.js +0 -119
  260. package/dist/kit/pets.d.ts +0 -85
  261. package/dist/kit/pets.d.ts.map +0 -1
  262. package/dist/kit/pets.js +0 -96
  263. package/dist/kit/plots.d.ts +0 -85
  264. package/dist/kit/plots.d.ts.map +0 -1
  265. package/dist/kit/plots.js +0 -113
  266. package/dist/kit/progression.d.ts +0 -181
  267. package/dist/kit/progression.d.ts.map +0 -1
  268. package/dist/kit/progression.js +0 -265
  269. package/dist/kit/quests.d.ts +0 -171
  270. package/dist/kit/quests.d.ts.map +0 -1
  271. package/dist/kit/quests.js +0 -237
  272. package/dist/kit/racing.d.ts +0 -85
  273. package/dist/kit/racing.d.ts.map +0 -1
  274. package/dist/kit/racing.js +0 -99
  275. package/dist/kit/shared.d.ts +0 -73
  276. package/dist/kit/shared.d.ts.map +0 -1
  277. package/dist/kit/shared.js +0 -101
  278. package/dist/kit/telemetry.d.ts +0 -66
  279. package/dist/kit/telemetry.d.ts.map +0 -1
  280. package/dist/kit/telemetry.js +0 -133
  281. package/dist/kit/territory.d.ts +0 -97
  282. package/dist/kit/territory.d.ts.map +0 -1
  283. package/dist/kit/territory.js +0 -114
  284. package/dist/kit/worldsim.d.ts +0 -263
  285. package/dist/kit/worldsim.d.ts.map +0 -1
  286. package/dist/kit/worldsim.js +0 -268
  287. package/dist/stores/model.d.ts +0 -81
  288. package/dist/stores/model.d.ts.map +0 -1
  289. package/dist/stores/model.js +0 -163
package/dist/kit/loot.js DELETED
@@ -1,160 +0,0 @@
1
- import { lootNames, lootRollFn } from './blueprints/index.js';
2
- import { kitContainerProperties, kitInvoke, } from './shared.js';
3
- /**
4
- * Runtime helpers for the {@link lootBlueprint} conventions: create durable
5
- * `LootRoll` containers, roll them (trusted — app admins by default, or the
6
- * blueprint's event-drop automations), and claim results atomically into an
7
- * item stack. The weighted selection runs entirely server-side from a stored
8
- * seed, so clients can neither pick their loot nor claim it twice.
9
- *
10
- * Obtained via `client.kit(appId).loot`.
11
- */
12
- export class LootKit {
13
- constructor(appId, gameModel, options = {}, engines) {
14
- this.appId = appId;
15
- this.gameModel = gameModel;
16
- this.engines = engines;
17
- this.typePrefix = options.typePrefix ?? '';
18
- this.names = lootNames(this.typePrefix);
19
- this.engineModuleName = options.engineModuleName ?? 'loot-engine';
20
- }
21
- /**
22
- * Is a big-table loot module deployed + enabled (cached per session)?
23
- * When true, {@link enginePull} routes rolls through server-held RNG with
24
- * pity timers + audit trails; the blueprint's weighted model rolls stay
25
- * for small tables (the coexistence policy — "the server picks the path").
26
- */
27
- engineAvailable() {
28
- if (!this.engines)
29
- return Promise.resolve(false);
30
- return this.engines.has(this.engineModuleName);
31
- }
32
- /** Pull from the module's table (pity-timer path); count caps at 10. */
33
- async enginePull(count = 1) {
34
- if (!this.engines)
35
- throw new Error('loot engine unavailable: compute domain not wired');
36
- const result = await this.engines.invoke(this.engineModuleName, 'pull', { count });
37
- if (!result.success)
38
- throw new Error(`loot.pull failed: ${result.reason ?? 'unknown'}`);
39
- return result.body;
40
- }
41
- /** Your pity counters + roll totals from the module. */
42
- async enginePity() {
43
- if (!this.engines)
44
- throw new Error('loot engine unavailable: compute domain not wired');
45
- const result = await this.engines.invoke(this.engineModuleName, 'pity', {});
46
- if (!result.success)
47
- throw new Error(`loot.pity failed: ${result.reason ?? 'unknown'}`);
48
- return result.body;
49
- }
50
- /** Your rolling audit trail from the module (dispute resolution). */
51
- async engineAudit() {
52
- if (!this.engines)
53
- throw new Error('loot engine unavailable: compute domain not wired');
54
- const result = await this.engines.invoke(this.engineModuleName, 'audit', {});
55
- if (!result.success)
56
- throw new Error(`loot.audit failed: ${result.reason ?? 'unknown'}`);
57
- return result.body;
58
- }
59
- /**
60
- * Create an unrolled `LootRoll` for a table, owned by `ownerUserId` (who
61
- * will claim it). Event-drop automations pick from the pool of unrolled
62
- * rolls — create a few ahead of time for tables wired to `drops`.
63
- */
64
- async createRoll(input) {
65
- return this.gameModel.createContainer({
66
- appId: this.appId,
67
- typeName: this.names.rollType,
68
- displayName: input.displayName ?? `Roll ${input.tableId}`,
69
- ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
70
- properties: [
71
- {
72
- key: 'owner_user_id',
73
- valueType: 'int',
74
- valueJson: String(input.ownerUserId),
75
- },
76
- {
77
- key: 'table_id',
78
- valueType: 'string',
79
- valueJson: JSON.stringify(input.tableId),
80
- },
81
- ],
82
- });
83
- }
84
- /**
85
- * Roll a table on an unrolled `LootRoll` — a **trusted** call (default
86
- * blueprint authority: app admins). Resolves with the rolled item id.
87
- *
88
- * @param tableId - The roll container's table (derives the function name);
89
- * read from the container when omitted.
90
- */
91
- async roll(rollId, tableId) {
92
- const table = tableId ?? (await this.state(rollId)).tableId;
93
- return kitInvoke(this.gameModel, {
94
- appId: String(this.appId),
95
- functionName: lootRollFn(table, this.typePrefix),
96
- selfContainerId: rollId,
97
- params: {},
98
- });
99
- }
100
- /**
101
- * Claim a rolled loot into a caller-owned stack of the rolled item. The
102
- * claimed flag and the grant commit atomically. Resolves with the granted
103
- * quantity.
104
- */
105
- async claim(rollId, toStackId) {
106
- return kitInvoke(this.gameModel, {
107
- appId: String(this.appId),
108
- functionName: this.names.claimFn,
109
- selfContainerId: rollId,
110
- params: { to_stack_id: toStackId },
111
- });
112
- }
113
- /** Read one roll's state. */
114
- async state(rollId) {
115
- const container = await this.gameModel.container({
116
- appId: this.appId,
117
- containerId: rollId,
118
- });
119
- return this.toRoll(container.containerId, container.displayName, container.ownerUserId != null ? String(container.ownerUserId) : null);
120
- }
121
- /**
122
- * List a player's rolls, optionally filtered to one table and/or to
123
- * unclaimed rolled loot (the "your drops" screen).
124
- */
125
- async rolls(ownerUserId, options = {}) {
126
- const containers = await this.gameModel.containers({
127
- appId: this.appId,
128
- typeName: this.names.rollType,
129
- });
130
- const mine = containers.filter((c) => c.ownerUserId != null && String(c.ownerUserId) === String(ownerUserId));
131
- const rolls = await Promise.all(mine.map((c) => this.toRoll(c.containerId, c.displayName, c.ownerUserId != null ? String(c.ownerUserId) : null)));
132
- return rolls.filter((r) => (options.tableId === undefined || r.tableId === options.tableId) &&
133
- (!options.unclaimedOnly || (!r.claimed && r.rolledItemId !== '')));
134
- }
135
- /**
136
- * Roll/claim audit history from the model event log (each roll records its
137
- * seed, item, and quantity as applied mutations).
138
- */
139
- async history(options = {}) {
140
- return this.gameModel.events({
141
- appId: this.appId,
142
- functionName: options.tableId !== undefined
143
- ? lootRollFn(options.tableId, this.typePrefix)
144
- : this.names.claimFn,
145
- ...(options.limit !== undefined ? { limit: options.limit } : {}),
146
- });
147
- }
148
- async toRoll(containerId, displayName, ownerUserId) {
149
- const props = await kitContainerProperties(this.gameModel, String(this.appId), containerId);
150
- return {
151
- containerId,
152
- displayName,
153
- ownerUserId,
154
- tableId: String(props.table_id ?? ''),
155
- rolledItemId: String(props.rolled_item_id ?? ''),
156
- rolledQty: Number(props.rolled_qty ?? 0),
157
- claimed: props.claimed === true,
158
- };
159
- }
160
- }
@@ -1,301 +0,0 @@
1
- import type { ChannelsAPI } from '../domains/channels.js';
2
- import type { EngineDetector } from './engine.js';
3
- import type { GameModelAPI } from '../domains/gameModel.js';
4
- import type { UdpAPI } from '../domains/udp.js';
5
- import type { Scalars } from '../generated/graphql.js';
6
- import { type KitInvokeResult } from './shared.js';
7
- /**
8
- * What {@link MatchesKit.finish} did about the backing session after a
9
- * successful `end_match`: `'ended'` (it ended it), `'already_ended'` (a
10
- * replayed finish; the session was already ended), `'forbidden'` (the caller
11
- * passed `end_match` -- creator or the app's elected host -- but is neither
12
- * the session host nor an app admin, so the session is still active; an app
13
- * admin can `gameModel.endSession` it).
14
- * Absent when `end_match` itself was refused (`success: false`).
15
- */
16
- export type KitMatchSessionEnd = 'ended' | 'already_ended' | 'forbidden';
17
- /** {@link MatchesKit.finish}'s result: the invoke result plus what happened to the session. */
18
- export type KitMatchFinishResult = KitInvokeResult<string> & {
19
- sessionEnd?: KitMatchSessionEnd;
20
- };
21
- /** Options for {@link MatchesKit}. Must match the deployed matches blueprint. */
22
- export interface MatchesKitOptions {
23
- /**
24
- * The compute module driving server-side match lifecycle when the app
25
- * runs an engine. Defaults to `'match-engine'`.
26
- */
27
- engineModuleName?: string;
28
- /** The `typePrefix` the matches blueprint was deployed with. */
29
- typePrefix?: string;
30
- /**
31
- * The 32-ASCII-char actor uuid used as the sender id on channel pings.
32
- * Defaults to a random uuid per kit instance.
33
- */
34
- actorUuid?: string;
35
- }
36
- /** A parsed view of one match. */
37
- export interface KitMatch {
38
- /** The session backing the match (participants + turn order). */
39
- sessionId: string;
40
- /** The MatchMeta container id (the `self` of the lifecycle functions). */
41
- metaId: string;
42
- displayName: string;
43
- creatorUserId: number;
44
- mode: string;
45
- state: string;
46
- round: number;
47
- maxPlayers: number;
48
- winnerUserId: number;
49
- /** The per-match notification channel (0 when none was wired). */
50
- channelId: string;
51
- /** Present when the blueprint was deployed with `turnTick`. */
52
- tickCount?: number;
53
- /**
54
- * The current turn's sequence number. Present only when the blueprint was
55
- * deployed with `turnTimer`, which is how the helpers detect that turns
56
- * carry a deadline.
57
- */
58
- turnSeq?: number;
59
- /** The highest turn sequence whose deadline elapsed. See {@link turnExpired}. */
60
- turnExpiredSeq?: number;
61
- }
62
- /**
63
- * Whether the match's current turn has run out of time — true once the
64
- * deadline for the open turn has fired. Always false for a match deployed
65
- * without `turnTimer`, and false for a deadline stranded by an earlier turn,
66
- * since those record a lower sequence than the one now open.
67
- */
68
- export declare function turnExpired(match: KitMatch): boolean;
69
- /** One row of the match standings. */
70
- export interface KitMatchScore {
71
- containerId: string;
72
- ownerUserId: string | null;
73
- points: number;
74
- }
75
- /**
76
- * Runtime helpers for the {@link matchesBlueprint} conventions: sessions ARE
77
- * the match primitive — `create` makes a session + a `MatchMeta` + a
78
- * per-match channel; turn order goes through the platform's session-turn
79
- * authority; lifecycle functions ping the channel post-commit and
80
- * {@link onMatchChanged} wraps the notify-to-pull loop (subscribe →
81
- * `"match_changed"` ping → re-pull state).
82
- *
83
- * Obtained via `client.kit(appId).matches`.
84
- */
85
- export declare class MatchesKit {
86
- private readonly appId;
87
- private readonly gameModel;
88
- private readonly channels;
89
- private readonly udp;
90
- private readonly engines?;
91
- private readonly names;
92
- private readonly actorUuid;
93
- private readonly engineModuleName;
94
- /**
95
- * This client's participant incarnation per session, remembered from
96
- * {@link create} (a creator starts at 1) and {@link join}, so {@link leave}
97
- * can send the value the server requires without the caller carrying it.
98
- */
99
- private readonly incarnations;
100
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, channels: ChannelsAPI | undefined, udp: UdpAPI | undefined, options?: MatchesKitOptions, engines?: EngineDetector | undefined);
101
- private requireChannels;
102
- private requireUdp;
103
- /**
104
- * Create a match: a session (the platform match primitive), a per-match
105
- * notification channel, and the session-scoped `MatchMeta`.
106
- *
107
- * @param input.creatorUserId - The calling player's user id (stored so the
108
- * creator may start/advance/end the match).
109
- * @param input.seedFromApp - Optional: container types whose app-scoped keyed
110
- * rows (a `gameModelSeed` with `bindingKey`) are stamped into the match's
111
- * session at creation, inside the same transaction, so the match starts
112
- * with its world rows present (chests, spawners, turrets). Same shape as
113
- * `CreateSessionInput.seedFromApp`: `{ typeNames, initialState? }`. At most
114
- * 2,000 rows; above that the create is refused and no session exists. Only
115
- * `'session'`-scoped types; the copies are the only rows the tier's
116
- * (opt-in) ended-session retention may drop.
117
- */
118
- create(input: {
119
- creatorUserId: Scalars['BigInt']['input'];
120
- mode?: string;
121
- maxPlayers?: number;
122
- displayName?: string;
123
- seedFromApp?: {
124
- typeNames: string[];
125
- initialState?: 'defaults' | 'app';
126
- };
127
- }): Promise<KitMatch>;
128
- /** List joinable matches (metas still in the lobby state). */
129
- open(): Promise<KitMatch[]>;
130
- /** Read one match by its MatchMeta container. */
131
- get(metaId: string): Promise<KitMatch>;
132
- /**
133
- * Join a match: session participation + the notification channel. A rejoin
134
- * (you are already in) returns your row with `incarnation + 1`. The
135
- * incarnation is remembered on this kit instance for {@link leave}.
136
- */
137
- join(match: KitMatch): Promise<{
138
- __typename?: "GmSessionParticipant";
139
- sessionId: string;
140
- userId: string;
141
- role: string;
142
- state: string;
143
- incarnation: number;
144
- actorUuid: string | null;
145
- joinedAt: string;
146
- leftAt: string | null;
147
- leftReason: string | null;
148
- }>;
149
- /**
150
- * Leave a match: session departure + the notification channel. The server
151
- * requires the incarnation {@link join} returned to *this* client, so a
152
- * superseded client can never remove the one that took over; pass it, or
153
- * let the kit use the one it remembered from `create` / `join` on this
154
- * instance. A kit session is `presence: 'none'`, so this and {@link finish}
155
- * are the roster's only exits.
156
- *
157
- * @throws {Error} when no incarnation is known for the match on this
158
- * instance and none was passed.
159
- * @throws {CrowdyGraphQLError} `SESSION_INCARNATION_STALE` (a newer client
160
- * of yours rejoined), `SESSION_NOT_PARTICIPANT`, `NOT_FOUND`.
161
- */
162
- leave(match: KitMatch, incarnation?: number): Promise<{
163
- __typename?: "GmSessionParticipant";
164
- sessionId: string;
165
- userId: string;
166
- role: string;
167
- state: string;
168
- incarnation: number;
169
- actorUuid: string | null;
170
- joinedAt: string;
171
- leftAt: string | null;
172
- leftReason: string | null;
173
- }>;
174
- /** Start the match (creator or host). Pings the match channel post-commit. */
175
- start(match: KitMatch): Promise<KitInvokeResult<string>>;
176
- /** Advance to the next round (creator or host). */
177
- advanceRound(match: KitMatch): Promise<KitInvokeResult<number>>;
178
- /** Whether it is `userId`'s session turn right now. */
179
- myTurn(match: KitMatch, userId: Scalars['BigInt']['input']): Promise<boolean>;
180
- /**
181
- * Pass the turn to the next player via the platform's session-turn
182
- * authority (current holder, host, or admin — enforced by the service),
183
- * then ping the match channel so everyone re-pulls.
184
- *
185
- * For a match deployed with `turnTimer`, this opens the incoming turn first
186
- * so it arrives with a deadline already running. Opening it before the
187
- * handover also means the outgoing holder is still the session's turn user,
188
- * which is what authorizes them to do it.
189
- */
190
- endTurn(match: KitMatch, nextUserId: Scalars['BigInt']['input']): Promise<{
191
- __typename?: "GmSession";
192
- sessionId: string;
193
- appId: string;
194
- name: string | null;
195
- status: string;
196
- createdByUserId: string | null;
197
- currentTurnUserId: string | null;
198
- metadataJson: string;
199
- admission: string;
200
- maxParticipants: number | null;
201
- participantCount: number;
202
- hostUserId: string | null;
203
- hostTerm: number;
204
- revision: string;
205
- endedAt: string | null;
206
- endReason: string | null;
207
- createdAt: string;
208
- presence: string;
209
- gridId: string | null;
210
- seededContainerCount: number | null;
211
- }>;
212
- /**
213
- * Open a turn and arm its deadline (`turnTimer` deployments only) — the
214
- * deadline replaces any still pending for this match. `endTurn` calls this
215
- * for you; call it directly to give the current player a fresh clock, e.g.
216
- * after granting extra time.
217
- */
218
- beginTurn(match: KitMatch): Promise<KitInvokeResult<number>>;
219
- /**
220
- * Cancel the pending turn deadline for this match, if any. Returns how many
221
- * timers were dropped. Ending a match already strands its deadline, so this
222
- * is only needed when you want turns to stop being timed while play
223
- * continues.
224
- */
225
- cancelTurnDeadline(match: KitMatch): Promise<number>;
226
- /** Find-or-create a player's session-scoped Score row. */
227
- ensureScore(match: KitMatch, ownerUserId: Scalars['BigInt']['input']): Promise<{
228
- __typename?: "GmContainer";
229
- containerId: string;
230
- appId: string;
231
- sessionId: string | null;
232
- typeName: string;
233
- displayName: string;
234
- description: string | null;
235
- ownerUserId: string | null;
236
- metadataJson: string;
237
- }>;
238
- /**
239
- * Add points to a Score row — trusted (host-refereed by default).
240
- * Resolves with the new points.
241
- */
242
- score(match: KitMatch, scoreId: string, points: number): Promise<KitInvokeResult<number>>;
243
- /** The match standings, highest points first (client-side sort). */
244
- standings(match: KitMatch): Promise<KitMatchScore[]>;
245
- /**
246
- * Finish the match and record the winner (creator or host). Also drops the
247
- * pending turn deadline on a `turnTimer` match — `end_match` already
248
- * strands it, so this just saves the pointless fire and channel ping.
249
- *
250
- * When `end_match` succeeds the backing session is ended too
251
- * (`gameModelEndSession`, reason `completed`): every participant is marked
252
- * left, admission closes, and the session's events become eligible for
253
- * retention. The game-authoritative step runs first, so the match is
254
- * decided whatever happens next; `sessionEnd` on the result says what
255
- * happened to the session ({@link KitMatchSessionEnd}): `'ended'`, or
256
- * `'already_ended'` for a replayed finish, or `'forbidden'` when the caller
257
- * passed `end_match` (creator or the app's elected host) but is not admitted
258
- * to the session end (session host or app admin only) -- the match is
259
- * finished, the session is not, and nothing is thrown. Any other refusal of
260
- * the session end propagates.
261
- */
262
- finish(match: KitMatch, winnerUserId: Scalars['BigInt']['input']): Promise<KitMatchFinishResult>;
263
- /**
264
- * Manually ping the match channel with `"match_changed"` (the lifecycle
265
- * functions do this automatically via their declared notifications; use
266
- * this after out-of-band changes such as `endTurn`).
267
- */
268
- notifyChanged(match: KitMatch): Promise<boolean>;
269
- /**
270
- * The notify-to-pull loop, wrapped: subscribe to the app's notifications,
271
- * and on every ping of THIS match's channel re-pull the match state and
272
- * hand it to `callback`. Returns the unsubscribe function.
273
- */
274
- onMatchChanged(match: KitMatch, callback: (match: KitMatch) => void): () => void;
275
- private toMatch;
276
- /**
277
- * Is a match compute engine deployed + enabled (cached per session)? When
278
- * true the engine owns transitions (ready checks, turn order + timeouts,
279
- * authoritative scoring); the blueprint's creator-driven functions remain
280
- * for model-only deployments.
281
- */
282
- engineAvailable(): Promise<boolean>;
283
- /**
284
- * Declare ready on an engine match (a MatchMeta container id). The match
285
- * starts server-side once every expected player is ready.
286
- */
287
- engineReady(matchId: string): Promise<Record<string, unknown>>;
288
- /** Submit your move (the engine validates the turn + resolves). */
289
- engineSubmitMove(matchId: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
290
- /** Forfeit an engine match. */
291
- engineForfeit(matchId: string): Promise<Record<string, unknown>>;
292
- /** The engine's live view: turn holder, timers, standings, summary. */
293
- engineStatus(matchId: string): Promise<Record<string, unknown>>;
294
- /**
295
- * Resolve a matchmaking proposal to the match the engine created for it
296
- * (poll after everyone accepts; see `kit.matchmaking`).
297
- */
298
- findByProposal(proposalId: string): Promise<string | null>;
299
- private engineInvoke;
300
- }
301
- //# sourceMappingURL=matches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../../src/kit/matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB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