@crowdedkingdoms/crowdyjs 17.14.0-dev.1 → 18.0.0-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 (271) hide show
  1. package/MIGRATION.md +92 -1
  2. package/README.md +93 -162
  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/host.d.ts +3 -3
  33. package/dist/domains/host.js +3 -3
  34. package/dist/domains/marketplace.d.ts +9 -70
  35. package/dist/domains/marketplace.d.ts.map +1 -1
  36. package/dist/domains/marketplace.js +9 -120
  37. package/dist/domains/playerWallet.d.ts +6 -12
  38. package/dist/domains/playerWallet.d.ts.map +1 -1
  39. package/dist/domains/playerWallet.js +6 -21
  40. package/dist/errors.d.ts +7 -13
  41. package/dist/errors.d.ts.map +1 -1
  42. package/dist/errors.js +6 -10
  43. package/dist/generated/graphql.d.ts +141 -7083
  44. package/dist/generated/graphql.d.ts.map +1 -1
  45. package/dist/generated/graphql.js +5 -313
  46. package/dist/grid-mods/exec-client-halves.d.ts +19 -3
  47. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -1
  48. package/dist/grid-mods/exec-client-halves.js +17 -2
  49. package/dist/grid-mods/grid-host-calls.d.ts +29 -17
  50. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  51. package/dist/grid-mods/grid-host-calls.js +40 -46
  52. package/dist/grid-mods/mod-runtime.d.ts +18 -11
  53. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  54. package/dist/grid-mods/mod-runtime.js +4 -2
  55. package/dist/grid-scope.d.ts +0 -189
  56. package/dist/grid-scope.d.ts.map +1 -1
  57. package/dist/grid-scope.js +0 -70
  58. package/dist/index.d.ts +11 -17
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +10 -16
  61. package/dist/kit/actions.d.ts +5 -9
  62. package/dist/kit/actions.d.ts.map +1 -1
  63. package/dist/kit/actions.js +5 -9
  64. package/dist/kit/index.d.ts +2 -33
  65. package/dist/kit/index.d.ts.map +1 -1
  66. package/dist/kit/index.js +1 -32
  67. package/dist/kit/kit.d.ts +8 -208
  68. package/dist/kit/kit.d.ts.map +1 -1
  69. package/dist/kit/kit.js +5 -163
  70. package/dist/kit/social.d.ts +1 -3
  71. package/dist/kit/social.d.ts.map +1 -1
  72. package/dist/kit/social.js +1 -3
  73. package/dist/kit/wire.d.ts +16 -5
  74. package/dist/kit/wire.d.ts.map +1 -1
  75. package/dist/kit/wire.js +19 -5
  76. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  77. package/dist/live-coding/assets/manifest.json +1 -1
  78. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  79. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  80. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  81. package/dist/live-coding/rust-analysis.js +30 -34
  82. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  83. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  84. package/dist/player-runtime/client-host-calls.js +28 -0
  85. package/dist/player-runtime/glue-runtime.d.ts +24 -20
  86. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  87. package/dist/player-runtime/glue-runtime.js +26 -55
  88. package/dist/player-runtime/glue-sab.d.ts +2 -2
  89. package/dist/player-runtime/glue-sab.js +2 -2
  90. package/dist/player-runtime/player-code-broker.d.ts +70 -43
  91. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  92. package/dist/player-runtime/player-code-broker.js +159 -64
  93. package/dist/player-runtime/player-glue-worker.d.ts +8 -9
  94. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  95. package/dist/player-runtime/player-glue-worker.js +26 -11
  96. package/dist/stores/inbox.d.ts +1 -1
  97. package/dist/stores/inbox.d.ts.map +1 -1
  98. package/dist/stores/index.d.ts +0 -11
  99. package/dist/stores/index.d.ts.map +1 -1
  100. package/dist/stores/index.js +0 -4
  101. package/dist/stores/session.d.ts +0 -2
  102. package/dist/stores/session.d.ts.map +1 -1
  103. package/package.json +1 -1
  104. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  105. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  106. package/dist/crowdy-studio/model-lint-log.js +0 -93
  107. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  108. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  109. package/dist/crowdy-studio/model-lint.js +0 -45
  110. package/dist/domains/compute.d.ts +0 -208
  111. package/dist/domains/compute.d.ts.map +0 -1
  112. package/dist/domains/compute.js +0 -274
  113. package/dist/domains/controlPlane.d.ts +0 -38
  114. package/dist/domains/controlPlane.d.ts.map +0 -1
  115. package/dist/domains/controlPlane.js +0 -43
  116. package/dist/domains/gameModel.d.ts +0 -1174
  117. package/dist/domains/gameModel.d.ts.map +0 -1
  118. package/dist/domains/gameModel.js +0 -1333
  119. package/dist/domains/playerCompute.d.ts +0 -91
  120. package/dist/domains/playerCompute.d.ts.map +0 -1
  121. package/dist/domains/playerCompute.js +0 -136
  122. package/dist/domains/playerModel.d.ts +0 -20
  123. package/dist/domains/playerModel.d.ts.map +0 -1
  124. package/dist/domains/playerModel.js +0 -54
  125. package/dist/kit/abilities.d.ts +0 -66
  126. package/dist/kit/abilities.d.ts.map +0 -1
  127. package/dist/kit/abilities.js +0 -71
  128. package/dist/kit/blueprints/combat.d.ts +0 -81
  129. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  130. package/dist/kit/blueprints/combat.js +0 -357
  131. package/dist/kit/blueprints/core.d.ts +0 -222
  132. package/dist/kit/blueprints/core.d.ts.map +0 -1
  133. package/dist/kit/blueprints/core.js +0 -185
  134. package/dist/kit/blueprints/decks.d.ts +0 -50
  135. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  136. package/dist/kit/blueprints/decks.js +0 -163
  137. package/dist/kit/blueprints/economy.d.ts +0 -88
  138. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  139. package/dist/kit/blueprints/economy.js +0 -533
  140. package/dist/kit/blueprints/guild.d.ts +0 -51
  141. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  142. package/dist/kit/blueprints/guild.js +0 -50
  143. package/dist/kit/blueprints/index.d.ts +0 -23
  144. package/dist/kit/blueprints/index.d.ts.map +0 -1
  145. package/dist/kit/blueprints/index.js +0 -22
  146. package/dist/kit/blueprints/inventory.d.ts +0 -84
  147. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  148. package/dist/kit/blueprints/inventory.js +0 -257
  149. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  150. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  151. package/dist/kit/blueprints/leaderboards.js +0 -126
  152. package/dist/kit/blueprints/liveops.d.ts +0 -42
  153. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  154. package/dist/kit/blueprints/liveops.js +0 -170
  155. package/dist/kit/blueprints/locks.d.ts +0 -82
  156. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  157. package/dist/kit/blueprints/locks.js +0 -155
  158. package/dist/kit/blueprints/loot.d.ts +0 -90
  159. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  160. package/dist/kit/blueprints/loot.js +0 -229
  161. package/dist/kit/blueprints/matches.d.ts +0 -84
  162. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  163. package/dist/kit/blueprints/matches.js +0 -349
  164. package/dist/kit/blueprints/moderation.d.ts +0 -32
  165. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  166. package/dist/kit/blueprints/moderation.js +0 -140
  167. package/dist/kit/blueprints/npcs.d.ts +0 -78
  168. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  169. package/dist/kit/blueprints/npcs.js +0 -125
  170. package/dist/kit/blueprints/plots.d.ts +0 -63
  171. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  172. package/dist/kit/blueprints/plots.js +0 -151
  173. package/dist/kit/blueprints/progression.d.ts +0 -68
  174. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  175. package/dist/kit/blueprints/progression.js +0 -324
  176. package/dist/kit/blueprints/quests.d.ts +0 -72
  177. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  178. package/dist/kit/blueprints/quests.js +0 -285
  179. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  180. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  181. package/dist/kit/blueprints/worldsim.js +0 -468
  182. package/dist/kit/combat.d.ts +0 -141
  183. package/dist/kit/combat.d.ts.map +0 -1
  184. package/dist/kit/combat.js +0 -196
  185. package/dist/kit/decks.d.ts +0 -157
  186. package/dist/kit/decks.d.ts.map +0 -1
  187. package/dist/kit/decks.js +0 -186
  188. package/dist/kit/director.d.ts +0 -88
  189. package/dist/kit/director.d.ts.map +0 -1
  190. package/dist/kit/director.js +0 -86
  191. package/dist/kit/economy.d.ts +0 -289
  192. package/dist/kit/economy.d.ts.map +0 -1
  193. package/dist/kit/economy.js +0 -427
  194. package/dist/kit/engine.d.ts +0 -48
  195. package/dist/kit/engine.d.ts.map +0 -1
  196. package/dist/kit/engine.js +0 -113
  197. package/dist/kit/features.d.ts +0 -60
  198. package/dist/kit/features.d.ts.map +0 -1
  199. package/dist/kit/features.js +0 -65
  200. package/dist/kit/instances.d.ts +0 -52
  201. package/dist/kit/instances.d.ts.map +0 -1
  202. package/dist/kit/instances.js +0 -60
  203. package/dist/kit/inventory.d.ts +0 -129
  204. package/dist/kit/inventory.d.ts.map +0 -1
  205. package/dist/kit/inventory.js +0 -200
  206. package/dist/kit/leaderboards.d.ts +0 -86
  207. package/dist/kit/leaderboards.d.ts.map +0 -1
  208. package/dist/kit/leaderboards.js +0 -133
  209. package/dist/kit/liveops.d.ts +0 -112
  210. package/dist/kit/liveops.d.ts.map +0 -1
  211. package/dist/kit/liveops.js +0 -183
  212. package/dist/kit/loot.d.ts +0 -128
  213. package/dist/kit/loot.d.ts.map +0 -1
  214. package/dist/kit/loot.js +0 -160
  215. package/dist/kit/matches.d.ts +0 -301
  216. package/dist/kit/matches.d.ts.map +0 -1
  217. package/dist/kit/matches.js +0 -458
  218. package/dist/kit/matchmaking.d.ts +0 -57
  219. package/dist/kit/matchmaking.d.ts.map +0 -1
  220. package/dist/kit/matchmaking.js +0 -59
  221. package/dist/kit/minigames.d.ts +0 -30
  222. package/dist/kit/minigames.d.ts.map +0 -1
  223. package/dist/kit/minigames.js +0 -38
  224. package/dist/kit/mobs.d.ts +0 -90
  225. package/dist/kit/mobs.d.ts.map +0 -1
  226. package/dist/kit/mobs.js +0 -98
  227. package/dist/kit/moderation.d.ts +0 -73
  228. package/dist/kit/moderation.d.ts.map +0 -1
  229. package/dist/kit/moderation.js +0 -103
  230. package/dist/kit/movement.d.ts +0 -78
  231. package/dist/kit/movement.d.ts.map +0 -1
  232. package/dist/kit/movement.js +0 -103
  233. package/dist/kit/notifications.d.ts +0 -45
  234. package/dist/kit/notifications.d.ts.map +0 -1
  235. package/dist/kit/notifications.js +0 -67
  236. package/dist/kit/npcs.d.ts +0 -226
  237. package/dist/kit/npcs.d.ts.map +0 -1
  238. package/dist/kit/npcs.js +0 -141
  239. package/dist/kit/objects.d.ts +0 -116
  240. package/dist/kit/objects.d.ts.map +0 -1
  241. package/dist/kit/objects.js +0 -119
  242. package/dist/kit/pets.d.ts +0 -85
  243. package/dist/kit/pets.d.ts.map +0 -1
  244. package/dist/kit/pets.js +0 -96
  245. package/dist/kit/plots.d.ts +0 -85
  246. package/dist/kit/plots.d.ts.map +0 -1
  247. package/dist/kit/plots.js +0 -113
  248. package/dist/kit/progression.d.ts +0 -181
  249. package/dist/kit/progression.d.ts.map +0 -1
  250. package/dist/kit/progression.js +0 -265
  251. package/dist/kit/quests.d.ts +0 -171
  252. package/dist/kit/quests.d.ts.map +0 -1
  253. package/dist/kit/quests.js +0 -237
  254. package/dist/kit/racing.d.ts +0 -85
  255. package/dist/kit/racing.d.ts.map +0 -1
  256. package/dist/kit/racing.js +0 -99
  257. package/dist/kit/shared.d.ts +0 -73
  258. package/dist/kit/shared.d.ts.map +0 -1
  259. package/dist/kit/shared.js +0 -101
  260. package/dist/kit/telemetry.d.ts +0 -66
  261. package/dist/kit/telemetry.d.ts.map +0 -1
  262. package/dist/kit/telemetry.js +0 -133
  263. package/dist/kit/territory.d.ts +0 -97
  264. package/dist/kit/territory.d.ts.map +0 -1
  265. package/dist/kit/territory.js +0 -114
  266. package/dist/kit/worldsim.d.ts +0 -263
  267. package/dist/kit/worldsim.d.ts.map +0 -1
  268. package/dist/kit/worldsim.js +0 -268
  269. package/dist/stores/model.d.ts +0 -81
  270. package/dist/stores/model.d.ts.map +0 -1
  271. package/dist/stores/model.js +0 -163
@@ -1,185 +0,0 @@
1
- /** Serialize a {@link KitInvokePolicy} tree to the wire `invokePolicyJson`. */
2
- export function kitPolicyJson(policy) {
3
- return JSON.stringify(policy);
4
- }
5
- /** Convert `PascalCase`/`camelCase` to `snake_case` for derived names. */
6
- export function toSnakeCase(name) {
7
- return name
8
- .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
9
- .replace(/[\s-]+/g, '_')
10
- .toLowerCase();
11
- }
12
- /**
13
- * Merge blueprints into a single `gameModelSeed` payload plus the automation
14
- * upserts, rejecting duplicate type, property, function, or automation names
15
- * across blueprints (a duplicate almost always means two blueprints need
16
- * distinct prefixes/type names).
17
- */
18
- export function mergeBlueprints(appId, blueprints, options = {}) {
19
- const containerTypes = [];
20
- const propertyDefinitions = [];
21
- const functions = [];
22
- const containers = [];
23
- const edges = [];
24
- const automations = [];
25
- const automationTriggers = [];
26
- const seenTypes = new Map();
27
- const seenProps = new Map();
28
- const seenFunctions = new Map();
29
- const seenAutomations = new Map();
30
- const seenTempIds = new Map();
31
- const claim = (seen, key, blueprintName, kind) => {
32
- const existing = seen.get(key);
33
- if (existing !== undefined) {
34
- throw new Error(`Blueprint '${blueprintName}' redefines ${kind} '${key}' already defined by blueprint '${existing}'`);
35
- }
36
- seen.set(key, blueprintName);
37
- };
38
- for (const blueprint of blueprints) {
39
- for (const type of blueprint.containerTypes ?? []) {
40
- claim(seenTypes, type.typeName, blueprint.name, 'container type');
41
- containerTypes.push(type);
42
- }
43
- for (const prop of blueprint.propertyDefinitions ?? []) {
44
- claim(seenProps, `${prop.containerTypeName}.${prop.key}`, blueprint.name, 'property');
45
- propertyDefinitions.push(prop);
46
- }
47
- for (const fn of blueprint.functions ?? []) {
48
- claim(seenFunctions, fn.name, blueprint.name, 'function');
49
- functions.push(fn);
50
- }
51
- for (const container of blueprint.containers ?? []) {
52
- claim(seenTempIds, container.tempId, blueprint.name, 'container tempId');
53
- containers.push(container);
54
- }
55
- edges.push(...(blueprint.edges ?? []));
56
- for (const automation of blueprint.automations ?? []) {
57
- claim(seenAutomations, automation.name, blueprint.name, 'automation');
58
- automations.push({ ...automation, appId });
59
- }
60
- for (const trigger of blueprint.automationTriggers ?? []) {
61
- automationTriggers.push({ ...trigger, appId });
62
- }
63
- }
64
- const seedInput = {
65
- appId,
66
- ...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
67
- ...(containerTypes.length ? { containerTypes } : {}),
68
- ...(propertyDefinitions.length ? { propertyDefinitions } : {}),
69
- ...(functions.length ? { functions } : {}),
70
- ...(containers.length ? { containers } : {}),
71
- ...(edges.length ? { edges } : {}),
72
- };
73
- return { seedInput, automations, automationTriggers };
74
- }
75
- /**
76
- * Concatenate several blueprints into ONE composite blueprint (a plain
77
- * client-side merge of the definition arrays — no collision checks; those
78
- * happen in {@link mergeBlueprints} at deploy). Used by composite builders
79
- * such as `guildBlueprint` that bundle other builders' output under a single
80
- * name.
81
- */
82
- export function composeBlueprints(name, blueprints) {
83
- const out = { name };
84
- for (const bp of blueprints) {
85
- if (bp.containerTypes?.length) {
86
- out.containerTypes = [...(out.containerTypes ?? []), ...bp.containerTypes];
87
- }
88
- if (bp.propertyDefinitions?.length) {
89
- out.propertyDefinitions = [
90
- ...(out.propertyDefinitions ?? []),
91
- ...bp.propertyDefinitions,
92
- ];
93
- }
94
- if (bp.functions?.length) {
95
- out.functions = [...(out.functions ?? []), ...bp.functions];
96
- }
97
- if (bp.containers?.length) {
98
- out.containers = [...(out.containers ?? []), ...bp.containers];
99
- }
100
- if (bp.edges?.length) {
101
- out.edges = [...(out.edges ?? []), ...bp.edges];
102
- }
103
- if (bp.automations?.length) {
104
- out.automations = [...(out.automations ?? []), ...bp.automations];
105
- }
106
- if (bp.automationTriggers?.length) {
107
- out.automationTriggers = [
108
- ...(out.automationTriggers ?? []),
109
- ...bp.automationTriggers,
110
- ];
111
- }
112
- }
113
- return out;
114
- }
115
- /**
116
- * The function-level fields a {@link KitTrustedAuthority} compiles to.
117
- * `extraCondition` (when given) is AND'ed into the policy.
118
- */
119
- export function trustedAuthorityFields(authority, extraCondition) {
120
- const rule = authority === 'server'
121
- ? { type: 'allow' }
122
- : authority === 'host'
123
- ? { type: 'is_host' }
124
- : authority === 'automation'
125
- ? { type: 'is_automation' }
126
- : authority === 'owner'
127
- ? { type: 'owner_of_self' }
128
- : authority.custom;
129
- const policy = extraCondition
130
- ? { type: 'and', rules: [rule, { type: 'condition', expression: extraCondition }] }
131
- : rule;
132
- return {
133
- invokePolicyJson: kitPolicyJson(policy),
134
- ...(authority === 'server' ? { invokeScope: 'server' } : {}),
135
- ...(authority === 'automation' ? { autonomousInvocable: true } : {}),
136
- };
137
- }
138
- /**
139
- * AND extra policy rules into a base policy (skipping empties) — the
140
- * composition point for `policyExtra` options such as
141
- * `plotBlueprint({ buyPolicyExtra: featureGate('land_owner') })`.
142
- */
143
- export function andPolicies(base, ...extra) {
144
- const extras = extra.filter((r) => r !== undefined);
145
- if (extras.length === 0)
146
- return base;
147
- return { type: 'and', rules: [base, ...extras] };
148
- }
149
- /**
150
- * A `tier_feature` policy leaf: the caller's access tier must hold `feature`
151
- * (defined via `kit.features.define` and granted with
152
- * `kit.features.grantToTier`). Pass it to any builder's `*policyExtra`
153
- * option to monetization-gate that function.
154
- */
155
- export function featureGate(feature) {
156
- return { type: 'tier_feature', feature };
157
- }
158
- /**
159
- * Expression fragment asserting that `ownerExpr` (an `owner_user_id`-style
160
- * property read) equals a user-id expression (usually the injected
161
- * `$caller_user_id` / `$self_owner_id` system params), honoring
162
- * {@link KitOwnerIdKind}.
163
- */
164
- export function ownerEquals(ownerExpr, userExpr, kind = 'int') {
165
- return kind === 'string'
166
- ? `${ownerExpr} == to_string(${userExpr})`
167
- : `${ownerExpr} == ${userExpr}`;
168
- }
169
- /**
170
- * Expression fragment asserting that `ownerExpr` (an `owner_user_id`-style
171
- * property read) equals the calling user, honoring {@link KitOwnerIdKind}.
172
- */
173
- export function ownerEqualsCaller(ownerExpr, kind = 'int') {
174
- return ownerEquals(ownerExpr, '$caller_user_id', kind);
175
- }
176
- /** The `SeedPropertyDefInput` for a kit-standard owner mirror property. */
177
- export function ownerMirrorProperty(containerTypeName, kind = 'int') {
178
- return {
179
- containerTypeName,
180
- key: 'owner_user_id',
181
- valueType: kind,
182
- defaultValueJson: kind === 'string' ? '""' : '0',
183
- description: "Mirror of the container owner's user id (kit convention: expressions cannot read container ownership).",
184
- };
185
- }
@@ -1,50 +0,0 @@
1
- import { type KitBlueprint, type KitOwnerIdKind } from './core.js';
2
- /** Options for {@link decksBlueprint}. */
3
- export interface DecksBlueprintOptions {
4
- /** Prefix for the type/function names. Defaults to none. */
5
- typePrefix?: string;
6
- /**
7
- * Turn-based mode: adds `is_current_turn` to draw/play/discard, so only
8
- * the player whose session turn it is may act. Defaults to false.
9
- */
10
- turnBased?: boolean;
11
- /**
12
- * Fan-out cap of the manual shuffle automation (raise it above your
13
- * largest deck size). Defaults to 200.
14
- */
15
- shuffleMaxTargets?: number;
16
- /** Owner-mirror typing (see the kit convention). Defaults to `'int'`. */
17
- ownerIdKind?: KitOwnerIdKind;
18
- }
19
- /** Names derived by {@link decksBlueprint} for a given prefix. */
20
- export interface DecksNames {
21
- cardDefType: string;
22
- cardType: string;
23
- drawFn: string;
24
- playFn: string;
25
- discardFn: string;
26
- assignPositionFn: string;
27
- shuffleAutomation: string;
28
- }
29
- /** Compute the type/function names a decks blueprint (and its runtime helper) uses. */
30
- export declare function decksNames(typePrefix?: string): DecksNames;
31
- /**
32
- * Blueprint for **cards & hidden information**: an admin `CardDef` catalog
33
- * and session-scoped `CardInstance`s whose `card_id` carries
34
- * **`visibility: "owner"`** — the two-property hidden-info trick: only the
35
- * owner's reads include `card_id`, while the public `revealed_card_id` stays
36
- * empty until the card is played/discarded (the play function copies it in
37
- * the same transaction). Opponents can see a card EXISTS in your hand, not
38
- * what it is — enforced by read filtering, not client discipline.
39
- *
40
- * Shuffling is honest about the platform: expressions can't index arrays, so
41
- * decks are ordered by a `position` int dealt by `assign_position`
42
- * (`rand_int(0, 1000000)` per card) via a **manual, type-fan-out
43
- * automation** — `kit.decks.shuffle()` runs it (admin), and drawing takes
44
- * the owner's lowest-position deck card ("top of deck"; the runtime picks
45
- * it, the server enforces the zone transition and ownership).
46
- *
47
- * Runtime counterpart: `client.kit(appId).decks`.
48
- */
49
- export declare function decksBlueprint(options?: DecksBlueprintOptions): KitBlueprint;
50
- //# sourceMappingURL=decks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decks.d.ts","sourceRoot":"","sources":["../../../src/kit/blueprints/decks.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAEnB,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,UAAU,SAAK,GAAG,UAAU,CAWtD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,YAAY,CAoJhF"}
@@ -1,163 +0,0 @@
1
- import { kitPolicyJson, ownerMirrorProperty, toSnakeCase, } from './core.js';
2
- /** Compute the type/function names a decks blueprint (and its runtime helper) uses. */
3
- export function decksNames(typePrefix = '') {
4
- const fnPrefix = typePrefix ? `${toSnakeCase(typePrefix)}_` : '';
5
- return {
6
- cardDefType: `${typePrefix}CardDef`,
7
- cardType: `${typePrefix}CardInstance`,
8
- drawFn: `${fnPrefix}draw_card`,
9
- playFn: `${fnPrefix}play_card`,
10
- discardFn: `${fnPrefix}discard_card`,
11
- assignPositionFn: `${fnPrefix}assign_position`,
12
- shuffleAutomation: `${fnPrefix.replace(/_/g, '-')}deck-shuffle`,
13
- };
14
- }
15
- /**
16
- * Blueprint for **cards & hidden information**: an admin `CardDef` catalog
17
- * and session-scoped `CardInstance`s whose `card_id` carries
18
- * **`visibility: "owner"`** — the two-property hidden-info trick: only the
19
- * owner's reads include `card_id`, while the public `revealed_card_id` stays
20
- * empty until the card is played/discarded (the play function copies it in
21
- * the same transaction). Opponents can see a card EXISTS in your hand, not
22
- * what it is — enforced by read filtering, not client discipline.
23
- *
24
- * Shuffling is honest about the platform: expressions can't index arrays, so
25
- * decks are ordered by a `position` int dealt by `assign_position`
26
- * (`rand_int(0, 1000000)` per card) via a **manual, type-fan-out
27
- * automation** — `kit.decks.shuffle()` runs it (admin), and drawing takes
28
- * the owner's lowest-position deck card ("top of deck"; the runtime picks
29
- * it, the server enforces the zone transition and ownership).
30
- *
31
- * Runtime counterpart: `client.kit(appId).decks`.
32
- */
33
- export function decksBlueprint(options = {}) {
34
- const { typePrefix = '', turnBased = false, shuffleMaxTargets = 200, ownerIdKind: kind = 'int', } = options;
35
- const names = decksNames(typePrefix);
36
- const playerPolicy = (condition) => {
37
- const rules = [
38
- { type: 'owner_of_self' },
39
- ...(turnBased ? [{ type: 'is_current_turn' }] : []),
40
- { type: 'condition', expression: condition },
41
- ];
42
- return kitPolicyJson({ type: 'and', rules });
43
- };
44
- const propertyDefinitions = [
45
- {
46
- containerTypeName: names.cardDefType,
47
- key: 'card_id',
48
- valueType: 'string',
49
- description: 'Stable card identifier (rules data lives on the def).',
50
- },
51
- ownerMirrorProperty(names.cardType, kind),
52
- {
53
- containerTypeName: names.cardType,
54
- key: 'card_id',
55
- valueType: 'string',
56
- defaultValueJson: '""',
57
- visibility: 'owner',
58
- description: "WHICH card this is — owner-visible only (the hidden-information half of the two-property trick); opponents' reads omit it.",
59
- },
60
- {
61
- containerTypeName: names.cardType,
62
- key: 'revealed_card_id',
63
- valueType: 'string',
64
- defaultValueJson: '""',
65
- description: 'The public half: empty while the card hides in deck/hand, copied from card_id when played or discarded.',
66
- },
67
- {
68
- containerTypeName: names.cardType,
69
- key: 'zone',
70
- valueType: 'string',
71
- defaultValueJson: '"deck"',
72
- description: "Card zone: 'deck' | 'hand' | 'board' | 'discard'.",
73
- },
74
- {
75
- containerTypeName: names.cardType,
76
- key: 'position',
77
- valueType: 'int',
78
- defaultValueJson: '0',
79
- description: 'Deck order (lowest = top), dealt by the shuffle automation via rand_int.',
80
- },
81
- ];
82
- const functions = [
83
- {
84
- name: names.drawFn,
85
- containerTypeName: names.cardType,
86
- returnType: 'string',
87
- mutations: [{ target: 'self', property: 'zone', expression: '"hand"' }],
88
- returnExpression: 'self.zone',
89
- invokePolicyJson: playerPolicy('self.zone == "deck"'),
90
- description: 'Draw a card you own from your deck into your hand (the runtime picks the lowest-position deck card — "top of deck"); card_id stays owner-visible.',
91
- },
92
- {
93
- name: names.playFn,
94
- containerTypeName: names.cardType,
95
- returnType: 'string',
96
- mutations: [
97
- { target: 'self', property: 'zone', expression: '"board"' },
98
- { target: 'self', property: 'revealed_card_id', expression: 'self.card_id' },
99
- ],
100
- returnExpression: 'self.revealed_card_id',
101
- invokePolicyJson: playerPolicy('self.zone == "hand"'),
102
- description: 'Play a card from your hand: the zone flip AND the public reveal (revealed_card_id = card_id) commit together.',
103
- },
104
- {
105
- name: names.discardFn,
106
- containerTypeName: names.cardType,
107
- returnType: 'string',
108
- mutations: [
109
- { target: 'self', property: 'zone', expression: '"discard"' },
110
- { target: 'self', property: 'revealed_card_id', expression: 'self.card_id' },
111
- ],
112
- returnExpression: 'self.revealed_card_id',
113
- invokePolicyJson: playerPolicy('self.zone == "hand" || self.zone == "board"'),
114
- description: 'Discard a card face-up (discard piles are public information).',
115
- },
116
- {
117
- name: names.assignPositionFn,
118
- containerTypeName: names.cardType,
119
- returnType: 'int',
120
- mutations: [
121
- { target: 'self', property: 'position', expression: 'rand_int(0, 1000000)' },
122
- ],
123
- returnExpression: 'self.position',
124
- invokePolicyJson: kitPolicyJson({ type: 'is_automation' }),
125
- autonomousInvocable: true,
126
- description: 'Shuffle step (automation-only): deals this card a random deck position — the supported server-side shuffle pattern (expressions cannot permute arrays).',
127
- },
128
- ];
129
- const automations = [
130
- {
131
- name: names.shuffleAutomation,
132
- functionName: names.assignPositionFn,
133
- targetMode: 'type',
134
- targetTypeName: names.cardType,
135
- triggerType: 'manual',
136
- maxTargets: shuffleMaxTargets,
137
- selectorJson: JSON.stringify({
138
- selfWhere: [{ key: 'zone', op: '==', value: 'deck' }],
139
- }),
140
- description: 'Manual shuffle: fans assign_position out over every deck-zone card (run via gameModelRunAutomation / kit.decks.shuffle).',
141
- },
142
- ];
143
- return {
144
- name: names.cardType,
145
- containerTypes: [
146
- {
147
- typeName: names.cardDefType,
148
- displayName: names.cardDefType,
149
- instantiableBy: 'admin',
150
- description: 'Studio card catalog row.',
151
- },
152
- {
153
- typeName: names.cardType,
154
- displayName: names.cardType,
155
- instantiableBy: 'member',
156
- description: 'One card in play: hidden while in deck/hand (owner-visible card_id), public once revealed.',
157
- },
158
- ],
159
- propertyDefinitions,
160
- functions,
161
- automations,
162
- };
163
- }
@@ -1,88 +0,0 @@
1
- import { type KitBlueprint, type KitOwnerIdKind, type KitTrustedAuthority } from './core.js';
2
- /** Options for {@link economyBlueprint}. */
3
- export interface EconomyBlueprintOptions {
4
- /**
5
- * Prefix applied to the container type names (`'Black'` → `BlackWallet` /
6
- * `BlackShopListing` / …) and, snake-cased, to the function names
7
- * (`black_earn_gold`, …). Lets several economies coexist. Defaults to none.
8
- */
9
- typePrefix?: string;
10
- /**
11
- * Currency property names on the wallet, one int property (default 0) per
12
- * entry, each with `earn_<c>` / `spend_<c>` functions. Defaults to
13
- * `['gold']`.
14
- */
15
- currencies?: string[];
16
- /**
17
- * The wallet currency shops and market listings are priced in. Defaults to
18
- * the first entry of `currencies`. (Expressions cannot pick a wallet
19
- * property dynamically, so one deployment trades in one currency; deploy a
20
- * prefixed second blueprint for a second shop currency.)
21
- */
22
- shopCurrency?: string;
23
- /**
24
- * Who may mint currency via `earn_<c>`. Trusted grants should be `'server'`
25
- * (app admins / studio backend, the default), `'host'`, or
26
- * `'automation'` — never plain players. Defaults to `'server'`.
27
- */
28
- earnAuthority?: KitTrustedAuthority;
29
- /**
30
- * How `owner_user_id` mirrors are typed on the stack containers this
31
- * economy guards (see the kit owner-mirroring convention). Defaults to
32
- * `'int'` (the kit standard).
33
- */
34
- ownerIdKind?: KitOwnerIdKind;
35
- /**
36
- * When set, adds a `restock_listing` automation that periodically raises
37
- * every listing's `stock` (by `amount`, clamped to `max_stock`) — the NPC
38
- * trader restock pattern.
39
- */
40
- restock?: {
41
- intervalMs: number;
42
- amount?: number;
43
- };
44
- }
45
- /** Names derived by {@link economyBlueprint} for a given prefix. */
46
- export interface EconomyNames {
47
- walletType: string;
48
- listingType: string;
49
- tradeType: string;
50
- marketType: string;
51
- /** Snake-cased function-name prefix (empty without a `typePrefix`). */
52
- fnPrefix: string;
53
- buyListingFn: string;
54
- acceptTradeFn: string;
55
- cancelTradeFn: string;
56
- buyMarketFn: string;
57
- cancelMarketFn: string;
58
- restockFn: string;
59
- restockAutomation: string;
60
- }
61
- /** Compute the type/function names an economy blueprint (and its runtime helper) uses. */
62
- export declare function economyNames(typePrefix?: string): EconomyNames;
63
- /** The earn/spend function name for one currency. */
64
- export declare function economyCurrencyFn(verb: 'earn' | 'spend', currency: string, typePrefix?: string): string;
65
- /**
66
- * Blueprint for a server-authoritative **economy**: per-player `Wallet`
67
- * containers (one int property per currency), an admin `ShopListing` catalog
68
- * with an atomic `buy_listing` (wallet debit + stock decrement + item grant
69
- * in ONE invoke), escrow `TradeOffer` swaps, and a player-to-player
70
- * `MarketListing` flow (buyer wallet → seller wallet + stack transfer, all
71
- * in one transaction).
72
- *
73
- * Anti-duplication is structural: every movement of currency or items is a
74
- * single function invocation whose condition guards check balances, stock,
75
- * item identity, and ownership mirrors server-side — never split a spend and
76
- * a grant across two invokes. Trusted mints (`earn_<c>`) default to
77
- * `invokeScope: "server"` (app admins only).
78
- *
79
- * Trade/market guards verify stack ownership through the kit-standard
80
- * `owner_user_id` mirror property on the stack type (the inventory blueprint
81
- * defines it; set it via `InventoryKit.createStack({ ownerUserId })`), and
82
- * pin the offer creator via the injected `$self_owner_id` — the server-truth
83
- * owner of the offer/listing container.
84
- *
85
- * Runtime counterpart: `client.kit(appId).economy`.
86
- */
87
- export declare function economyBlueprint(options?: EconomyBlueprintOptions): KitBlueprint;
88
- //# sourceMappingURL=economy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"economy.d.ts","sourceRoot":"","sources":["../../../src/kit/blueprints/economy.ts"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAEnB,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,UAAU,SAAK,GAAG,YAAY,CAgB1D;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,QAAQ,EAAE,MAAM,EAChB,UAAU,SAAK,GACd,MAAM,CAGR;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,uBAA4B,GACpC,YAAY,CAyfd"}