@joiner-platform/cli 0.0.0-stage → 0.1.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 (303) hide show
  1. package/README.md +30 -2
  2. package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
  3. package/bundled-resources/poe-tile-templates/base/README.md +7 -0
  4. package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
  5. package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
  6. package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
  7. package/bundled-resources/poe-tile-templates/base/package.json +36 -0
  8. package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
  9. package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
  10. package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
  11. package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
  12. package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
  13. package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
  14. package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
  15. package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
  16. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
  17. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
  18. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
  19. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
  20. package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
  21. package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
  22. package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
  23. package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
  24. package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
  25. package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
  26. package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
  27. package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
  28. package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
  29. package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
  30. package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
  31. package/bundled-resources/poe-tile-templates/index.ts +27 -0
  32. package/bundled-resources/poe-tile-templates/package.json +31 -0
  33. package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
  34. package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
  35. package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
  36. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
  37. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
  38. package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
  39. package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
  40. package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
  41. package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
  42. package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
  43. package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
  44. package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
  45. package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
  46. package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
  47. package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
  48. package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
  49. package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
  50. package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
  51. package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
  52. package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
  53. package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
  54. package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
  55. package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
  56. package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
  57. package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
  58. package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
  59. package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
  60. package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
  61. package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
  62. package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
  63. package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
  64. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
  65. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
  66. package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
  67. package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
  68. package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
  69. package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
  70. package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
  71. package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
  72. package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
  73. package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
  74. package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
  75. package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
  76. package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
  77. package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
  78. package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
  79. package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
  80. package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
  81. package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
  82. package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
  83. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
  84. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
  85. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
  86. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
  87. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
  88. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
  89. package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
  90. package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
  91. package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
  92. package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
  93. package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
  94. package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
  95. package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
  96. package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
  97. package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
  98. package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
  99. package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
  100. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
  101. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
  102. package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
  103. package/cli.ts +134 -0
  104. package/index.ts +96 -0
  105. package/package.json +48 -5
  106. package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
  107. package/skills/audio-generation/SKILL.md +125 -0
  108. package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
  109. package/skills/finish-prototype/SKILL.md +22 -0
  110. package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
  111. package/skills/help-me-build/SKILL.md +56 -0
  112. package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
  113. package/skills/image-generation/SKILL.md +128 -0
  114. package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
  115. package/skills/one-shot/SKILL.md +22 -0
  116. package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
  117. package/skills/platform-prototype/SKILL.md +60 -0
  118. package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
  119. package/skills/platform-subagent/SKILL.md +16 -0
  120. package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
  121. package/skills/poe-tiles-cli/SKILL.md +609 -0
  122. package/skills/poe-tiles-cli/references/device-motion.md +40 -0
  123. package/skills/poe-tiles-cli/references/player-updates.md +41 -0
  124. package/skills/prototype/.generated-by-poe-templated-docs +0 -0
  125. package/skills/prototype/SKILL.md +149 -0
  126. package/skills/publish/.generated-by-poe-templated-docs +0 -0
  127. package/skills/publish/SKILL.md +73 -0
  128. package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
  129. package/skills/synced-store/SKILL.md +583 -0
  130. package/skills/synced-store/references/actions.md +85 -0
  131. package/skills/synced-store/references/api-patterns.md +245 -0
  132. package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
  133. package/skills/synced-store/references/client-api-reference.md +263 -0
  134. package/skills/synced-store/references/data-visibility.md +95 -0
  135. package/skills/synced-store/references/external-stores.md +162 -0
  136. package/skills/synced-store/references/file-uploads.md +216 -0
  137. package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
  138. package/skills/synced-store/references/limitations.md +72 -0
  139. package/skills/synced-store/references/live-data-limit-hook.md +131 -0
  140. package/skills/synced-store/references/mutator-rules.md +169 -0
  141. package/skills/synced-store/references/platform.md +49 -0
  142. package/skills/synced-store/references/schema-and-bindings.md +85 -0
  143. package/skills/synced-store/references/schema-libraries.md +57 -0
  144. package/skills/synced-store/references/schema-migrations.md +119 -0
  145. package/skills/synced-store/references/searchable-tables.md +27 -0
  146. package/skills/synced-store/references/server-forking.md +115 -0
  147. package/skills/synced-store/references/singleton-tables.md +61 -0
  148. package/skills/synced-store/references/sort-keys.md +253 -0
  149. package/skills/synced-store/references/ui-patterns.md +95 -0
  150. package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
  151. package/skills/tile-creator/SKILL.md +197 -0
  152. package/skills/tile-creator/references/assets.md +124 -0
  153. package/skills/tile-creator/references/backend-api.md +354 -0
  154. package/skills/tile-creator/references/cli-limitations.md +64 -0
  155. package/skills/tile-creator/references/cli.md +604 -0
  156. package/skills/tile-creator/references/client-api.md +2407 -0
  157. package/skills/tile-creator/references/composing-apps.md +166 -0
  158. package/skills/tile-creator/references/e2e-tests.md +55 -0
  159. package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
  160. package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
  161. package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
  162. package/skills/tile-creator/references/native-results.md +100 -0
  163. package/skills/tile-creator/references/platform-integration.md +201 -0
  164. package/skills/tile-creator/references/power-report.md +199 -0
  165. package/skills/tile-creator/references/publish-rollout.md +166 -0
  166. package/skills/tile-creator/references/publishing.md +33 -0
  167. package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
  168. package/skills/tile-creator/references/render-check.md +266 -0
  169. package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
  170. package/skills/tile-creator/references/safe-area-insets.md +79 -0
  171. package/skills/tile-creator/references/sandbox-limitations.md +32 -0
  172. package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
  173. package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
  174. package/skills/tile-creator/references/simulations.md +125 -0
  175. package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
  176. package/skills/tile-creator/references/troubleshooting.md +22 -0
  177. package/skills/tile-creator/references/turn-based-mutator.md +43 -0
  178. package/skills/tile-creator/references/user-erasure.md +14 -0
  179. package/skills/tile-creator/references/vite-plugin.md +166 -0
  180. package/skills/tile-creator/references/workspace-retention.md +72 -0
  181. package/src/admin-conversions-client.ts +28 -0
  182. package/src/admin-reviews-client.ts +36 -0
  183. package/src/api.generated.ts +1527 -0
  184. package/src/auth-token.ts +198 -0
  185. package/src/bounded-read.ts +35 -0
  186. package/src/bun-version.ts +33 -0
  187. package/src/checkout-base.ts +207 -0
  188. package/src/cli-bun-version.ts +16 -0
  189. package/src/cli-env.ts +28 -0
  190. package/src/cli-name.ts +23 -0
  191. package/src/client.ts +2474 -0
  192. package/src/collect-files.ts +226 -0
  193. package/src/commands/accounts.ts +55 -0
  194. package/src/commands/admin-abandon-conversion.ts +60 -0
  195. package/src/commands/admin-reviews.ts +66 -0
  196. package/src/commands/admin.ts +219 -0
  197. package/src/commands/auth.ts +89 -0
  198. package/src/commands/checkout-prototype.ts +67 -0
  199. package/src/commands/creator-source-capability.ts +11 -0
  200. package/src/commands/doctor-bun.ts +145 -0
  201. package/src/commands/doctor-command.ts +64 -0
  202. package/src/commands/doctor-package-json.ts +47 -0
  203. package/src/commands/doctor-sdk-pin.ts +156 -0
  204. package/src/commands/doctor-store-keys-lexer.ts +213 -0
  205. package/src/commands/doctor-store-keys-scan.ts +262 -0
  206. package/src/commands/doctor-store-keys.ts +196 -0
  207. package/src/commands/doctor.ts +371 -0
  208. package/src/commands/init/blank-scaffold-templates.ts +397 -0
  209. package/src/commands/init/index.ts +170 -0
  210. package/src/commands/init/internal-toolchain.ts +49 -0
  211. package/src/commands/init/manager-test-template.ts +107 -0
  212. package/src/commands/init/multiplayer-test-template.ts +217 -0
  213. package/src/commands/init/name-input.tsx +167 -0
  214. package/src/commands/init/no-store-scaffold-templates.ts +281 -0
  215. package/src/commands/init/no-store-scaffold.ts +134 -0
  216. package/src/commands/init/package-json-scripts.ts +72 -0
  217. package/src/commands/init/scaffold.ts +960 -0
  218. package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
  219. package/src/commands/init/sdk-tarball-url.ts +31 -0
  220. package/src/commands/init/template-picker.tsx +147 -0
  221. package/src/commands/inspect-child-entry.ts +107 -0
  222. package/src/commands/inspect-contract.ts +87 -0
  223. package/src/commands/inspect-freshness.ts +217 -0
  224. package/src/commands/inspect-lock.ts +201 -0
  225. package/src/commands/inspect-options.ts +360 -0
  226. package/src/commands/inspect-orchestrate.ts +375 -0
  227. package/src/commands/inspect-process.ts +172 -0
  228. package/src/commands/inspect-ready.ts +65 -0
  229. package/src/commands/inspect-report.ts +235 -0
  230. package/src/commands/inspect-run-state.ts +296 -0
  231. package/src/commands/inspect-run.ts +157 -0
  232. package/src/commands/inspect-watchdog.ts +74 -0
  233. package/src/commands/install-joiner.ts +208 -0
  234. package/src/commands/login.ts +308 -0
  235. package/src/commands/models.ts +40 -0
  236. package/src/commands/parse-options.ts +36 -0
  237. package/src/commands/remix-package-json.ts +64 -0
  238. package/src/commands/remix.ts +379 -0
  239. package/src/commands/sdk-url.ts +141 -0
  240. package/src/commands/simulations.ts +133 -0
  241. package/src/commands/skills.ts +108 -0
  242. package/src/commands/store-files.ts +92 -0
  243. package/src/commands/stores.ts +703 -0
  244. package/src/commands/tiles-channel-commands.ts +115 -0
  245. package/src/commands/tiles-checkout.ts +351 -0
  246. package/src/commands/tiles-gallery-command.ts +95 -0
  247. package/src/commands/tiles-get-helpers.ts +27 -0
  248. package/src/commands/tiles-inspect.ts +276 -0
  249. package/src/commands/tiles-power-command.ts +308 -0
  250. package/src/commands/tiles-power-format.ts +396 -0
  251. package/src/commands/tiles-power-versions.ts +299 -0
  252. package/src/commands/tiles-publish-helpers.ts +145 -0
  253. package/src/commands/tiles-upload-command.ts +277 -0
  254. package/src/commands/tiles-version-commands.ts +201 -0
  255. package/src/commands/tiles-visibility-command.ts +103 -0
  256. package/src/commands/tiles.ts +257 -0
  257. package/src/commands/upgrade.ts +307 -0
  258. package/src/commit-in-progress.ts +42 -0
  259. package/src/creator-source-context.ts +97 -0
  260. package/src/creator-source-publish.ts +52 -0
  261. package/src/deferred-assets.ts +125 -0
  262. package/src/distribution.ts +28 -0
  263. package/src/errors.ts +61 -0
  264. package/src/install-command.ts +43 -0
  265. package/src/output.ts +62 -0
  266. package/src/poe-tile-config-files.ts +100 -0
  267. package/src/poe-tile-config-players.ts +168 -0
  268. package/src/poe-tile-config-remix.ts +166 -0
  269. package/src/poe-tile-config.ts +831 -0
  270. package/src/power-report-client.ts +55 -0
  271. package/src/prototype-startup.ts +21 -0
  272. package/src/publish-change-summary.ts +55 -0
  273. package/src/publish-overrides-validation.ts +49 -0
  274. package/src/publish-pack.ts +167 -0
  275. package/src/publish-phases.ts +57 -0
  276. package/src/publish-retry.ts +51 -0
  277. package/src/publish-tile-from-config.ts +434 -0
  278. package/src/recorder-stream.ts +169 -0
  279. package/src/remix-provenance.ts +156 -0
  280. package/src/resolve-client-credential.ts +71 -0
  281. package/src/resolve-media-uploads.ts +147 -0
  282. package/src/sdk-dependency.ts +54 -0
  283. package/src/sdk-skills.ts +85 -0
  284. package/src/should-skip-client-setup.ts +20 -0
  285. package/src/simulation-snapshot.ts +123 -0
  286. package/src/simulation-types.ts +74 -0
  287. package/src/simulations-client.ts +112 -0
  288. package/src/source-bundle.ts +466 -0
  289. package/src/staged-publish-cleanup.ts +44 -0
  290. package/src/staged-publish-deferred.ts +160 -0
  291. package/src/staged-publish.ts +401 -0
  292. package/src/store-file-upload.ts +268 -0
  293. package/src/store-request.ts +168 -0
  294. package/src/tar-canonical.ts +41 -0
  295. package/src/tar-extensions.ts +159 -0
  296. package/src/tar-extract.ts +193 -0
  297. package/src/tar-parse.ts +224 -0
  298. package/src/tar.ts +231 -0
  299. package/src/template-check-scripts.ts +18 -0
  300. package/src/tile-gallery-client.ts +82 -0
  301. package/src/types.ts +258 -0
  302. package/src/upload-concurrency.ts +54 -0
  303. package/src/whole-tile.ts +52 -0
@@ -0,0 +1,354 @@
1
+ # Backend API
2
+
3
+ The `joiner-sdk/v1/backend.js` module is the single import for everything a Joiner tile needs on the backend side. It wraps `@synced-store/backend` with platform defaults — system tables and hooks are pre-wired so apps don't configure them manually.
4
+
5
+ ```typescript
6
+ import {
7
+ defineSchema, table, singletonTable, item,
8
+ defineBackendConfig,
9
+ } from "joiner-sdk/v1/backend.js";
10
+ ```
11
+
12
+ ## Schema Builders
13
+
14
+ ### `defineSchema()`
15
+
16
+ Define a synced-store schema with platform system tables automatically configured. System tables (`$users`, `$userInfo`) are pre-wired — no need to pass `systemTableTypes`.
17
+
18
+ ```typescript
19
+ import { defineSchema, table } from "joiner-sdk/v1/backend.js";
20
+ import { z } from "zod";
21
+ import { TILE_SCHEMA_VERSION } from "./tile-schema-version";
22
+
23
+ export const mySchema = defineSchema({
24
+ schemaVersion: TILE_SCHEMA_VERSION,
25
+ tables: {
26
+ messages: {
27
+ schema: table(z.object({
28
+ text: z.string(),
29
+ sender: z.string(),
30
+ })),
31
+ },
32
+ },
33
+ mutators: {
34
+ send: {
35
+ description: "Send a message",
36
+ input: z.object({ text: z.string() }),
37
+ },
38
+ },
39
+ actions: {
40
+ summarize: {
41
+ description: "Summarize the conversation",
42
+ input: z.object({}),
43
+ },
44
+ },
45
+ });
46
+ ```
47
+
48
+ ### `table(schema)`
49
+
50
+ Define a homogeneous table where every row has the same Zod schema.
51
+
52
+ ### `singletonTable(items)`
53
+
54
+ Define a singleton table with a fixed set of typed keys.
55
+
56
+ ```typescript
57
+ import { singletonTable, item } from "joiner-sdk/v1/backend.js";
58
+ import { z } from "zod";
59
+
60
+ const settings = singletonTable({
61
+ theme: item(z.enum(["light", "dark"])),
62
+ language: item(z.string()),
63
+ });
64
+ ```
65
+
66
+ ### `item(schema)`
67
+
68
+ Define a single item within a `singletonTable`.
69
+
70
+ ## `defineBackendConfig()`
71
+
72
+ Bundle your schema, mutators, actions, and hooks into a typed backend config. Hook names (`onInit`, `onAddUsersV2`, `onRemoveUser`, `onAnonymizeUser`, `onSetTitle`, `onGrantPermission`, `onRevokePermission`, `onAddTileInstanceToRoom`, `onChangeTileParent`, `onAddChildTile`, `onChildInstancesAdded`, `onRoomMemberInstanceMovedOut`) are pre-wired with their input types.
73
+
74
+ Every backend hook should also be represented in `defineClientConfig({ hooks })` so `poe-tiles-kernel` can supply matching optimistic startup invocations when opening a fresh prepared store. Put deterministic hook work in a browser-safe shared helper and import that helper into both configs. Keep only truly server-only effects backend-local, or guard them with `if (ctx.isServer)`.
75
+
76
+ ```typescript
77
+ import { defineBackendConfig } from "joiner-sdk/v1/backend.js";
78
+ import { mySchema } from "./schema";
79
+ import { myMutators } from "./mutators/index";
80
+ import { myActions } from "./actions";
81
+
82
+ export const myBackendConfig = defineBackendConfig({
83
+ schema: mySchema,
84
+ mutators: myMutators,
85
+ actions: myActions,
86
+ hooks: {
87
+ onAddUsersV2: async (ctx, { users }) => {
88
+ // Initialize data for every user this batch admitted
89
+ },
90
+ onRemoveUser: async (ctx, { userId }) => {
91
+ // Clean up when a user leaves
92
+ },
93
+ },
94
+ });
95
+ ```
96
+
97
+ ### System Hooks
98
+
99
+ | Hook | Input | When it fires |
100
+ |------|-------|---------------|
101
+ | `onInit` | `{ parentRoomUsers }` | A new child-room instance is initialized with parent-room context (`parentRoomUsers` is a read-only roster snapshot) |
102
+ | `onAddUsersV2` | `{ users: Array<{ userId: string; batchUserIds?: string[]; addedBatchUserIds?: string[]; joinKind?: "added" \| "inviteLink" \| "open" \| "group" \| "session"; invitedBy?: string; poeFeedbackResponder?: boolean }> }` | Users join the store instance; one call per batch |
103
+ | `onRemoveUser` | `{ userId: string }` | User leaves the store instance |
104
+ | `onAnonymizeUser` | `{ userId: string }` | User is hard-deleted/anonymized |
105
+ | `onSetTitle` | `{ userId: string; title: string \| null }` | Store title changes; `title` is `null` when the custom title is cleared/reset to the default — handle the reset case rather than interpolating `null` |
106
+ | `onGrantPermission` | `{ userId: string; permission: string }` | Permission granted |
107
+ | `onRevokePermission` | `{ userId: string; permission: string }` | Permission revoked |
108
+ | `onAddTileInstanceToRoom` | `{ storeTypeId: string; instanceId: string }` | A new app instance is registered as a member of this room (fires on the room store after a new `$room_member_instances` row is written; suppressed on idempotent re-registers) |
109
+ | `onChangeTileParent` | `{ previousParent?: PoeTileRoom; parent?: PoeTileRoom }` | This tile instance gains, loses, or changes its parent rootGroup |
110
+ | `onAddChildTile` | `{ typeId: string; instanceId: string; room: PoeTileRoom; reason?: "adoption" }` | A rootGroup gains one net-new child tile row |
111
+ | `onChildInstancesAdded` | `{ instances: Array<{ typeId: string; instanceId: string; roomTypeId: string; roomId: string; reason?: "adoption" }> }` | A rootGroup gains one or more net-new child tile rows |
112
+ | `onRoomMemberInstanceMovedOut` | `{ storeTypeId, instanceId, toRoom, ... }` | A member app instance is removed from this room |
113
+
114
+ Common hook uses:
115
+
116
+ - `onInit` is for deterministic one-time bootstrap. Use it to seed app-owned rows such as an initial activity message (`"{name} started the group"`). `parentRoomUsers` is a read-only snapshot of the parent room's roster — never a way to admit members. Membership is platform-owned: the host seats the launcher at genesis (both users when the tile is launched from a 2-person room, i.e. a DM); larger rooms stay picker-driven.
117
+ - `onAddUsersV2(ctx, { users })` runs after membership is written, once for every batch of users admitted together (a genesis roster, a multi-person invite), in admission order. Auto-seat users through this hook. Read `$users[userId].addedBy` and `$userInfo` for attribution; each entry's optional `addedBatchUserIds` is that operation’s ordered invitation group, so one call can write one grouped announcement. Retain historical names/IDs in your own message metadata; invitation context is not a membership table.
118
+ - Each entry's optional `joinKind` says how the member came in:
119
+
120
+ | `joinKind` | The member... | Who to credit |
121
+ |---|---|---|
122
+ | `"added"` | was added by another member (the host picker, `Poe.room.pickMembers()`) | `$users[userId].addedBy` |
123
+ | `"inviteLink"` | opened another member's invite link | `invitedBy`, the link's creator; absent when the creator was not in the room at the join, or has deleted their account |
124
+ | `"open"` | joined from "Join your friends" because a member lets their network or contacts join | nobody |
125
+ | `"group"` | is in the room's parent group and let themselves in | nobody |
126
+ | `"session"` | came from the session this one was launched from | nobody |
127
+
128
+ `joinKind` is absent for the launch roster, for other platform adds, and for a member who opens their own invite link. Only this hook gets the two fields: they are not on the member's `$users` row, so save what you need in your own table when the hook runs. A tile instance created after the member joined gets the same values in its hook. A member who joined before the platform recorded joins can have no `joinKind`.
129
+
130
+ To gate something until a player invites a helper, or to pay a reward for an invite, record the credit once per invited user. Pay a reward in the same hook, and cap what one inviter can earn:
131
+
132
+ ```typescript
133
+ const MAX_REWARDED_INVITES = 5;
134
+
135
+ onAddUsersV2: async (ctx, { users }) => {
136
+ for (const user of users) {
137
+ if (user.userId.startsWith("agent_")) continue; // an agent is not a helper
138
+ const inviter =
139
+ user.joinKind === "inviteLink"
140
+ ? user.invitedBy
141
+ : user.joinKind === "added"
142
+ ? (await ctx.table("$users").get(user.userId))?.addedBy
143
+ : undefined;
144
+ if (inviter === undefined) continue;
145
+ // Keyed by the invited user, so leaving and coming back counts once.
146
+ if (await ctx.table("invites").get(user.userId)) continue;
147
+ await ctx.table("invites").set({
148
+ itemKey: user.userId,
149
+ value: { invitedUserId: user.userId, inviterUserId: inviter },
150
+ });
151
+ // A gate needs only the row above. A reward also needs a cap for each
152
+ // inviter, or a second account can earn it without limit.
153
+ const rewarded =
154
+ (await ctx.table("inviteRewards").get(inviter))?.count ?? 0;
155
+ if (rewarded >= MAX_REWARDED_INVITES) continue;
156
+ await ctx.table("inviteRewards").set({
157
+ itemKey: inviter,
158
+ value: { count: rewarded + 1 },
159
+ });
160
+ // Pay the reward to `inviter` here, in your own table.
161
+ }
162
+ },
163
+ ```
164
+ - `onAddUsers` is deprecated. Use `onAddUsersV2`; a tile that defines both fails to load.
165
+
166
+ See [historical account erasure](user-erasure.md) for repairing old roster rows with `isUserErased`.
167
+
168
+ ## System Tables
169
+
170
+ These tables are automatically available in mutators and actions via `ctx.table()`:
171
+
172
+ | Table | Type | Description |
173
+ |-------|------|-------------|
174
+ | `$users` | `UserMembership` | Users currently in the store instance |
175
+ | `$userInfo` | `PoeUserInfo` | Profile information for each user |
176
+
177
+ ```typescript
178
+ // In a mutator or action:
179
+ const user = await ctx.table("$users").get(userId);
180
+ const info = await ctx.table("$userInfo").get(userId);
181
+ ```
182
+
183
+ ## `_requestUploadUrl` — app-controlled uploads
184
+
185
+ File uploads (`store.files.upload()` on the client) are off until your app
186
+ opts in by declaring and implementing the reserved `_requestUploadUrl` action
187
+ — the platform runs it server-side before minting each upload ticket, so it
188
+ is your policy gate: who may upload, what, and when.
189
+
190
+ Declare it in the schema (the leading `_` marks it platform-invoked; it never
191
+ appears on the client's `store.action`):
192
+
193
+ ```typescript
194
+ actions: {
195
+ _requestUploadUrl: {
196
+ description: "Approve one photo upload per player per day",
197
+ input: z.object({
198
+ fileId: z.string(),
199
+ sizeBytes: z.number(),
200
+ name: z.string().optional(),
201
+ }),
202
+ output: z.unknown(),
203
+ },
204
+ },
205
+ ```
206
+
207
+ Implement it with your backend actions. The handler runs on a **read-only**
208
+ action context (table reads and `ctx.files.generateUploadUrl` only — no
209
+ `ctx.mutate`, no external dispatch). Approve by calling
210
+ `ctx.files.generateUploadUrl(...)` exactly once; deny by throwing an
211
+ `ActionError` whose code (letters/digits/`_`, bounded) reaches the client as
212
+ `error.appCode`:
213
+
214
+ ```typescript
215
+ import { ActionError } from "joiner-sdk/v1/backend.js";
216
+
217
+ const actions = {
218
+ _requestUploadUrl: async (ctx, input) => {
219
+ if (input.sizeBytes > 5 * 1024 * 1024) {
220
+ throw new ActionError("photo_too_large");
221
+ }
222
+ await ctx.files.generateUploadUrl({ sizeBytes: input.sizeBytes });
223
+ return null;
224
+ },
225
+ };
226
+ ```
227
+
228
+ **Enforce app rules in the CLAIMING MUTATOR, not here.** The handler is
229
+ read-only and records nothing, so it cannot serialize concurrent uploads —
230
+ any grant-time rule (one photo per day, one entry per round) is advisory at
231
+ best, and the mutator that writes the `fileRefs` claim is the authoritative
232
+ gate anyway (a rejected claim just lets the unclaimed upload expire). Gate
233
+ here only what must be decided BEFORE the bytes are uploaded: the size cap,
234
+ or whether uploads are open at all.
235
+
236
+ `ctx.userId` is the uploading member (platform-verified). `generateUploadUrl`
237
+ accepts two distinct optional size params: `sizeBytes` re-asserts the
238
+ request's declared size (a mismatch rejects the grant), while `maxBytes` is
239
+ an approval CEILING the receiver enforces — not a way to pick the size; to
240
+ enforce a size policy, throw before minting.
241
+ Returning without minting (or minting twice) invalidates the grant. Platform
242
+ quotas and rate limits still apply on top of your policy.
243
+
244
+ Backend actions can inspect the exact platform counters with
245
+ `ctx.files.getQuotaUsage()`. It returns store-instance usage and byte/count
246
+ limits plus the acting user's attributed usage. Pass `{ userId }` to select
247
+ another user in the same store instance:
248
+
249
+ ```typescript
250
+ const mine = await ctx.files.getQuotaUsage();
251
+ const anotherUser = await ctx.files.getQuotaUsage({ userId });
252
+ // { instance: { bytes, count, limitBytes, limitCount },
253
+ // user: { userId, bytes, count } }
254
+ ```
255
+
256
+ The call is allowed inside the read-only `_requestUploadUrl` handler, so an app
257
+ can reject against exact aggregate usage before transferring bytes. The
258
+ publish-time platform check remains authoritative under concurrent grants.
259
+
260
+ ## Platform Capabilities
261
+
262
+ Actions and guarded server-side mutator code have access to server-side services via `ctx.platform.call()` — environment variables, and more. Prefer actions; mutator platform calls are discouraged, must be awaited, must be idempotent/read-only because optimistic-lock conflicts can retry the server mutator attempt, and should be rare because mutators are processed one at a time. See [Platform](../../synced-store/references/platform.md) for the full guidance.
263
+
264
+
265
+ ## Type Exports
266
+
267
+ ### Type Inference Utilities
268
+
269
+ ```typescript
270
+ import type {
271
+ InferActionContext, // Action context type from schema
272
+ InferActionHandlers, // Action handler types from schema
273
+ InferMutationContext, // Mutation context type from schema
274
+ InferMutatorHandlers, // Mutator handler types from schema
275
+ InferReadContext, // Read-only context type from schema
276
+ InferSchemaTableTypes, // Table types from schema
277
+ InferSchemaActionSchemas, // Action input schemas from schema
278
+ InferSchemaMutatorSchemas,// Mutator input schemas from schema
279
+ } from "joiner-sdk/v1/backend.js";
280
+ ```
281
+
282
+ ### Core Types
283
+
284
+ ```typescript
285
+ import type {
286
+ ActionContext, ActionFn, // Server-side action context
287
+ MutationContext, MutationFn, // Shared mutation context (client + server)
288
+ QueryContext, QueryFn, // Query context
289
+ JSONValue, // JSON-serializable value
290
+ ScanResult, // Table scan result
291
+ TableReader, TableWriter, // Table operation interfaces
292
+ } from "joiner-sdk/v1/backend.js";
293
+ ```
294
+
295
+ ### Shared Table Contracts
296
+
297
+ ```typescript
298
+ import type {
299
+ EntryKey,
300
+ ExternalStoreTableReader,
301
+ TablePageOptions,
302
+ TablePageResult,
303
+ } from "joiner-sdk/v1/shared.js";
304
+ import { MAX_TABLE_PAGE_CURSOR_LENGTH } from "joiner-sdk/v1/shared.js";
305
+ ```
306
+
307
+ - `EntryKey` has a required `itemKey` and optional `sortKey`. Within a table, `itemKey` identifies the row; `sortKey` controls ordering, not identity.
308
+ - `ExternalStoreTableReader<T>` is a read-only table interface without `pageByItemKey`. Its `getWithStoreVersion(key)` returns `{ value, storeVersion, synced }`: the value and target store version come from the same snapshot, even when the row is absent. `synced` indicates whether the target has completed at least one sync.
309
+ - In a mutator or action, an external `scan` (`ctx.externalStore(...)`) reads one target snapshot per response. A scan with a `limit` gets up to 1,000 rows (and at most 1,048,576 bytes of JSON-serialized rows) per response; a scan without one gets 100 rows per response. If the target commits between two responses of the same scan, the scan throws a version conflict. To read a whole bounded table consistently, pass its maximum row count as the `limit`.
310
+
311
+ Server current-store table handles expose `pageByItemKey(options)`, using
312
+ `TablePageOptions`: required `maxPhysicalRows` (a positive safe integer) and
313
+ optional `cursor`. The budget bounds base-storage work, not matching results;
314
+ overlay work is counted separately in `overlayEntriesExamined`.
315
+ `TablePageResult<T>` contains `entries: Array<[EntryKey, T]>`,
316
+ `overlayEntriesExamined`, and either `{ status: "continue", cursor }` or
317
+ `{ status: "exhausted" }`. An empty page can still continue; stop only on
318
+ `"exhausted"`.
319
+
320
+ Mutators also run optimistically on clients, where `pageByItemKey` throws despite
321
+ being present on the `TableReader` type. In a mutator, guard paging and all dependent
322
+ work with `if (ctx.isServer)`. Server actions, including read-only actions, can page
323
+ current-store tables; an action is not an atomic replacement for a mutator's
324
+ read-and-write operation.
325
+
326
+ Pass opaque continuation cursors unchanged to the same store and table scope.
327
+ They advance by item identity, not `sortKey` order, and do not snapshot future writes.
328
+ Use `MAX_TABLE_PAGE_CURSOR_LENGTH` as the serialized cursor length bound when
329
+ validating persisted or forwarded cursors. Paging is not available on external
330
+ store table handles.
331
+
332
+ ### Poe Platform Types
333
+
334
+ ```typescript
335
+ import type {
336
+ PlatformCaller, // Type for ctx.platform.call()
337
+ PlatformAPI, // Platform capability types
338
+ PlatformAPIName, // Platform capability names
339
+ InferSystemHooks, // Schema-aware app hook definitions
340
+ SystemHookMap, // Platform hook names and inputs
341
+ SystemTableTypes, // System table type map
342
+ PoeUserInfo, // User profile data
343
+ UserMembership, // User membership record
344
+ } from "joiner-sdk/v1/backend.js";
345
+ ```
346
+
347
+ ### Migration Types
348
+
349
+ ```typescript
350
+ import type {
351
+ AnyMigration, // Single migration step
352
+ Migrations, // Array of migrations for schema versioning
353
+ } from "joiner-sdk/v1/backend.js";
354
+ ```
@@ -0,0 +1,64 @@
1
+ # Bundle publishing limits
2
+
3
+ These limits apply to each uploaded bundle, including preview uploads. All
4
+ sizes use binary units: **1 MiB = 1,048,576 bytes**.
5
+
6
+ ## Client/runtime bundles
7
+
8
+ The runtime bundle is the built `.tar.gz` uploaded for a tile. The platform
9
+ extracts any backend artifacts and produces the client bundle served to players.
10
+
11
+ | What is measured | Maximum | Meaning |
12
+ | --- | --- | --- |
13
+ | Total decompressed file data | 100 MiB (104,857,600 bytes) | Sum of the regular files' contents after decompression, excluding tar headers and padding. |
14
+ | Individual decompressed file | 20 MiB (20,971,520 bytes) | Contents of any one regular file after decompression. A phone hands a tile several copies of each asset it requests, so one large file costs more than the same bytes split up; split large data files into smaller ones. |
15
+ | File count | 1,000 | Regular file entries in the bundle. |
16
+ | Backend artifact | 8 MiB (8,388,608 bytes) | Decompressed size of `synced-store-backend-config.js`, the server-side code the platform loads into your tile's store. The build fails locally and publish rejects with a 400 naming the artifact and the limit. Reduce server code and bundled data, or move large assets to managed files. |
17
+ | Backend bytecode artifact | 12 MiB (12,582,912 bytes) | Decompressed size of `synced-store-backend-config.quickjs`, the compiled form of the backend artifact that production executes. |
18
+
19
+ The upload is refused as soon as the archive is found to exceed the first
20
+ three, before anything is stored; a small compressed archive can still exceed
21
+ the decompressed-data limit. The server also bounds the compressed archive,
22
+ but that bound is sized so it never refuses an archive within the limits
23
+ above. The two backend artifact limits are checked by the build and again
24
+ when the publish is committed. Runtime validation counts backend artifacts
25
+ before removing them from the client bundle, so they consume the uploaded
26
+ bundle's file-count and decompressed-data budgets too.
27
+
28
+ ## Source archives
29
+
30
+ The optional source bundle is a separate `.tar.gz` containing project source,
31
+ not the client assets served to players. Its compressed upload/download limit
32
+ is **100 MiB (104,857,600 bytes)**, independent of the client/runtime bundle's
33
+ decompressed-data limit.
34
+
35
+ When building a source archive, the CLI also limits the selected files to
36
+ **100 MiB of total file contents before compression** and **50,000 files**,
37
+ after ignore rules. These are source-packaging checks in the CLI; the publish
38
+ API enforces the compressed source size without parsing it to enforce a source
39
+ file-count or decompressed-data limit. The client bundle's 1,000-file and
40
+ 20 MiB-per-file limits do not apply to source archives.
41
+
42
+ These publishing limits do not grant additional browser cache allowance or
43
+ describe exact disk usage. A browser origin can cache multiple client bundles;
44
+ cache retention and physical storage overhead are separate concerns. See
45
+ [Publishing a tile](publishing.md) for the upload workflow.
46
+
47
+ ## Upload rate
48
+
49
+ Each account may upload, counting preview uploads and a new tile's first upload:
50
+
51
+ | Uploads counted | Short limit | Long limit |
52
+ | --- | --- | --- |
53
+ | Every upload | 50 per 10 minutes | 1,000 per 24 hours |
54
+ | Uploads that create a new tile | 10 per hour | 50 per 7 days |
55
+
56
+ A new tile's first upload counts against both rows. Each limit refills
57
+ steadily: after the full count is used, one more upload is allowed every
58
+ period divided by the count (every 12 seconds for the 10-minute limit, every
59
+ 6 minutes for new tiles per hour). An upload over a limit is refused with HTTP
60
+ 429, code `publish_rate_limited`, a `scope` of `publish` or `new_tile`, and
61
+ `retry_after_seconds` (also sent as `Retry-After`). Nothing is written. Wait
62
+ that many seconds before retrying the same upload; retrying sooner is refused
63
+ again. Upload once per meaningful change rather than on every file save.
64
+