@yaks/platform 0.0.0-stage → 0.2.36

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 (1213) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +261 -2
  3. package/_client-blobs.js +7 -0
  4. package/_client-error.js +70 -0
  5. package/_client-modal.js +3 -0
  6. package/_client-replica.js +5 -0
  7. package/_client-review.js +1 -0
  8. package/_client-schema.js +1 -0
  9. package/_client-vault.js +31 -0
  10. package/_edit-query.js +1 -0
  11. package/_uploads.js +4 -0
  12. package/account-browser.js +67 -0
  13. package/account-browser.js.map +1 -0
  14. package/account-browser.ts +87 -0
  15. package/account-rows.js +130 -0
  16. package/account-rows.js.map +1 -0
  17. package/account-rows.ts +237 -0
  18. package/admin-visits-view.js +65 -0
  19. package/admin-visits-view.js.map +1 -0
  20. package/admin-visits-view.ts +120 -0
  21. package/admin-visits.js +143 -0
  22. package/admin-visits.js.map +1 -0
  23. package/admin-visits.ts +211 -0
  24. package/admit-graph.js +8 -0
  25. package/admit-graph.js.map +1 -0
  26. package/admit-graph.ts +10 -0
  27. package/agent-guide.js +368 -0
  28. package/agent-guide.js.map +1 -0
  29. package/agent-guide.ts +450 -0
  30. package/agents-browser.js +143 -0
  31. package/agents-browser.js.map +1 -0
  32. package/agents-browser.ts +141 -0
  33. package/agents-view.js +129 -0
  34. package/agents-view.js.map +1 -0
  35. package/agents-view.ts +236 -0
  36. package/agents.js +148 -0
  37. package/agents.js.map +1 -0
  38. package/agents.ts +150 -0
  39. package/app-actions.js +56 -0
  40. package/app-actions.js.map +1 -0
  41. package/app-actions.ts +61 -0
  42. package/app-authority.js +280 -0
  43. package/app-authority.js.map +1 -0
  44. package/app-authority.ts +356 -0
  45. package/app-canvas-browser.js +308 -0
  46. package/app-canvas-browser.js.map +1 -0
  47. package/app-canvas-browser.ts +377 -0
  48. package/app-canvas-view.js +244 -0
  49. package/app-canvas-view.js.map +1 -0
  50. package/app-canvas-view.ts +399 -0
  51. package/app-canvas.js +87 -0
  52. package/app-canvas.js.map +1 -0
  53. package/app-canvas.ts +170 -0
  54. package/app-client.js +521 -0
  55. package/app-client.js.map +1 -0
  56. package/app-client.ts +562 -0
  57. package/app-command.js +108 -0
  58. package/app-command.js.map +1 -0
  59. package/app-command.ts +155 -0
  60. package/app-commands.js +334 -0
  61. package/app-commands.js.map +1 -0
  62. package/app-commands.ts +379 -0
  63. package/app-decision.js +69 -0
  64. package/app-decision.js.map +1 -0
  65. package/app-decision.ts +61 -0
  66. package/app-effects.js +43 -0
  67. package/app-effects.js.map +1 -0
  68. package/app-effects.ts +53 -0
  69. package/app-file.js +252 -0
  70. package/app-file.js.map +1 -0
  71. package/app-file.ts +362 -0
  72. package/app-friends.js +60 -0
  73. package/app-friends.js.map +1 -0
  74. package/app-friends.ts +81 -0
  75. package/app-graph.js +9 -0
  76. package/app-graph.js.map +1 -0
  77. package/app-graph.ts +9 -0
  78. package/app-icon.js +59 -0
  79. package/app-icon.js.map +1 -0
  80. package/app-icon.ts +121 -0
  81. package/app-made.js +164 -0
  82. package/app-made.js.map +1 -0
  83. package/app-made.ts +306 -0
  84. package/app-outbound.js +72 -0
  85. package/app-outbound.js.map +1 -0
  86. package/app-outbound.ts +109 -0
  87. package/app-outbox.js +42 -0
  88. package/app-outbox.js.map +1 -0
  89. package/app-outbox.ts +46 -0
  90. package/app-patch.js +75 -0
  91. package/app-patch.js.map +1 -0
  92. package/app-patch.ts +106 -0
  93. package/app-read.js +101 -0
  94. package/app-read.js.map +1 -0
  95. package/app-read.ts +126 -0
  96. package/app-role-tools.js +232 -0
  97. package/app-role-tools.js.map +1 -0
  98. package/app-role-tools.ts +258 -0
  99. package/app-roles.js +91 -0
  100. package/app-roles.js.map +1 -0
  101. package/app-roles.ts +76 -0
  102. package/app-session-access.js +109 -0
  103. package/app-session-access.js.map +1 -0
  104. package/app-session-access.ts +145 -0
  105. package/app-starter.js +109 -0
  106. package/app-starter.js.map +1 -0
  107. package/app-starter.ts +123 -0
  108. package/app-storage.js +38 -0
  109. package/app-storage.js.map +1 -0
  110. package/app-storage.ts +54 -0
  111. package/app-style-guide.js +138 -0
  112. package/app-style-guide.js.map +1 -0
  113. package/app-style-guide.ts +195 -0
  114. package/app-subs.js +89 -0
  115. package/app-subs.js.map +1 -0
  116. package/app-subs.ts +110 -0
  117. package/app-tests.js +54 -0
  118. package/app-tests.js.map +1 -0
  119. package/app-tests.ts +56 -0
  120. package/app-tile.js +209 -0
  121. package/app-tile.js.map +1 -0
  122. package/app-tile.ts +227 -0
  123. package/app-transfer.js +188 -0
  124. package/app-transfer.js.map +1 -0
  125. package/app-transfer.ts +281 -0
  126. package/app-vocab.js +52 -0
  127. package/app-vocab.js.map +1 -0
  128. package/app-vocab.ts +43 -0
  129. package/app-words.js +55 -0
  130. package/app-words.js.map +1 -0
  131. package/app-words.ts +73 -0
  132. package/app-worker.js +28 -0
  133. package/app-worker.js.map +1 -0
  134. package/app-worker.ts +38 -0
  135. package/app-writes.js +132 -0
  136. package/app-writes.js.map +1 -0
  137. package/app-writes.ts +128 -0
  138. package/asset-bytes.js +57 -0
  139. package/asset-bytes.js.map +1 -0
  140. package/asset-bytes.ts +90 -0
  141. package/asset-response.js +28 -0
  142. package/asset-response.js.map +1 -0
  143. package/asset-response.ts +46 -0
  144. package/asset-url.js +556 -0
  145. package/asset-url.js.map +1 -0
  146. package/asset-url.ts +774 -0
  147. package/attribution-vocab.js +14 -0
  148. package/attribution-vocab.js.map +1 -0
  149. package/attribution-vocab.ts +11 -0
  150. package/authorship-graph.js +8 -0
  151. package/authorship-graph.js.map +1 -0
  152. package/authorship-graph.ts +10 -0
  153. package/badge.js +98 -0
  154. package/blob-images.js +206 -0
  155. package/blob-images.js.map +1 -0
  156. package/blob-images.ts +323 -0
  157. package/blob-posters.js +125 -0
  158. package/blob-posters.js.map +1 -0
  159. package/blob-posters.ts +207 -0
  160. package/blob-routes.js +14 -0
  161. package/blob-routes.js.map +1 -0
  162. package/blob-routes.ts +25 -0
  163. package/bots.js +77 -0
  164. package/bots.js.map +1 -0
  165. package/bots.ts +93 -0
  166. package/browser-mockup.js +81 -0
  167. package/browser-mockup.js.map +1 -0
  168. package/browser-mockup.ts +105 -0
  169. package/browser-record.js +55 -0
  170. package/browser-record.js.map +1 -0
  171. package/browser-record.ts +66 -0
  172. package/browser-scroll.js +90 -0
  173. package/browser-scroll.js.map +1 -0
  174. package/browser-scroll.ts +108 -0
  175. package/browser-stream.js +79 -0
  176. package/browser-stream.js.map +1 -0
  177. package/browser-stream.ts +84 -0
  178. package/browser-trace.js +252 -0
  179. package/browser-trace.js.map +1 -0
  180. package/browser-trace.ts +330 -0
  181. package/browser-viewer.js +236 -0
  182. package/browser-viewer.js.map +1 -0
  183. package/browser-viewer.ts +233 -0
  184. package/browser-visit.js +1522 -0
  185. package/browser-visit.js.map +1 -0
  186. package/browser-visit.ts +2179 -0
  187. package/browser-wire.js +242 -0
  188. package/browser-wire.js.map +1 -0
  189. package/browser-wire.ts +262 -0
  190. package/budget.js +17 -0
  191. package/budget.js.map +1 -0
  192. package/budget.ts +42 -0
  193. package/cli.js +52 -0
  194. package/cli.js.map +1 -0
  195. package/cli.ts +55 -0
  196. package/client-modules.js +24 -0
  197. package/client-modules.js.map +1 -0
  198. package/client-modules.ts +24 -0
  199. package/client-routes.js +83 -0
  200. package/client-routes.js.map +1 -0
  201. package/client-routes.ts +104 -0
  202. package/client-words.js +62 -0
  203. package/client-words.js.map +1 -0
  204. package/client-words.ts +77 -0
  205. package/client.js +709 -0
  206. package/comp.js +2 -0
  207. package/comp.js.map +1 -0
  208. package/comp.ts +15 -0
  209. package/config.js +497 -0
  210. package/config.js.map +1 -0
  211. package/config.ts +287 -0
  212. package/connect-parts.js +107 -0
  213. package/connect-parts.js.map +1 -0
  214. package/connect-parts.ts +165 -0
  215. package/connected-activity-browser.js +301 -0
  216. package/connected-activity-browser.js.map +1 -0
  217. package/connected-activity-browser.ts +341 -0
  218. package/connected-activity-view.js +55 -0
  219. package/connected-activity-view.js.map +1 -0
  220. package/connected-activity-view.ts +81 -0
  221. package/connected-activity-wire.js +165 -0
  222. package/connected-activity-wire.js.map +1 -0
  223. package/connected-activity-wire.ts +171 -0
  224. package/connected-activity.css +156 -0
  225. package/connected-activity.js +185 -0
  226. package/connected-activity.js.map +1 -0
  227. package/connected-activity.ts +278 -0
  228. package/connection-icon-browser.js +50 -0
  229. package/connection-icon-browser.js.map +1 -0
  230. package/connection-icon-browser.ts +52 -0
  231. package/connections-browser.js +393 -0
  232. package/connections-browser.js.map +1 -0
  233. package/connections-browser.ts +465 -0
  234. package/connections-page.js +178 -0
  235. package/connections-page.js.map +1 -0
  236. package/connections-page.ts +461 -0
  237. package/connections-view.js +1215 -0
  238. package/connections-view.js.map +1 -0
  239. package/connections-view.ts +2239 -0
  240. package/connector-upload.js +94 -0
  241. package/connector-upload.js.map +1 -0
  242. package/connector-upload.ts +146 -0
  243. package/consent.js +2 -0
  244. package/consent.js.map +1 -0
  245. package/consent.ts +3 -0
  246. package/cookie.js +53 -0
  247. package/cookie.js.map +1 -0
  248. package/cookie.ts +75 -0
  249. package/copy.js +104 -0
  250. package/corner.js +226 -0
  251. package/credential-draft-move.js +154 -0
  252. package/credential-draft-move.js.map +1 -0
  253. package/credential-draft-move.ts +197 -0
  254. package/credential-draft-place.js +2 -0
  255. package/credential-draft-place.js.map +1 -0
  256. package/credential-draft-place.ts +4 -0
  257. package/credential-drafts.js +66 -0
  258. package/credential-drafts.js.map +1 -0
  259. package/credential-drafts.ts +93 -0
  260. package/dashboard-browser.js +149 -0
  261. package/dashboard-browser.js.map +1 -0
  262. package/dashboard-browser.ts +184 -0
  263. package/dashboard-view.js +293 -0
  264. package/dashboard-view.js.map +1 -0
  265. package/dashboard-view.ts +423 -0
  266. package/dashboard.js +268 -0
  267. package/dashboard.js.map +1 -0
  268. package/dashboard.ts +436 -0
  269. package/deno.json +1 -0
  270. package/describe-graph.js +8 -0
  271. package/describe-graph.js.map +1 -0
  272. package/describe-graph.ts +7 -0
  273. package/directory-derived.js +142 -0
  274. package/directory-derived.js.map +1 -0
  275. package/directory-derived.ts +198 -0
  276. package/directory-index-move.js +77 -0
  277. package/directory-index-move.js.map +1 -0
  278. package/directory-index-move.ts +59 -0
  279. package/directory-index.js +382 -0
  280. package/directory-index.js.map +1 -0
  281. package/directory-index.ts +550 -0
  282. package/directory-pages.js +41 -0
  283. package/directory-pages.js.map +1 -0
  284. package/directory-pages.ts +71 -0
  285. package/directory-route.js +129 -0
  286. package/directory-route.js.map +1 -0
  287. package/directory-route.ts +189 -0
  288. package/directory-vocab.js +58 -0
  289. package/directory-vocab.js.map +1 -0
  290. package/directory-vocab.ts +46 -0
  291. package/document-graph.js +86 -0
  292. package/document-graph.js.map +1 -0
  293. package/document-graph.ts +93 -0
  294. package/document-ocr.js +146 -0
  295. package/document-ocr.js.map +1 -0
  296. package/document-ocr.ts +204 -0
  297. package/documents.js +50 -0
  298. package/documents.js.map +1 -0
  299. package/documents.ts +64 -0
  300. package/domain-pages.js +221 -0
  301. package/domain-pages.js.map +1 -0
  302. package/domain-pages.ts +586 -0
  303. package/domain-settings.js +88 -0
  304. package/domain-settings.js.map +1 -0
  305. package/domain-settings.ts +132 -0
  306. package/domain-transfer.js +138 -0
  307. package/domain-transfer.js.map +1 -0
  308. package/domain-transfer.ts +190 -0
  309. package/donation-loans.js +176 -0
  310. package/donation-loans.js.map +1 -0
  311. package/donation-loans.ts +271 -0
  312. package/draft-choice.js +136 -0
  313. package/draft-choice.js.map +1 -0
  314. package/draft-choice.ts +310 -0
  315. package/drawing.js +27 -0
  316. package/drawing.js.map +1 -0
  317. package/drawing.ts +40 -0
  318. package/early-report.js +18 -0
  319. package/early-report.js.map +1 -0
  320. package/early-report.ts +31 -0
  321. package/edit-client-path.js +2 -0
  322. package/edit-client-path.js.map +1 -0
  323. package/edit-client-path.ts +1 -0
  324. package/edit-mode.js +920 -0
  325. package/edit-mode.js.map +1 -0
  326. package/edit-mode.ts +1003 -0
  327. package/edit-sync.js +61 -0
  328. package/edit-sync.js.map +1 -0
  329. package/edit-sync.ts +83 -0
  330. package/edit.js +265 -0
  331. package/embed-graph.js +11 -0
  332. package/embed-graph.js.map +1 -0
  333. package/embed-graph.ts +8 -0
  334. package/embedded-payment.js +211 -0
  335. package/embedded-payment.js.map +1 -0
  336. package/embedded-payment.ts +290 -0
  337. package/entry-actions-browser.js +43 -0
  338. package/entry-actions-browser.js.map +1 -0
  339. package/entry-actions-browser.ts +64 -0
  340. package/entry-actions.js +56 -0
  341. package/entry-actions.js.map +1 -0
  342. package/entry-actions.ts +59 -0
  343. package/escape.js +14 -0
  344. package/escape.js.map +1 -0
  345. package/escape.ts +24 -0
  346. package/face-input.js +6 -0
  347. package/face-input.js.map +1 -0
  348. package/face-input.ts +14 -0
  349. package/facebook.js +370 -0
  350. package/facebook.js.map +1 -0
  351. package/facebook.ts +474 -0
  352. package/facets.js +142 -0
  353. package/facets.js.map +1 -0
  354. package/facets.ts +89 -0
  355. package/fee.js +45 -0
  356. package/fee.js.map +1 -0
  357. package/fee.ts +51 -0
  358. package/fence.js +164 -0
  359. package/fence.js.map +1 -0
  360. package/fence.ts +223 -0
  361. package/file-metadata.js +135 -0
  362. package/file-metadata.js.map +1 -0
  363. package/file-metadata.ts +177 -0
  364. package/file-operation.js +51 -0
  365. package/file-operation.js.map +1 -0
  366. package/file-operation.ts +32 -0
  367. package/file-redirects.js +72 -0
  368. package/file-redirects.js.map +1 -0
  369. package/file-redirects.ts +74 -0
  370. package/file-root.js +8 -0
  371. package/file-root.js.map +1 -0
  372. package/file-root.ts +24 -0
  373. package/files-routes.js +203 -0
  374. package/files-routes.js.map +1 -0
  375. package/files-routes.ts +282 -0
  376. package/files.js +369 -0
  377. package/files.js.map +1 -0
  378. package/files.ts +522 -0
  379. package/fingerprint.js +217 -0
  380. package/fingerprint.js.map +1 -0
  381. package/fingerprint.ts +314 -0
  382. package/firsts.js +335 -0
  383. package/firsts.js.map +1 -0
  384. package/firsts.ts +368 -0
  385. package/friends-at.js +78 -0
  386. package/friends-at.js.map +1 -0
  387. package/friends-at.ts +115 -0
  388. package/friends-browser.js +66 -0
  389. package/friends-browser.js.map +1 -0
  390. package/friends-browser.ts +77 -0
  391. package/friends-dock-browser.js +375 -0
  392. package/friends-dock-browser.js.map +1 -0
  393. package/friends-dock-browser.ts +408 -0
  394. package/friends-dock-view.js +363 -0
  395. package/friends-dock-view.js.map +1 -0
  396. package/friends-dock-view.ts +592 -0
  397. package/friends-view.js +33 -0
  398. package/friends-view.js.map +1 -0
  399. package/friends-view.ts +69 -0
  400. package/friends.js +153 -0
  401. package/friends.js.map +1 -0
  402. package/friends.ts +200 -0
  403. package/fundraising-orders.js +197 -0
  404. package/fundraising-orders.js.map +1 -0
  405. package/fundraising-orders.ts +283 -0
  406. package/fundraising.js +165 -0
  407. package/fundraising.js.map +1 -0
  408. package/fundraising.ts +215 -0
  409. package/funnel.js +141 -0
  410. package/funnel.js.map +1 -0
  411. package/funnel.ts +284 -0
  412. package/gift-savings.js +19 -0
  413. package/gift-savings.js.map +1 -0
  414. package/gift-savings.ts +29 -0
  415. package/git-history.js +331 -0
  416. package/git-history.js.map +1 -0
  417. package/git-history.ts +481 -0
  418. package/giving-browser.js +35 -0
  419. package/giving-browser.js.map +1 -0
  420. package/giving-browser.ts +40 -0
  421. package/giving-pages.js +284 -0
  422. package/giving-pages.js.map +1 -0
  423. package/giving-pages.ts +418 -0
  424. package/giving-view.js +244 -0
  425. package/giving-view.js.map +1 -0
  426. package/giving-view.ts +509 -0
  427. package/giving.js +198 -0
  428. package/giving.js.map +1 -0
  429. package/giving.ts +280 -0
  430. package/gmail-mailbox.js +52 -0
  431. package/gmail-mailbox.js.map +1 -0
  432. package/gmail-mailbox.ts +74 -0
  433. package/graves.js +136 -0
  434. package/graves.js.map +1 -0
  435. package/graves.ts +180 -0
  436. package/hashed.js +499 -0
  437. package/hashed.js.map +1 -0
  438. package/hashed.ts +676 -0
  439. package/home/assets.js +15 -0
  440. package/home/assets.js.map +1 -0
  441. package/home/assets.ts +16 -0
  442. package/home/brands/stripe.svg +12 -0
  443. package/home/brands/zoom.svg +34 -0
  444. package/home/demos.js +413 -0
  445. package/home/demos.js.map +1 -0
  446. package/home/demos.ts +431 -0
  447. package/home/games.js +112 -0
  448. package/home/games.js.map +1 -0
  449. package/home/games.ts +137 -0
  450. package/home/icons.js +41 -0
  451. package/home/icons.js.map +1 -0
  452. package/home/icons.ts +42 -0
  453. package/home/mascot/calculating.webp +0 -0
  454. package/home/mascot/flag.webp +0 -0
  455. package/home/mascot/letter.webp +0 -0
  456. package/home/mascot/plane.webp +0 -0
  457. package/home/mascot/plug.webp +0 -0
  458. package/home/mascot/thinking.webp +0 -0
  459. package/home/mascot/typing.webp +0 -0
  460. package/home/mascot/wave.webp +0 -0
  461. package/home/mod.tsx +517 -0
  462. package/home/parts.js +149 -0
  463. package/home/parts.js.map +1 -0
  464. package/home/parts.ts +45 -0
  465. package/home/phone.tsx +152 -0
  466. package/home/scenes.tsx +212 -0
  467. package/home/sky.js +930 -0
  468. package/home/sky.tsx +479 -0
  469. package/home/story.js +392 -0
  470. package/home/style.css +1304 -0
  471. package/home/words.js +2 -0
  472. package/home/words.js.map +1 -0
  473. package/home/words.ts +8 -0
  474. package/home/yak.js +146 -0
  475. package/home/yak_test.tsx +111 -0
  476. package/home-router.js +30 -0
  477. package/home-router.js.map +1 -0
  478. package/home-router.ts +41 -0
  479. package/host.js +58 -0
  480. package/host.js.map +1 -0
  481. package/host.ts +97 -0
  482. package/hosted-page.js +126 -0
  483. package/hosted-page.js.map +1 -0
  484. package/hosted-page.ts +295 -0
  485. package/install-browser.js +89 -0
  486. package/install-browser.js.map +1 -0
  487. package/install-browser.ts +99 -0
  488. package/install-icons.js +271 -0
  489. package/install-icons.js.map +1 -0
  490. package/install-icons.ts +366 -0
  491. package/installs.js +197 -0
  492. package/installs.js.map +1 -0
  493. package/installs.ts +270 -0
  494. package/instrument.js +50 -0
  495. package/instrument.js.map +1 -0
  496. package/instrument.ts +55 -0
  497. package/integration-icons.js +138 -0
  498. package/integration-icons.js.map +1 -0
  499. package/integration-icons.ts +198 -0
  500. package/interaction-browser.js +95 -0
  501. package/interaction-browser.js.map +1 -0
  502. package/interaction-browser.ts +107 -0
  503. package/interaction-report.js +399 -0
  504. package/interaction-report.js.map +1 -0
  505. package/interaction-report.ts +450 -0
  506. package/interaction.js +273 -0
  507. package/interaction.js.map +1 -0
  508. package/interaction.ts +290 -0
  509. package/invite-browser.js +98 -0
  510. package/invite-browser.js.map +1 -0
  511. package/invite-browser.ts +123 -0
  512. package/invite-view.js +100 -0
  513. package/invite-view.js.map +1 -0
  514. package/invite-view.ts +137 -0
  515. package/kept.js +520 -0
  516. package/kept.js.map +1 -0
  517. package/kept.ts +821 -0
  518. package/kills-graph.js +18 -0
  519. package/kills-graph.js.map +1 -0
  520. package/kills-graph.ts +16 -0
  521. package/ladder.js +418 -0
  522. package/ladder.js.map +1 -0
  523. package/ladder.ts +510 -0
  524. package/lenses-graph.js +24 -0
  525. package/lenses-graph.js.map +1 -0
  526. package/lenses-graph.ts +27 -0
  527. package/lenses.js +197 -0
  528. package/lenses.js.map +1 -0
  529. package/lenses.ts +204 -0
  530. package/lent.js +32 -0
  531. package/lent.js.map +1 -0
  532. package/lent.ts +95 -0
  533. package/letters.js +134 -0
  534. package/letters.js.map +1 -0
  535. package/letters.ts +251 -0
  536. package/lexicon-graph.js +11 -0
  537. package/lexicon-graph.js.map +1 -0
  538. package/lexicon-graph.ts +7 -0
  539. package/link-preview.js +111 -0
  540. package/link-preview.js.map +1 -0
  541. package/link-preview.ts +136 -0
  542. package/listing.js +262 -0
  543. package/listing.js.map +1 -0
  544. package/listing.ts +330 -0
  545. package/local-time.js +32 -0
  546. package/local-time.js.map +1 -0
  547. package/local-time.ts +41 -0
  548. package/located.js +380 -0
  549. package/located.js.map +1 -0
  550. package/located.ts +471 -0
  551. package/log-graph.js +7 -0
  552. package/log-graph.js.map +1 -0
  553. package/log-graph.ts +9 -0
  554. package/lower-graph.js +7 -0
  555. package/lower-graph.js.map +1 -0
  556. package/lower-graph.ts +9 -0
  557. package/mail-request.js +32 -0
  558. package/mail-request.js.map +1 -0
  559. package/mail-request.ts +29 -0
  560. package/mail-senders.js +40 -0
  561. package/mail-senders.js.map +1 -0
  562. package/mail-senders.ts +47 -0
  563. package/managed-browser-pilot.js +151 -0
  564. package/managed-browser-pilot.js.map +1 -0
  565. package/managed-browser-pilot.ts +230 -0
  566. package/managed-browser-sites.js +43 -0
  567. package/managed-browser-sites.js.map +1 -0
  568. package/managed-browser-sites.ts +41 -0
  569. package/managed-browser-wire.js +142 -0
  570. package/managed-browser-wire.js.map +1 -0
  571. package/managed-browser-wire.ts +140 -0
  572. package/managed-browser.js +529 -0
  573. package/managed-browser.js.map +1 -0
  574. package/managed-browser.ts +740 -0
  575. package/manifest.js +425 -0
  576. package/manifest.js.map +1 -0
  577. package/manifest.ts +468 -0
  578. package/metadata-effect.js +61 -0
  579. package/metadata-effect.js.map +1 -0
  580. package/metadata-effect.ts +59 -0
  581. package/meter-graph.js +205 -0
  582. package/meter-graph.js.map +1 -0
  583. package/meter-graph.ts +238 -0
  584. package/meter-vocab.js +8 -0
  585. package/meter-vocab.js.map +1 -0
  586. package/meter-vocab.ts +4 -0
  587. package/meter.js +402 -0
  588. package/meter.js.map +1 -0
  589. package/meter.ts +697 -0
  590. package/mod.js +14 -0
  591. package/mod.js.map +1 -0
  592. package/mod.ts +16 -0
  593. package/models-vocab.js +25 -0
  594. package/models-vocab.js.map +1 -0
  595. package/models-vocab.ts +15 -0
  596. package/monogram.js +32 -0
  597. package/monogram.js.map +1 -0
  598. package/monogram.ts +46 -0
  599. package/mover.js +6 -0
  600. package/mover.js.map +1 -0
  601. package/mover.ts +45 -0
  602. package/named.js +136 -0
  603. package/named.js.map +1 -0
  604. package/named.ts +169 -0
  605. package/names.js +196 -0
  606. package/names.js.map +1 -0
  607. package/names.ts +252 -0
  608. package/notices-vocab.js +20 -0
  609. package/notices-vocab.js.map +1 -0
  610. package/notices-vocab.ts +28 -0
  611. package/numbers.js +85 -0
  612. package/numbers.js.map +1 -0
  613. package/numbers.ts +97 -0
  614. package/object-hosts.js +137 -0
  615. package/object-hosts.js.map +1 -0
  616. package/object-hosts.ts +153 -0
  617. package/open-script.js +235 -0
  618. package/open-script.js.map +1 -0
  619. package/open-script.ts +253 -0
  620. package/opening.js +31 -0
  621. package/opening.js.map +1 -0
  622. package/opening.ts +28 -0
  623. package/operator-activity-view.js +82 -0
  624. package/operator-activity-view.js.map +1 -0
  625. package/operator-activity-view.ts +85 -0
  626. package/operator-activity.js +220 -0
  627. package/operator-activity.js.map +1 -0
  628. package/operator-activity.ts +293 -0
  629. package/operator-brief.js +36 -0
  630. package/operator-brief.js.map +1 -0
  631. package/operator-brief.ts +76 -0
  632. package/operator-copy-browser.js +67 -0
  633. package/operator-copy-browser.js.map +1 -0
  634. package/operator-copy-browser.ts +71 -0
  635. package/operator-corner.js +266 -0
  636. package/operator-corner.js.map +1 -0
  637. package/operator-corner.ts +300 -0
  638. package/operator-decisions.js +19 -0
  639. package/operator-decisions.js.map +1 -0
  640. package/operator-decisions.ts +18 -0
  641. package/operator-docs.js +152 -0
  642. package/operator-docs.js.map +1 -0
  643. package/operator-docs.ts +196 -0
  644. package/operator-door.js +10 -0
  645. package/operator-door.js.map +1 -0
  646. package/operator-door.ts +14 -0
  647. package/operator-drafts-browser.js +28 -0
  648. package/operator-drafts-browser.js.map +1 -0
  649. package/operator-drafts-browser.ts +32 -0
  650. package/operator-drafts.js +60 -0
  651. package/operator-drafts.js.map +1 -0
  652. package/operator-drafts.ts +80 -0
  653. package/operator-early-draft.js +110 -0
  654. package/operator-early-draft.js.map +1 -0
  655. package/operator-early-draft.ts +125 -0
  656. package/operator-go-browser.js +130 -0
  657. package/operator-go-browser.js.map +1 -0
  658. package/operator-go-browser.ts +182 -0
  659. package/operator-go-step.js +86 -0
  660. package/operator-go-step.js.map +1 -0
  661. package/operator-go-step.ts +92 -0
  662. package/operator-go-tool.js +49 -0
  663. package/operator-go-tool.js.map +1 -0
  664. package/operator-go-tool.ts +31 -0
  665. package/operator-go.js +68 -0
  666. package/operator-go.js.map +1 -0
  667. package/operator-go.ts +100 -0
  668. package/operator-graph.js +46 -0
  669. package/operator-graph.js.map +1 -0
  670. package/operator-graph.ts +60 -0
  671. package/operator-handoff.js +91 -0
  672. package/operator-handoff.js.map +1 -0
  673. package/operator-handoff.ts +104 -0
  674. package/operator-machine.js +136 -0
  675. package/operator-machine.js.map +1 -0
  676. package/operator-machine.ts +168 -0
  677. package/operator-matches-browser.js +155 -0
  678. package/operator-matches-browser.js.map +1 -0
  679. package/operator-matches-browser.ts +178 -0
  680. package/operator-matches-view.js +147 -0
  681. package/operator-matches-view.js.map +1 -0
  682. package/operator-matches-view.ts +224 -0
  683. package/operator-matches.js +65 -0
  684. package/operator-matches.js.map +1 -0
  685. package/operator-matches.ts +120 -0
  686. package/operator-memory.js +119 -0
  687. package/operator-memory.js.map +1 -0
  688. package/operator-memory.ts +122 -0
  689. package/operator-mic.ts +40 -0
  690. package/operator-model.js +144 -0
  691. package/operator-model.js.map +1 -0
  692. package/operator-model.ts +154 -0
  693. package/operator-notes.js +32 -0
  694. package/operator-notes.js.map +1 -0
  695. package/operator-notes.ts +40 -0
  696. package/operator-opening-browser.js +184 -0
  697. package/operator-opening-browser.js.map +1 -0
  698. package/operator-opening-browser.ts +195 -0
  699. package/operator-owner.js +391 -0
  700. package/operator-owner.js.map +1 -0
  701. package/operator-owner.ts +392 -0
  702. package/operator-page-context.js +121 -0
  703. package/operator-page-context.js.map +1 -0
  704. package/operator-page-context.ts +143 -0
  705. package/operator-page-image.js +38 -0
  706. package/operator-page-image.js.map +1 -0
  707. package/operator-page-image.ts +42 -0
  708. package/operator-panel-browser.js +601 -0
  709. package/operator-panel-browser.js.map +1 -0
  710. package/operator-panel-browser.ts +669 -0
  711. package/operator-panel-view.js +69 -0
  712. package/operator-panel-view.js.map +1 -0
  713. package/operator-panel-view.ts +100 -0
  714. package/operator-panel.js +131 -0
  715. package/operator-panel.js.map +1 -0
  716. package/operator-panel.ts +155 -0
  717. package/operator-push.tsx +112 -0
  718. package/operator-record.js +55 -0
  719. package/operator-record.js.map +1 -0
  720. package/operator-record.ts +92 -0
  721. package/operator-replies.js +240 -0
  722. package/operator-replies.js.map +1 -0
  723. package/operator-replies.ts +281 -0
  724. package/operator-reply-view.js +117 -0
  725. package/operator-reply-view.js.map +1 -0
  726. package/operator-reply-view.ts +185 -0
  727. package/operator-safety.js +30 -0
  728. package/operator-safety.js.map +1 -0
  729. package/operator-safety.ts +53 -0
  730. package/operator-settings-browser.js +257 -0
  731. package/operator-settings-browser.js.map +1 -0
  732. package/operator-settings-browser.ts +290 -0
  733. package/operator-settings-view.js +291 -0
  734. package/operator-settings-view.js.map +1 -0
  735. package/operator-settings-view.ts +588 -0
  736. package/operator-settings.js +79 -0
  737. package/operator-settings.js.map +1 -0
  738. package/operator-settings.ts +137 -0
  739. package/operator-source.js +43 -0
  740. package/operator-source.js.map +1 -0
  741. package/operator-source.ts +69 -0
  742. package/operator-talk-browser.js +94 -0
  743. package/operator-talk-browser.js.map +1 -0
  744. package/operator-talk-browser.ts +120 -0
  745. package/operator-talk.js +83 -0
  746. package/operator-talk.js.map +1 -0
  747. package/operator-talk.ts +127 -0
  748. package/operator-task-text.js +45 -0
  749. package/operator-task-text.js.map +1 -0
  750. package/operator-task-text.ts +49 -0
  751. package/operator-timing-browser.js +51 -0
  752. package/operator-timing-browser.js.map +1 -0
  753. package/operator-timing-browser.ts +68 -0
  754. package/operator-timing-view.js +48 -0
  755. package/operator-timing-view.js.map +1 -0
  756. package/operator-timing-view.ts +90 -0
  757. package/operator-timing.js +132 -0
  758. package/operator-timing.js.map +1 -0
  759. package/operator-timing.ts +170 -0
  760. package/operator-vocab.js +8 -0
  761. package/operator-vocab.js.map +1 -0
  762. package/operator-vocab.ts +7 -0
  763. package/operator-voice-audio.ts +84 -0
  764. package/operator-voice-browser.ts +237 -0
  765. package/operator-voice-feedback.js +108 -0
  766. package/operator-voice-feedback.js.map +1 -0
  767. package/operator-voice-feedback.ts +133 -0
  768. package/operator-voice-view.js +33 -0
  769. package/operator-voice-view.js.map +1 -0
  770. package/operator-voice-view.ts +43 -0
  771. package/operator-voice.css +38 -0
  772. package/operator-voice.js +35 -0
  773. package/operator-voice.js.map +1 -0
  774. package/operator-voice.ts +33 -0
  775. package/operator-wait.js +70 -0
  776. package/operator-wait.js.map +1 -0
  777. package/operator-wait.ts +79 -0
  778. package/operator-watches.js +126 -0
  779. package/operator-watches.js.map +1 -0
  780. package/operator-watches.ts +141 -0
  781. package/operator-words.js +94 -0
  782. package/operator-words.js.map +1 -0
  783. package/operator-words.ts +114 -0
  784. package/outreach-trial.js +103 -0
  785. package/outreach-trial.js.map +1 -0
  786. package/outreach-trial.ts +122 -0
  787. package/outreach-vocab.js +10 -0
  788. package/outreach-vocab.js.map +1 -0
  789. package/outreach-vocab.ts +7 -0
  790. package/outreach.js +162 -0
  791. package/outreach.js.map +1 -0
  792. package/outreach.ts +239 -0
  793. package/package.json +1131 -4
  794. package/packs.js +103 -0
  795. package/packs.js.map +1 -0
  796. package/packs.ts +119 -0
  797. package/page-copy.js +267 -0
  798. package/page-copy.js.map +1 -0
  799. package/page-copy.ts +362 -0
  800. package/page-graph.js +114 -0
  801. package/page-graph.js.map +1 -0
  802. package/page-graph.ts +151 -0
  803. package/page-links.js +78 -0
  804. package/page-links.js.map +1 -0
  805. package/page-links.ts +124 -0
  806. package/page-parts.js +236 -0
  807. package/page-parts.js.map +1 -0
  808. package/page-parts.ts +388 -0
  809. package/page-query.js +95 -0
  810. package/page-query.js.map +1 -0
  811. package/page-query.ts +120 -0
  812. package/page-script.js +183 -0
  813. package/page-script.js.map +1 -0
  814. package/page-script.ts +192 -0
  815. package/page-wire.js +93 -0
  816. package/page-wire.js.map +1 -0
  817. package/page-wire.ts +100 -0
  818. package/pages-vocab.js +9 -0
  819. package/pages-vocab.js.map +1 -0
  820. package/pages-vocab.ts +5 -0
  821. package/partials.js +21 -0
  822. package/partials.js.map +1 -0
  823. package/partials.ts +37 -0
  824. package/payment-browser.js +250 -0
  825. package/payment-browser.js.map +1 -0
  826. package/payment-browser.ts +298 -0
  827. package/payment-rows.js +117 -0
  828. package/payment-rows.js.map +1 -0
  829. package/payment-rows.ts +219 -0
  830. package/payment-view.js +397 -0
  831. package/payment-view.js.map +1 -0
  832. package/payment-view.ts +852 -0
  833. package/people-browser.js +186 -0
  834. package/people-browser.js.map +1 -0
  835. package/people-browser.ts +210 -0
  836. package/people-rows.js +192 -0
  837. package/people-rows.js.map +1 -0
  838. package/people-rows.ts +289 -0
  839. package/people-view.js +463 -0
  840. package/people-view.js.map +1 -0
  841. package/people-view.ts +804 -0
  842. package/person-lines.js +196 -0
  843. package/person-lines.js.map +1 -0
  844. package/person-lines.ts +256 -0
  845. package/place.js +30 -0
  846. package/place.js.map +1 -0
  847. package/place.ts +31 -0
  848. package/plan-details.js +39 -0
  849. package/plan-details.js.map +1 -0
  850. package/plan-details.ts +57 -0
  851. package/plan-trial-graph.js +63 -0
  852. package/plan-trial-graph.js.map +1 -0
  853. package/plan-trial-graph.ts +57 -0
  854. package/plans.js +223 -0
  855. package/plans.js.map +1 -0
  856. package/plans.ts +313 -0
  857. package/platform-credentials.js +136 -0
  858. package/platform-credentials.js.map +1 -0
  859. package/platform-credentials.ts +189 -0
  860. package/poster-backfill.js +72 -0
  861. package/poster-backfill.js.map +1 -0
  862. package/poster-backfill.ts +96 -0
  863. package/presence.js +57 -0
  864. package/presence.js.map +1 -0
  865. package/presence.ts +77 -0
  866. package/preview-audit.js +65 -0
  867. package/preview-audit.js.map +1 -0
  868. package/preview-audit.ts +126 -0
  869. package/preview-fit.js +62 -0
  870. package/preview-fit.js.map +1 -0
  871. package/preview-fit.ts +72 -0
  872. package/preview-html.js +96 -0
  873. package/preview-html.js.map +1 -0
  874. package/preview-html.ts +139 -0
  875. package/preview.js +317 -0
  876. package/preview.js.map +1 -0
  877. package/preview.ts +498 -0
  878. package/price.js +53 -0
  879. package/price.js.map +1 -0
  880. package/price.ts +85 -0
  881. package/profile-browser.js +117 -0
  882. package/profile-browser.js.map +1 -0
  883. package/profile-browser.ts +141 -0
  884. package/profile-view.js +96 -0
  885. package/profile-view.js.map +1 -0
  886. package/profile-view.ts +197 -0
  887. package/provider-credits.js +159 -0
  888. package/provider-credits.js.map +1 -0
  889. package/provider-credits.ts +174 -0
  890. package/public-site-choice.js +18 -0
  891. package/public-site-choice.js.map +1 -0
  892. package/public-site-choice.ts +21 -0
  893. package/public-site.js +151 -0
  894. package/public-site.js.map +1 -0
  895. package/public-site.ts +268 -0
  896. package/publishing-graph.js +136 -0
  897. package/publishing-graph.js.map +1 -0
  898. package/publishing-graph.ts +122 -0
  899. package/qr.js +32 -0
  900. package/qr.js.map +1 -0
  901. package/qr.ts +32 -0
  902. package/query-page.js +159 -0
  903. package/query-page.js.map +1 -0
  904. package/query-page.ts +249 -0
  905. package/query-refusal.js +174 -0
  906. package/query-refusal.js.map +1 -0
  907. package/query-refusal.ts +319 -0
  908. package/refusal-loop.js +71 -0
  909. package/refusal-loop.js.map +1 -0
  910. package/refusal-loop.ts +98 -0
  911. package/refusals-vocab.js +9 -0
  912. package/refusals-vocab.js.map +1 -0
  913. package/refusals-vocab.ts +5 -0
  914. package/refused-writes.js +119 -0
  915. package/refused-writes.js.map +1 -0
  916. package/refused-writes.ts +152 -0
  917. package/refused.js +67 -0
  918. package/refused.js.map +1 -0
  919. package/refused.ts +76 -0
  920. package/regional-route-storage.js +127 -0
  921. package/regional-route-storage.js.map +1 -0
  922. package/regional-route-storage.ts +94 -0
  923. package/regional-route.js +105 -0
  924. package/regional-route.js.map +1 -0
  925. package/regional-route.ts +158 -0
  926. package/regional-serving-copy.js +153 -0
  927. package/regional-serving-copy.js.map +1 -0
  928. package/regional-serving-copy.ts +200 -0
  929. package/release-asset.js +71 -0
  930. package/release-asset.js.map +1 -0
  931. package/release-asset.ts +121 -0
  932. package/release-browser.js +383 -0
  933. package/release-code.js +5 -0
  934. package/release-entry.js +3 -0
  935. package/release-file.js +169 -0
  936. package/release-file.js.map +1 -0
  937. package/release-file.ts +241 -0
  938. package/release-index.js +140 -0
  939. package/release-index.js.map +1 -0
  940. package/release-index.ts +161 -0
  941. package/release-page.js +227 -0
  942. package/release-reads.js +27 -0
  943. package/release-reads.js.map +1 -0
  944. package/release-reads.ts +56 -0
  945. package/release-sheets.js +76 -0
  946. package/release-state.js +181 -0
  947. package/release-update.js +22 -0
  948. package/release-update.js.map +1 -0
  949. package/release-update.ts +29 -0
  950. package/release.js +50 -0
  951. package/release.js.map +1 -0
  952. package/release.ts +72 -0
  953. package/released.js +263 -0
  954. package/released.js.map +1 -0
  955. package/released.ts +310 -0
  956. package/remake-graph.js +17 -0
  957. package/remake-graph.js.map +1 -0
  958. package/remake-graph.ts +15 -0
  959. package/rouse-graph.js +11 -0
  960. package/rouse-graph.js.map +1 -0
  961. package/rouse-graph.ts +8 -0
  962. package/route-memory.js +101 -0
  963. package/route-memory.js.map +1 -0
  964. package/route-memory.ts +132 -0
  965. package/routes.js +1143 -0
  966. package/routes.js.map +1 -0
  967. package/routes.ts +1502 -0
  968. package/sale-recovery.js +175 -0
  969. package/sale-recovery.js.map +1 -0
  970. package/sale-recovery.ts +156 -0
  971. package/sales.js +113 -0
  972. package/sales.js.map +1 -0
  973. package/sales.ts +150 -0
  974. package/schema.js +28 -0
  975. package/schema.js.map +1 -0
  976. package/schema.ts +13 -0
  977. package/serving-copy.js +161 -0
  978. package/serving-copy.js.map +1 -0
  979. package/serving-copy.ts +201 -0
  980. package/settings-drafts-browser.js +81 -0
  981. package/settings-drafts-browser.js.map +1 -0
  982. package/settings-drafts-browser.ts +95 -0
  983. package/settings-drafts.js +119 -0
  984. package/settings-drafts.js.map +1 -0
  985. package/settings-drafts.ts +136 -0
  986. package/shared-browser.js +61 -0
  987. package/shared-browser.js.map +1 -0
  988. package/shared-browser.ts +77 -0
  989. package/shared-view.js +29 -0
  990. package/shared-view.js.map +1 -0
  991. package/shared-view.ts +47 -0
  992. package/side-browser.js +164 -0
  993. package/side-browser.js.map +1 -0
  994. package/side-browser.ts +201 -0
  995. package/side-parts.js +258 -0
  996. package/side-parts.js.map +1 -0
  997. package/side-parts.ts +447 -0
  998. package/side-rows.js +64 -0
  999. package/side-rows.js.map +1 -0
  1000. package/side-rows.ts +104 -0
  1001. package/signed-in.js +37 -0
  1002. package/signed-in.js.map +1 -0
  1003. package/signed-in.ts +45 -0
  1004. package/site-assets.js +8 -0
  1005. package/site-assets.js.map +1 -0
  1006. package/site-assets.ts +25 -0
  1007. package/site-header.js +65 -0
  1008. package/site-header.js.map +1 -0
  1009. package/site-header.ts +71 -0
  1010. package/site-nav.js +75 -0
  1011. package/site-nav.js.map +1 -0
  1012. package/site-nav.ts +82 -0
  1013. package/site-validation.js +37 -0
  1014. package/site-validation.js.map +1 -0
  1015. package/site-validation.ts +47 -0
  1016. package/space-apps-browser.js +107 -0
  1017. package/space-apps-browser.js.map +1 -0
  1018. package/space-apps-browser.ts +128 -0
  1019. package/space-apps-view.js +222 -0
  1020. package/space-apps-view.js.map +1 -0
  1021. package/space-apps-view.ts +396 -0
  1022. package/space-apps.js +88 -0
  1023. package/space-apps.js.map +1 -0
  1024. package/space-apps.ts +143 -0
  1025. package/space-logo.js +82 -0
  1026. package/space-logo.js.map +1 -0
  1027. package/space-logo.ts +112 -0
  1028. package/space-pages-browser.js +474 -0
  1029. package/space-pages-browser.js.map +1 -0
  1030. package/space-pages-browser.ts +463 -0
  1031. package/space-pages-view.js +212 -0
  1032. package/space-pages-view.js.map +1 -0
  1033. package/space-pages-view.ts +460 -0
  1034. package/space-pages.js +193 -0
  1035. package/space-pages.js.map +1 -0
  1036. package/space-pages.ts +282 -0
  1037. package/space-switch.js +36 -0
  1038. package/space-switch.js.map +1 -0
  1039. package/space-switch.ts +64 -0
  1040. package/splash.js +510 -0
  1041. package/splash.js.map +1 -0
  1042. package/splash.ts +525 -0
  1043. package/standing.js +409 -0
  1044. package/standing.js.map +1 -0
  1045. package/standing.ts +746 -0
  1046. package/still.js +63 -0
  1047. package/still.js.map +1 -0
  1048. package/still.ts +95 -0
  1049. package/store-listing.js +107 -0
  1050. package/store-listing.js.map +1 -0
  1051. package/store-listing.ts +133 -0
  1052. package/store-wake.js +65 -0
  1053. package/store-wake.js.map +1 -0
  1054. package/store-wake.ts +101 -0
  1055. package/stream-posters.js +177 -0
  1056. package/stream-posters.js.map +1 -0
  1057. package/stream-posters.ts +297 -0
  1058. package/support-contract-service.js +219 -0
  1059. package/support-contract-service.js.map +1 -0
  1060. package/support-contract-service.ts +307 -0
  1061. package/support-contract-view.js +155 -0
  1062. package/support-contract-view.js.map +1 -0
  1063. package/support-contract-view.ts +265 -0
  1064. package/support-contract.js +114 -0
  1065. package/support-contract.js.map +1 -0
  1066. package/support-contract.ts +157 -0
  1067. package/sweep-vocab.js +10 -0
  1068. package/sweep-vocab.js.map +1 -0
  1069. package/sweep-vocab.ts +9 -0
  1070. package/talk-views-browser.js +208 -0
  1071. package/talk-views-browser.js.map +1 -0
  1072. package/talk-views-browser.ts +232 -0
  1073. package/talk-views.js +36 -0
  1074. package/talk-views.js.map +1 -0
  1075. package/talk-views.ts +64 -0
  1076. package/task-rows.js +86 -0
  1077. package/task-rows.js.map +1 -0
  1078. package/task-rows.ts +96 -0
  1079. package/tasks-view.js +111 -0
  1080. package/tasks-view.js.map +1 -0
  1081. package/tasks-view.ts +176 -0
  1082. package/toast.ts +17 -0
  1083. package/trash-graph.js +41 -0
  1084. package/trash-graph.js.map +1 -0
  1085. package/trash-graph.ts +27 -0
  1086. package/trash-vocab.js +8 -0
  1087. package/trash-vocab.js.map +1 -0
  1088. package/trash-vocab.ts +4 -0
  1089. package/trial.js +325 -0
  1090. package/trial.js.map +1 -0
  1091. package/trial.ts +451 -0
  1092. package/update-rows.js +77 -0
  1093. package/update-rows.js.map +1 -0
  1094. package/update-rows.ts +171 -0
  1095. package/update-waiting.js +131 -0
  1096. package/update-waiting.js.map +1 -0
  1097. package/update-waiting.ts +133 -0
  1098. package/updates-browser.js +28 -0
  1099. package/updates-browser.js.map +1 -0
  1100. package/updates-browser.ts +33 -0
  1101. package/updates-day-browser.js +77 -0
  1102. package/updates-day-browser.js.map +1 -0
  1103. package/updates-day-browser.ts +84 -0
  1104. package/updates-day.js +60 -0
  1105. package/updates-day.js.map +1 -0
  1106. package/updates-day.ts +94 -0
  1107. package/updates-list-browser.js +175 -0
  1108. package/updates-list-browser.js.map +1 -0
  1109. package/updates-list-browser.ts +198 -0
  1110. package/updates-view.js +546 -0
  1111. package/updates-view.js.map +1 -0
  1112. package/updates-view.ts +814 -0
  1113. package/upload-client-path.js +5 -0
  1114. package/upload-client-path.js.map +1 -0
  1115. package/upload-client-path.ts +4 -0
  1116. package/uploads.js +290 -0
  1117. package/uploads.js.map +1 -0
  1118. package/uploads.ts +334 -0
  1119. package/upstream.js +40 -0
  1120. package/upstream.js.map +1 -0
  1121. package/upstream.ts +57 -0
  1122. package/version-view.js +57 -0
  1123. package/version-view.js.map +1 -0
  1124. package/version-view.ts +99 -0
  1125. package/versions.js +231 -0
  1126. package/versions.js.map +1 -0
  1127. package/versions.ts +367 -0
  1128. package/visit-counts.js +123 -0
  1129. package/visit-counts.js.map +1 -0
  1130. package/visit-counts.ts +162 -0
  1131. package/visitor-location.js +33 -0
  1132. package/visitor-location.js.map +1 -0
  1133. package/visitor-location.ts +38 -0
  1134. package/visitor.js +152 -0
  1135. package/visitor.js.map +1 -0
  1136. package/visitor.ts +228 -0
  1137. package/visits-browser.js +71 -0
  1138. package/visits-browser.js.map +1 -0
  1139. package/visits-browser.ts +87 -0
  1140. package/visits-view.js +88 -0
  1141. package/visits-view.js.map +1 -0
  1142. package/visits-view.ts +184 -0
  1143. package/visits.js +428 -0
  1144. package/visits.js.map +1 -0
  1145. package/visits.ts +561 -0
  1146. package/vocab/account.vocab.json +349 -0
  1147. package/vocab/agents.vocab.json +64 -0
  1148. package/vocab/app-canvas.vocab.json +137 -0
  1149. package/vocab/app-friends.vocab.json +71 -0
  1150. package/vocab/app-permissions.vocab.json +46 -0
  1151. package/vocab/apps.vocab.json +553 -0
  1152. package/vocab/attribution.vocab.json +32 -0
  1153. package/vocab/builder-install.vocab.json +10 -0
  1154. package/vocab/connections.vocab.json +128 -0
  1155. package/vocab/dashboard.vocab.json +148 -0
  1156. package/vocab/directory.vocab.json +2445 -0
  1157. package/vocab/exception.vocab.json +18 -0
  1158. package/vocab/fundraising.vocab.json +284 -0
  1159. package/vocab/gmail-mailbox.vocab.json +73 -0
  1160. package/vocab/kernel.vocab.json +420 -0
  1161. package/vocab/mcp-retirement.vocab.json +66 -0
  1162. package/vocab/meter.vocab.json +230 -0
  1163. package/vocab/models-install.vocab.json +10 -0
  1164. package/vocab/notices.vocab.json +88 -0
  1165. package/vocab/operator-drafts.vocab.json +19 -0
  1166. package/vocab/operator-matches.vocab.json +85 -0
  1167. package/vocab/operator-settings.vocab.json +127 -0
  1168. package/vocab/operator-talk.vocab.json +92 -0
  1169. package/vocab/operator.vocab.json +1314 -0
  1170. package/vocab/outreach.vocab.json +141 -0
  1171. package/vocab/pages.vocab.json +38 -0
  1172. package/vocab/payment.vocab.json +271 -0
  1173. package/vocab/people.vocab.json +337 -0
  1174. package/vocab/presence.vocab.json +19 -0
  1175. package/vocab/preview.vocab.json +66 -0
  1176. package/vocab/referenced.vocab.json +17 -0
  1177. package/vocab/referral.vocab.json +272 -0
  1178. package/vocab/refusals.vocab.json +16 -0
  1179. package/vocab/registration.vocab.json +17 -0
  1180. package/vocab/serving.vocab.json +103 -0
  1181. package/vocab/side.vocab.json +97 -0
  1182. package/vocab/space-apps.vocab.json +137 -0
  1183. package/vocab/space-pages.vocab.json +416 -0
  1184. package/vocab/sweep-install.vocab.json +10 -0
  1185. package/vocab/sweep.vocab.json +125 -0
  1186. package/vocab/trash.vocab.json +19 -0
  1187. package/vocab/update.vocab.json +53 -0
  1188. package/vocab/upload.vocab.json +69 -0
  1189. package/vocab/use.vocab.json +93 -0
  1190. package/vocab/visits.vocab.json +143 -0
  1191. package/vocab/waiting.vocab.json +29 -0
  1192. package/vocab.js +16 -0
  1193. package/vocab.js.map +1 -0
  1194. package/vocab.json +1703 -0
  1195. package/vocab.ts +17 -0
  1196. package/weigh-graph.js +12 -0
  1197. package/weigh-graph.js.map +1 -0
  1198. package/weigh-graph.ts +9 -0
  1199. package/wire-news.js +30 -0
  1200. package/wire-news.js.map +1 -0
  1201. package/wire-news.ts +30 -0
  1202. package/work-standing.js +64 -0
  1203. package/work-standing.js.map +1 -0
  1204. package/work-standing.ts +44 -0
  1205. package/woven.js +435 -0
  1206. package/woven.js.map +1 -0
  1207. package/woven.ts +649 -0
  1208. package/wrap-graph.js +17 -0
  1209. package/wrap-graph.js.map +1 -0
  1210. package/wrap-graph.ts +15 -0
  1211. package/write-owner.js +11 -0
  1212. package/write-owner.js.map +1 -0
  1213. package/write-owner.ts +24 -0
package/routes.ts ADDED
@@ -0,0 +1,1502 @@
1
+ /**
2
+ * `@yaks/platform/routes` — where a request is going, read from its hostname
3
+ * and path and nothing else (D-32318 §Routing). The apex `yaks.app` is the
4
+ * platform's own face; `<space>.yaks.app/<app>/…` is an app in a space. On
5
+ * loopback, an explicit LOCAL_DEV=1 lets `x-yak-host` stand in for a hostname
6
+ * a local test cannot send (fetch refuses a Host header). Deployed hosts
7
+ * always ignore the header. Pure: only the configured host, no store.
8
+ *
9
+ * ```ts
10
+ * import { route } from '@yaks/platform/routes'
11
+ * import { assertEquals } from '@std/assert'
12
+ * assertEquals(route('ada.yaks.app', '/menu/soup'), {
13
+ * space: 'ada',
14
+ * app: 'menu',
15
+ * path: '/soup',
16
+ * })
17
+ * ```
18
+ *
19
+ * @module
20
+ */
21
+ import { knocks } from '@yaks/git/address'
22
+ import { upgrading } from './app-outbound.js'
23
+ import { apex, type Host, spaceHost, url } from './host.js'
24
+ import { letter, monogram } from './monogram.js'
25
+ import { PLATFORM, RESERVED, ROOT, SLUG } from './names.js'
26
+ import type { LogoSize } from './space-logo.ts'
27
+ import { releaseId } from './versions.js'
28
+
29
+ /** A request before the router splits the hostname into an app path, in
30
+ * the env `E` of whatever serves it. */
31
+ export type Arrived<E = unknown> = {
32
+ env: E
33
+ req: Request
34
+ path: string
35
+ space: string | null
36
+ }
37
+
38
+ /** A hostname's door, or null when the path belongs elsewhere. */
39
+ export type Door<E = unknown> = (
40
+ at: Arrived<E>,
41
+ ) => Promise<Response | null> | Response | null
42
+
43
+ // A person's spaces and account live at the apex rather than on any space's
44
+ // hostname, so no app sharing a space's origin can reach them (T-39354). A
45
+ // space's own address, `/<space>`, is its Dashboard (T-3702): its apps, what
46
+ // its agents did and its Updates. Its Operator is at `/<space>/operator`
47
+ // (D-473): a new chat, each conversation at `/<space>/operator/<id>`, its
48
+ // Updates at `/<space>/updates` and its Matches at `/<space>/matches`; the
49
+ // person's Updates from every space are `/updates`. Manage is the settings: a space's at `/manage/<space>/<page>`,
50
+ // and the person's own, wherever they are, at `/manage/account/<page>`
51
+ // (T-136122), which no space can be named (./names.ts `RESERVED` holds
52
+ // `account`).
53
+ export let MANAGE = '/manage'
54
+ /** Where a provider-started connection is attached to a space after sign-in. */
55
+ export let CONNECTION_INSTALL = '/connections/install'
56
+ /** The person's Updates from every space's Operator. */
57
+ export let UPDATES = '/updates'
58
+ /** A texted link's page approving one act the Operator was asked for by a
59
+ * number alone (yaks.app's operator-approvals.ts). */
60
+ export let APPROVE = '/approve'
61
+ export let ACCOUNT = 'account'
62
+ /** A page of one space's. */
63
+ export type SpaceView =
64
+ | 'apps'
65
+ | 'new'
66
+ | 'operator'
67
+ | 'dashboard'
68
+ | 'updates'
69
+ | 'tasks'
70
+ | 'matches'
71
+ | 'people'
72
+ | 'connections'
73
+ | 'visits'
74
+ | 'selling'
75
+ | 'billing'
76
+ | 'domains'
77
+ | 'settings'
78
+ | 'trash'
79
+ | 'versions'
80
+ /** A page of the person's own, the same in every space. `space` makes one. */
81
+ export type AccountView =
82
+ | 'profile'
83
+ | 'friends'
84
+ | 'invite'
85
+ | 'agents'
86
+ | 'shared'
87
+ | 'space'
88
+ export type ManageView = SpaceView | AccountView
89
+ /** A page of a space's Operator, at the space's own address. */
90
+ export type Talk = 'updates' | 'matches' | 'dashboard' | 'tasks'
91
+ let TALK: string[] = [
92
+ 'updates',
93
+ 'matches',
94
+ 'dashboard',
95
+ 'tasks',
96
+ ] satisfies Talk[]
97
+ let talks = (view: string): view is Talk => TALK.includes(view)
98
+ /** A settings page: every page of a person's spaces but their Operator's
99
+ * and an app's versions'. */
100
+ export type Setting = Exclude<ManageView, Talk | 'versions'>
101
+ let SPACE_VIEWS: Exclude<SpaceView, 'versions'>[] = [
102
+ 'apps',
103
+ 'new',
104
+ 'operator',
105
+ 'dashboard',
106
+ 'updates',
107
+ 'tasks',
108
+ 'matches',
109
+ 'people',
110
+ 'connections',
111
+ 'visits',
112
+ 'selling',
113
+ 'billing',
114
+ 'domains',
115
+ 'settings',
116
+ 'trash',
117
+ ]
118
+ let ACCOUNT_VIEWS: AccountView[] = [
119
+ 'profile',
120
+ 'friends',
121
+ 'invite',
122
+ 'agents',
123
+ 'shared',
124
+ 'space',
125
+ ]
126
+ export let accountView = (view: ManageView): view is AccountView =>
127
+ (ACCOUNT_VIEWS as string[]).includes(view)
128
+ // The pages before the space moved into the path, `/manage/<page>` with
129
+ // `?space=` or none for the person's own, and what each is now: letters
130
+ // already sent carry them.
131
+ let LEGACY: Record<string, Exclude<ManageView, 'versions'>> = {
132
+ ...Object.fromEntries(SPACE_VIEWS.map((v) => [v, v])),
133
+ connect: 'agents',
134
+ }
135
+ /** Whether a space named `slug` stands at the apex's root, `/<slug>`: every
136
+ * space but one holding a name the apex keeps for itself (./names.ts
137
+ * `RESERVED`, `ROOT`), whose Operator stays at `/manage/<slug>`.
138
+ *
139
+ * ```ts
140
+ * import { rooted } from '@yaks/platform/routes'
141
+ * import { assertEquals } from '@std/assert'
142
+ * assertEquals([rooted('ada'), rooted('admin'), rooted('gallery')], [true, false, false])
143
+ * ```
144
+ */
145
+ export let rooted = (slug: string): boolean =>
146
+ SLUG.test(slug) && !RESERVED.has(slug) && !ROOT.has(slug)
147
+ // Where a space's pages stand: its own address, else its old one under
148
+ // Manage.
149
+ let home = (space: string) =>
150
+ rooted(space) ? `/${space}` : `${MANAGE}/${encodeURIComponent(space)}`
151
+ /** A space's Dashboard: its own address, else under Manage, where the
152
+ * space's bare address is still its Operator.
153
+ *
154
+ * ```ts
155
+ * import { dashboardPath } from '@yaks/platform/routes'
156
+ * import { assertEquals } from '@std/assert'
157
+ * assertEquals(dashboardPath('ada'), '/ada')
158
+ * assertEquals(dashboardPath('yak'), '/manage/yak/dashboard')
159
+ * ```
160
+ */
161
+ export let dashboardPath = (space: string): string =>
162
+ rooted(space) ? home(space) : `${home(space)}/dashboard`
163
+ /** A page of a space's Operator: its Dashboard, Updates or Matches. Without
164
+ * a space, Updates from every space the person talks to.
165
+ *
166
+ * ```ts
167
+ * import { talkPath } from '@yaks/platform/routes'
168
+ * import { assertEquals } from '@std/assert'
169
+ * assertEquals(talkPath('updates', 'ada'), '/ada/updates')
170
+ * assertEquals(talkPath('updates'), '/updates')
171
+ * assertEquals(talkPath('matches', 'yak'), '/manage/yak/matches')
172
+ * assertEquals(talkPath('dashboard', 'ada'), '/ada')
173
+ * ```
174
+ */
175
+ export let talkPath = (view: Talk, space?: string): string =>
176
+ !space
177
+ ? UPDATES
178
+ : view == 'dashboard'
179
+ ? dashboardPath(space)
180
+ : `${home(space)}/${view}`
181
+
182
+ /** The detail page an entity link can open over its current page. */
183
+ export let taskEntityPath = (space: string, eid: string): string =>
184
+ `${talkPath('tasks', space)}?${new URLSearchParams({ item: eid })}`
185
+ /** A settings page's path. A space's page without a space names the one the
186
+ * person opens first, whichever that is when they follow it. */
187
+ export let managePath = (
188
+ view: Setting,
189
+ space?: string,
190
+ ): string =>
191
+ accountView(view)
192
+ ? `${MANAGE}/${ACCOUNT}/${view}`
193
+ : space
194
+ ? `${MANAGE}/${encodeURIComponent(space)}/${view}`
195
+ : `${MANAGE}/${view}`
196
+
197
+ /** The fund settings section of a space's Selling page. */
198
+ export let donationPath = (space: string, app?: string): string =>
199
+ managePath('selling', space) +
200
+ (app ? `?donations=${encodeURIComponent(app)}` : '') + '#donation-funds'
201
+
202
+ /** Open a chat account's OAuth confirmation from Profile. */
203
+ export let accountLink = (
204
+ home: string,
205
+ integration: string,
206
+ space?: string,
207
+ ): URL => {
208
+ let link = new URL(managePath('profile'), home)
209
+ link.searchParams.set('link', integration)
210
+ if (space) link.searchParams.set('back', space)
211
+ return link
212
+ }
213
+ /** Where a form lands back: the page under /manage or of a space's Operator
214
+ * it names, at the apex, else `fallback`; a form never sends the person off
215
+ * yaks.app. */
216
+ export let backTo = (env: Host, back: string, fallback: string): string => {
217
+ let apex = new URL(url(env))
218
+ let to = new URL(back || fallback, apex)
219
+ return to.origin == apex.origin &&
220
+ (to.pathname == MANAGE || to.pathname == CONNECTION_INSTALL ||
221
+ to.pathname.startsWith(`${MANAGE}/`) ||
222
+ !!spaced(to.pathname))
223
+ ? to.href
224
+ : new URL(fallback, apex).href
225
+ }
226
+ // What a conversation opens by: a task's or a request's eid, or `new`.
227
+ let OPEN = /^(new|[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12})$/
228
+ /** An Operator conversation's own page, the chat app (operator-page.ts
229
+ * `chatPage`): one opened by its task or request, or a new one, which is the
230
+ * Operator's own address. Its other conversations are under it, so `open`
231
+ * empty is the prefix they share.
232
+ *
233
+ * ```ts
234
+ * import { chatPath } from '@yaks/platform/routes'
235
+ * import { assertEquals } from '@std/assert'
236
+ * let id = '0b5e6a52-3c1d-4f2e-9a8b-7c6d5e4f3a2b'
237
+ * assertEquals(chatPath('ada'), '/ada/operator')
238
+ * assertEquals(chatPath('ada', id), `/ada/operator/${id}`)
239
+ * assertEquals(chatPath('ada', ''), '/ada/operator/')
240
+ * assertEquals(chatPath('yak'), '/manage/yak')
241
+ * assertEquals(chatPath('yak', id), `/manage/yak/operator/${id}`)
242
+ * ```
243
+ */
244
+ export let chatPath = (space: string, open = 'new'): string =>
245
+ rooted(space)
246
+ ? `/${space}/operator${open == 'new' ? '' : `/${open}`}`
247
+ : open == 'new'
248
+ ? home(space)
249
+ : `${managePath('operator', space)}/${open}`
250
+ // A version's own page, under its space's: `versions/<app>/<version>`.
251
+ let VERSIONS = 'versions'
252
+ let shipped = (space: string, [app, n]: string[]) =>
253
+ SLUG.test(app) && /^[1-9][0-9]*$/.test(n)
254
+ ? { space, view: 'versions' as const, version: { app, version: +n } }
255
+ : null
256
+ /** A version of an app's own page (operator-page.ts `versionPage`): what it
257
+ * changed, as its release says, and the way to it as it shipped.
258
+ *
259
+ * ```ts
260
+ * import { versionPath } from '@yaks/platform/routes'
261
+ * import { assertEquals } from '@std/assert'
262
+ * assertEquals(versionPath('ada', 'roster', 4), '/ada/versions/roster/4')
263
+ * assertEquals(versionPath('yak', 'roster', 4), '/manage/yak/versions/roster/4')
264
+ * ```
265
+ */
266
+ export let versionPath = (space: string, app: string, version: number) =>
267
+ `${home(space)}/${VERSIONS}/${app}/${version}`
268
+ /** Where a space's logo is drawn from, or none where it has none: its bytes'
269
+ * own address, so the address changes with the picture and nothing is ever
270
+ * shown stale.
271
+ *
272
+ * ```ts
273
+ * import { logoPath } from '@yaks/platform/routes'
274
+ * import { assertEquals } from '@std/assert'
275
+ * let sha = 'a'.repeat(64)
276
+ * assertEquals(logoPath({ slug: 'ada', logo: { sha } }), `/manage/ada/logo/${sha}?size=avatar`)
277
+ * assertEquals(logoPath({ slug: 'ada', logo: null }), undefined)
278
+ * ```
279
+ */
280
+ export let logoPath = (
281
+ space: { slug: string; logo?: { sha: string } | null },
282
+ size: LogoSize = 'avatar',
283
+ ): string | undefined =>
284
+ space.logo
285
+ ? `${MANAGE}/${
286
+ encodeURIComponent(space.slug)
287
+ }/logo/${space.logo.sha}?size=${size}`
288
+ : undefined
289
+ /** Where Settings' Logo form sends a picture: Settings with `?logo`, so the
290
+ * page's Save, which also posts a multipart form there, is not read as one.
291
+ *
292
+ * ```ts
293
+ * import { logoUpload } from '@yaks/platform/routes'
294
+ * import { assertEquals } from '@std/assert'
295
+ * assertEquals(logoUpload('ada'), '/manage/ada/settings?logo')
296
+ * ```
297
+ */
298
+ export let logoUpload = (space: string): string =>
299
+ `${managePath('settings', space)}?logo`
300
+ /** What draws an app's home-screen icon: its release, the space's logo and
301
+ * the artwork drawn for an app that has no icon of its own.
302
+ *
303
+ * ```ts
304
+ * import { iconVersion } from '@yaks/platform/routes'
305
+ * import { assertEquals } from '@std/assert'
306
+ * let id = '0b6b4f8c-fdcc-4a38-bcbd-15bad97cee69'
307
+ * assertEquals(
308
+ * iconVersion({ source: `ada/.releases/7/${id}` }, { logo: null }),
309
+ * `${id}.`,
310
+ * )
311
+ * ```
312
+ */
313
+ export let iconVersion = (
314
+ app: { source?: string | null; generatedIcon?: string },
315
+ space: { logo?: { sha: string } | null },
316
+ art?: string,
317
+ ): string =>
318
+ `${art ?? releaseId(app.source) ?? app.source ?? ''}.${
319
+ space.logo?.sha.slice(0, 12) ?? ''
320
+ }${app.generatedIcon ? `.${app.generatedIcon.slice(0, 12)}` : ''}`
321
+
322
+ /** The platform's empty response that starts an app ahead of navigation. */
323
+ export let APP_WARM = '/_web/warm'
324
+
325
+ /** The warm door under the app mount `at`. */
326
+ export let appWarmAt = (at: string) => at.replace(/\/$/, '') + APP_WARM
327
+
328
+ /** An app's icon below its address `at` (ending in a slash), named by what
329
+ * draws it (`iconVersion`), so a browser keeps it until a release or the
330
+ * logo changes it (workers/yak apps.ts `caching`).
331
+ *
332
+ * ```ts
333
+ * import { iconAt } from '@yaks/platform/routes'
334
+ * import { assertEquals } from '@std/assert'
335
+ * assertEquals(
336
+ * iconAt('https://ada.yaks.app/box/', { source: 'abc' }, { logo: null }),
337
+ * 'https://ada.yaks.app/box/icon.png?v=abc.',
338
+ * )
339
+ * ```
340
+ */
341
+ export let iconAt = (
342
+ at: string,
343
+ app: { source?: string | null; generatedIcon?: string },
344
+ space: { logo?: { sha: string } | null },
345
+ art?: string,
346
+ ): string =>
347
+ `${at}icon.png?v=${encodeURIComponent(iconVersion(app, space, art))}`
348
+
349
+ /** The app fields needed to address its display icon. */
350
+ export type MarkedApp = {
351
+ eid: string
352
+ slug: string
353
+ title: string
354
+ source?: string | null
355
+ generatedIcon?: string
356
+ }
357
+
358
+ /** The release and the platform artwork it can show. */
359
+ export let markVersion = (
360
+ { eid, slug, title, source, generatedIcon }: MarkedApp,
361
+ ) => {
362
+ let release = releaseId(source)
363
+ return release || source === null
364
+ ? `3.${release ?? ''}.${eid}.${generatedIcon ?? letter(title || slug)}`
365
+ : null
366
+ }
367
+
368
+ /** The icon in an app list. */
369
+ export let appMark = (at: string, app: MarkedApp): string => {
370
+ let version = markVersion(app)
371
+ return `${at}/icon.png?display${
372
+ version ? `&v=${encodeURIComponent(version)}` : ''
373
+ }`
374
+ }
375
+
376
+ /** An app list's image and the mark it can paint before the image arrives. */
377
+ export let appMarkImage = (at: string, app: MarkedApp): {
378
+ backdrop: { 'data-app-mark': string; style: { '--app-mark': string } }
379
+ image: {
380
+ src: string
381
+ alt: string
382
+ loading: 'lazy'
383
+ class: string
384
+ 'data-app-mark-image': string
385
+ }
386
+ } => ({
387
+ backdrop: {
388
+ 'data-app-mark': '',
389
+ style: {
390
+ '--app-mark': `url("data:image/svg+xml,${
391
+ encodeURIComponent(monogram(app.title || app.slug, app.eid))
392
+ }")`,
393
+ },
394
+ },
395
+ image: {
396
+ src: appMark(at, app),
397
+ alt: '',
398
+ loading: 'lazy',
399
+ class: 'AppMark_Image',
400
+ 'data-app-mark-image': '',
401
+ },
402
+ })
403
+
404
+ /** Where the gallery serves pictures whose visibility follows an app. */
405
+ export let PICTURES = '/gallery/image/'
406
+
407
+ /** Where the connections page serves the logos it does not keep as SVG
408
+ * (workers/yak catalog.ts `logoDoor`), by the integration's name. */
409
+ export let LOGOS = '/connections/logo/'
410
+ export let STORED_LOGOS: string = `${LOGOS}file/`
411
+ export let ICON_LIMIT = 1024 * 1024
412
+ /** Where an integration's logo is drawn from, read from its row: its own
413
+ * SVG as a `data:` address, else the logo door for a row that names its
414
+ * logo's address (`image`), made absolute on the apex, or none where it has
415
+ * neither (@yaks/ui `Logo` then draws a neutral mark).
416
+ *
417
+ * ```ts
418
+ * import { integrationLogo } from '@yaks/platform/routes'
419
+ * import { assertEquals } from '@std/assert'
420
+ * let env = { APEX: 'yaks.test' }
421
+ * assertEquals(
422
+ * integrationLogo({ name: 'gmail', image: 'https://x.test/g.svg' }, env),
423
+ * 'https://yaks.test/connections/logo/gmail',
424
+ * )
425
+ * assertEquals(integrationLogo({ name: 'x', logo: '<svg/>' }), 'data:image/svg+xml,%3Csvg%2F%3E')
426
+ * assertEquals(integrationLogo({ name: 'mine' }), undefined)
427
+ * ```
428
+ */
429
+ export let integrationLogo = (
430
+ i: { name: string; logo?: string; image?: string },
431
+ env: Host = {},
432
+ ): string | undefined =>
433
+ i.logo ? `data:image/svg+xml,${encodeURIComponent(i.logo)}` : i.image
434
+ ? url(
435
+ env,
436
+ SHA.test(i.image)
437
+ ? STORED_LOGOS + i.image
438
+ : `${LOGOS}${encodeURIComponent(i.name)}`,
439
+ )
440
+ : undefined
441
+ let SHA = /^[0-9a-f]{64}$/
442
+ /** The name a web manifest answers at, under an app's mount or a space's
443
+ * Operator. */
444
+ export const MANIFEST = 'manifest.webmanifest'
445
+ /** The Operator's public icon. */
446
+ export let OPERATOR_ICON = '/connector-512.png'
447
+ /** What a space's Operator page installs from (operator-page.ts
448
+ * `installing`). */
449
+ export let manifestPath = (space: string) =>
450
+ `${MANAGE}/${encodeURIComponent(space)}/${MANIFEST}`
451
+ // Where each published app's own page lives (workers/yak app-page.ts): one
452
+ // address per platform-wide name, listed or not.
453
+ export let PAGE = '/apps/'
454
+ /** A published app's own page on the platform. */
455
+ /// pageAt('recipes') -> 'https://yaks.app/apps/recipes'
456
+ export let pageAt = (name: string, env: Host = {}): string =>
457
+ url(env, `${PAGE}${encodeURIComponent(name)}`)
458
+
459
+ // Where the page of a space that shares anything in public lives
460
+ // (workers/yak publisher-page.ts): one address per space slug.
461
+ export let PUBLISHER = '/spaces/'
462
+ /** The page of a space that shares anything in public. */
463
+ /// publisherAt('ada') -> 'https://yaks.app/spaces/ada'
464
+ export let publisherAt = (slug: string, env: Host = {}): string =>
465
+ url(env, `${PUBLISHER}${encodeURIComponent(slug)}`)
466
+
467
+ /** The doors of a space's Operator store, as @yaks/api names them, under its
468
+ * Operator's own path: `/manage/<space>/operator/query`.
469
+ *
470
+ * ```ts
471
+ * import { managed } from '@yaks/platform/routes'
472
+ * import { assertEquals } from '@std/assert'
473
+ * assertEquals(managed('/manage/ada/operator/ws'), {
474
+ * space: 'ada',
475
+ * view: 'operator',
476
+ * door: 'ws',
477
+ * })
478
+ * ```
479
+ */
480
+ export type StoreDoor = 'apply' | 'query' | 'ws'
481
+ let STORE_DOORS: string[] = ['apply', 'query', 'ws'] satisfies StoreDoor[]
482
+ /** What an address of a person's spaces asks for: an account page, the
483
+ * person's Updates from every space's Operator (`updates`), a space's page (a
484
+ * new chat with its Operator when none is named), a door of its Operator's
485
+ * store, its logo's bytes, an address from before T-136122 (`legacy`), or one
486
+ * whose page has moved (`moved`, D-473), each to be sent on. Null is no page.
487
+ */
488
+ export type Managed =
489
+ | { account: AccountView }
490
+ | { updates: true }
491
+ | {
492
+ space: string
493
+ view: SpaceView
494
+ open?: string
495
+ door?: StoreDoor
496
+ logo?: string
497
+ manifest?: true
498
+ version?: { app: string; version: number }
499
+ }
500
+ | { legacy: Exclude<ManageView, 'versions'> }
501
+ | { first: true }
502
+ | { moved: string }
503
+ // A page of a space's Operator under Manage, where it was before D-473: sent
504
+ // on to the space's own address, unless the space holds a name the apex keeps
505
+ // (`rooted`), whose Operator is still served there.
506
+ let talked = (space: string, view: 'operator' | Talk, open = 'new') =>
507
+ !rooted(space) ? { space, view, ...view == 'operator' ? { open } : {} } : {
508
+ moved: view == 'operator' ? chatPath(space, open) : talkPath(view, space),
509
+ }
510
+ /** What a path under `/manage` asks for (`Managed`), or null where it is not
511
+ * one. */
512
+ export let managed = (path: string): Managed | null => {
513
+ if (!(path == MANAGE || path.startsWith(`${MANAGE}/`))) return null
514
+ let [one, two, ...rest] = path.slice(MANAGE.length).split('/')
515
+ .filter(Boolean)
516
+ // An Operator conversation, on a page of its own (`chatPath`), or a door
517
+ // of its store.
518
+ if (two == 'operator' && rest.length == 1 && SLUG.test(one)) {
519
+ if (STORE_DOORS.includes(rest[0])) {
520
+ return { space: one, view: 'operator', door: rest[0] as StoreDoor }
521
+ }
522
+ return OPEN.test(rest[0]) ? talked(one, 'operator', rest[0]) : null
523
+ }
524
+ if (two == VERSIONS && rest.length == 2 && SLUG.test(one)) {
525
+ let at = shipped(one, rest)
526
+ return at && rooted(one)
527
+ ? { moved: versionPath(one, at.version.app, at.version.version) }
528
+ : at
529
+ }
530
+ if (two == MANIFEST && !rest.length && SLUG.test(one)) {
531
+ return { space: one, view: 'operator', manifest: true }
532
+ }
533
+ if (two == 'logo' && rest.length == 1 && SLUG.test(one)) {
534
+ return SHA.test(rest[0])
535
+ ? { space: one, view: 'settings', logo: rest[0] }
536
+ : null
537
+ }
538
+ if (rest.length) return null
539
+ if (!one) return { first: true }
540
+ if (one == ACCOUNT) {
541
+ return !two
542
+ ? { account: 'profile' }
543
+ : (ACCOUNT_VIEWS as string[]).includes(two)
544
+ ? { account: two as AccountView }
545
+ : null
546
+ }
547
+ if (one == 'updates' && !two) return { moved: UPDATES }
548
+ if (!two) {
549
+ return Object.hasOwn(LEGACY, one)
550
+ ? { legacy: LEGACY[one] }
551
+ : SLUG.test(one)
552
+ ? talked(one, 'operator')
553
+ : null
554
+ }
555
+ if (!SLUG.test(one) || !(SPACE_VIEWS as string[]).includes(two)) return null
556
+ return talks(two) ? talked(one, two) : { space: one, view: two as SpaceView }
557
+ }
558
+ /** What an address at the apex's root asks for: the person's Updates from
559
+ * every space (`/updates`), or a page of a space at the space's own address
560
+ * (`rooted`): its Dashboard, its Operator's chat or another page of its
561
+ * Operator; or null where it is none. A conversation's address from before
562
+ * the chat moved under `/operator` is sent on to where it is now.
563
+ *
564
+ * ```ts
565
+ * import { spaced } from '@yaks/platform/routes'
566
+ * import { assertEquals } from '@std/assert'
567
+ * let id = '0b5e6a52-3c1d-4f2e-9a8b-7c6d5e4f3a2b'
568
+ * assertEquals(spaced('/ada'), { space: 'ada', view: 'dashboard' })
569
+ * assertEquals(spaced('/ada/operator'), { space: 'ada', view: 'operator', open: 'new' })
570
+ * assertEquals(spaced(`/ada/operator/${id}`), { space: 'ada', view: 'operator', open: id })
571
+ * assertEquals(spaced(`/ada/${id}`), { moved: `/ada/operator/${id}` })
572
+ * assertEquals(spaced('/ada/updates'), { space: 'ada', view: 'updates' })
573
+ * assertEquals(spaced('/ada/versions/roster/4'), {
574
+ * space: 'ada',
575
+ * view: 'versions',
576
+ * version: { app: 'roster', version: 4 },
577
+ * })
578
+ * assertEquals(spaced('/ada/dashboard'), { moved: '/ada' })
579
+ * assertEquals(spaced('/pricing'), null)
580
+ * ```
581
+ */
582
+ export let spaced = (path: string): Managed | null => {
583
+ if (path == UPDATES) return { updates: true }
584
+ let [, one, two, ...rest] = path.split('/')
585
+ if (!rooted(one)) return null
586
+ if (two == 'operator' && rest.length < 2) {
587
+ let open = rest[0] ?? 'new'
588
+ return OPEN.test(open) ? { space: one, view: 'operator', open } : null
589
+ }
590
+ if (two == VERSIONS && rest.length == 2) return shipped(one, rest)
591
+ if (rest.length) return null
592
+ if (two == null) return { space: one, view: 'dashboard' }
593
+ if (two == 'dashboard') return { moved: dashboardPath(one) }
594
+ if (talks(two)) return { space: one, view: two }
595
+ return OPEN.test(two) ? { moved: chatPath(one, two) } : null
596
+ }
597
+ /** Whether `path` is a page a signed-in person opens in the frame: a space's
598
+ * page, every space's Updates, a settings page, or an address moved to one;
599
+ * never a store's door, a logo or a manifest.
600
+ *
601
+ * ```ts
602
+ * import { framed } from '@yaks/platform/routes'
603
+ * import { assertEquals } from '@std/assert'
604
+ * assertEquals(framed('/ada/updates'), true)
605
+ * assertEquals(framed('/manage/account/friends'), true)
606
+ * assertEquals(framed('/manage/ada/logo/' + 'a'.repeat(64)), false)
607
+ * assertEquals(framed('/pricing'), false)
608
+ * ```
609
+ */
610
+ export let framed = (path: string): boolean => {
611
+ let at = managed(path) ?? spaced(path)
612
+ return !!at && !('door' in at && at.door || 'logo' in at && at.logo ||
613
+ 'manifest' in at && at.manifest)
614
+ }
615
+ /** Where an address that names no space (`/manage`, or one from before the
616
+ * space was in the path) is now, for `space`: a page names its own, and none
617
+ * is the space's chat. */
618
+ export let landing = (
619
+ at: { first: true } | { legacy: Exclude<ManageView, 'versions'> },
620
+ space: string,
621
+ ): string =>
622
+ 'first' in at
623
+ ? chatPath(space)
624
+ : talks(at.legacy)
625
+ ? talkPath(at.legacy, space)
626
+ : managePath(at.legacy, space)
627
+ /** The path an address from before the dashboard named its space in the path
628
+ * (`/_yaks/<page>`, `/manage/<page>`) stands for in `space`, or null. */
629
+ export let movedFor = (path: string, space: string): string | null => {
630
+ let at = managed(path)
631
+ if (at && 'moved' in at && at.moved == UPDATES) {
632
+ return talkPath('updates', space)
633
+ }
634
+ return at && ('first' in at || 'legacy' in at) ? landing(at, space) : null
635
+ }
636
+ /** The same page of a space's at another name, where a rename moved it. */
637
+ export let renamed = (
638
+ at: {
639
+ view: SpaceView
640
+ open?: string
641
+ version?: { app: string; version: number }
642
+ },
643
+ slug: string,
644
+ ): string =>
645
+ at.open
646
+ ? chatPath(slug, at.open)
647
+ : at.view == 'versions'
648
+ ? at.version
649
+ ? versionPath(slug, at.version.app, at.version.version)
650
+ : dashboardPath(slug)
651
+ : talks(at.view)
652
+ ? talkPath(at.view, slug)
653
+ : managePath(at.view, slug)
654
+ /** One space's settings page, as an address to put in a letter or an
655
+ * answer. */
656
+ export let manageAt = (
657
+ space: string,
658
+ view: Setting,
659
+ env: Host = {},
660
+ ): string => url(env, managePath(view, space))
661
+ /** A connections page's address, still naming the testing integrations it
662
+ * was opened for (connections.ts `enabled`), so its forms and a sign-in begun
663
+ * there come back to the page as it was. */
664
+ export let enabling = (to: string, enable: string[] = []): string => {
665
+ if (!enable.length) return to
666
+ let [path, hash] = to.split('#')
667
+ return `${path}${path.includes('?') ? '&' : '?'}enable=${
668
+ enable.map(encodeURIComponent).join(',')
669
+ }${hash == null ? '' : `#${hash}`}`
670
+ }
671
+
672
+ // The path the platform keeps on every space's hostname, outside the
673
+ // app-slug namespace: a service's webhooks arrive under it (connections.ts
674
+ // `HOOKS`), and the dashboard's addresses from when it lived there move to
675
+ // the apex.
676
+ export let OURS = '/_yaks'
677
+
678
+ /** The generated style guide's own sheet and specimens (app-style-guide.ts),
679
+ * the same address on every app origin. No app page is given them. */
680
+ export let APP_GUIDE_CSS = '/_app-guide.css'
681
+ export let APP_SPECIMENS_JS = '/_app-specimens.js'
682
+
683
+ export let APP_GUIDE_ASSETS = [APP_GUIDE_CSS, APP_SPECIMENS_JS]
684
+
685
+ /** A read of a style guide asset at its shared address. */
686
+ export let appGuideRead = (method: string, path: string): boolean =>
687
+ (method == 'GET' || method == 'HEAD') && APP_GUIDE_ASSETS.includes(path)
688
+
689
+ /** The platform admin's directory, on the platform's own host (admin.ts). */
690
+ export let ADMIN = '/admin'
691
+ export let ADMIN_CONNECTIONS = `${ADMIN}/connections`
692
+ export let adminConnectionsPath = (space: string, person: string) =>
693
+ `${ADMIN_CONNECTIONS}?${new URLSearchParams({ space, person })}`
694
+
695
+ export let adminPath = (path: string): boolean =>
696
+ path == ADMIN || path.startsWith(ADMIN + '/')
697
+
698
+ export let BROWSE = '/api/browse'
699
+ export let ADMIN_BROWSE = `${BROWSE}/admin`
700
+
701
+ export let adminPage = (href: unknown, env: Host = {}): boolean => {
702
+ if (typeof href != 'string') return false
703
+ let url = URL.parse(href)
704
+ return !!url && url.origin == `https://${apex(env)}` &&
705
+ !url.username && !url.password &&
706
+ adminPath(url.pathname)
707
+ }
708
+
709
+ /** Where signing out is posted (identity.ts). */
710
+ export let LOGOUT = '/logout'
711
+
712
+ // What the plans cost, as a page (site/pricing.tsx, D-32751). It lives here
713
+ // — beside the platform's own name, in the module with no dependencies —
714
+ // because both halves of the paid tier need it and they must not import each
715
+ // other: billing.ts writes the plan, usage.ts says where a space stands
716
+ // against its ceilings, and unseen.ts already joins them.
717
+ //
718
+ // It is the one address the agent surface may give (C-33033 on D-32751):
719
+ // OpenAI's app-directory policy forbids a plugin selling a subscription and
720
+ // allows explaining that a feature needs a plan and linking to a page that
721
+ // describes the plans. So a tool answer may name this and never a checkout
722
+ // link — checkout is the signed-in web page's, and email's.
723
+ export let PRICING: string = url({}, '/pricing')
724
+
725
+ /** Signed-in plan settings; login preserves this destination. Never checkout. */
726
+ export let planSettings = (slug: string, env: Host = {}): string =>
727
+ manageAt(slug, 'billing', env)
728
+
729
+ // One MCP resource, requiring sign-in by default. The explicit required URL
730
+ // remains for existing connectors; mixed auth is opt-in at `?auth=mixed`.
731
+ export let MCP: string = url({}, '/mcp')
732
+ export let MCP_ASK = `${MCP}?auth=required`
733
+
734
+ // Where signing in happens — one email address and a six-digit code, and the
735
+ // same line for somebody who has never been here (signin.ts). It is here
736
+ // beside the other two for the same reason: everything that says it must say
737
+ // the same string, and the tools that name it in a refusal (tools.ts, anon.ts)
738
+ // cannot import identity.ts, which re-exports it, without dragging the
739
+ // runtime's own modules into a Deno test.
740
+ export let SIGN_IN: string = url({}, '/login')
741
+
742
+ /** Where someone who has not signed in is sent: the login page, already
743
+ * carrying the page to hand them back to (T-32593). Whether that address is
744
+ * one to follow is the login door's to decide. */
745
+ export let signInAt = (page: string, env: Host): string => {
746
+ let to = new URL(`https://${apex(env)}/login`)
747
+ to.searchParams.set('return', page)
748
+ return to.href
749
+ }
750
+
751
+ /** Send a signed-out visitor to sign-in with the requested platform page. */
752
+ export let signInReturn = (req: Request, env: Host): Response => {
753
+ let { pathname, search } = new URL(req.url)
754
+ return new Response(null, {
755
+ status: 303,
756
+ headers: { location: signInAt(url(env, pathname + search), env) },
757
+ })
758
+ }
759
+ /** Where a paid plan's Get Started sends a stranger (site/home.tsx,
760
+ * site/pricing.tsx): signing in, then the Billing page of the space they open
761
+ * first, whose plan card is the button that buys the plan. Not the connector
762
+ * page, where the card waits closed below the setup. */
763
+ export let GET_PLAN = `/login?return=${
764
+ encodeURIComponent(managePath('billing'))
765
+ }`
766
+ /** The page that installs a published app by its name (install.ts). Here
767
+ * beside the sign-in address, since a visitor's bar (./visits.ts) sends a
768
+ * stranger through the one to the other. */
769
+ export let INSTALL = '/install'
770
+ /** The page installing `name`, or, `back`, where it sends a stranger who
771
+ * pressed its button back to once signed in: the same page, marked so the
772
+ * funnel counts one who came back apart (install.ts). */
773
+ export let installAt = (name: string, back = false): string =>
774
+ `${INSTALL}?name=${encodeURIComponent(name)}${back ? '&from=sign-in' : ''}`
775
+ /** Whether an install page's address is one a stranger came back to from
776
+ * signing in (`installAt`). */
777
+ export let isBack = (url: URL): boolean =>
778
+ url.searchParams.get('from') == 'sign-in'
779
+
780
+ export let says = (env: Host = {}): string =>
781
+ `sign in at ${url(env, '/login')} to reach your apps from here`
782
+
783
+ // And the sentence every refusal says about it: what a person's agent reads
784
+ // when it asked for something nobody signed in may have. It lives here beside
785
+ // the address rather than at one of the doors, because three of them say it —
786
+ // the 401 and its challenge (identity.ts), and the tools a stranger is shown
787
+ // but may not call (anon.ts `barred`).
788
+ export let SAYS: string = says()
789
+
790
+ // And what an agent's connector form asks for when it will not go and find it
791
+ // (T-34414): the authorization server's own addresses and the one scope.
792
+ // identity.ts configures the provider with these, so they are the same strings
793
+ // the two `/.well-known` documents serve, and the connect page types them out
794
+ // for a person whose form has empty boxes. Paths, not absolute URLs, because
795
+ // the provider matches an endpoint by hostname and path and the probe kernel
796
+ // is not at this hostname; the page absolutes them against PLATFORM.
797
+ export let OAUTH = {
798
+ authorize: '/oauth/authorize',
799
+ token: '/oauth/token',
800
+ register: '/oauth/register',
801
+ scope: 'graph',
802
+ }
803
+
804
+ // The Cloudflare for SaaS fallback origin (T-33036): the name a customer's
805
+ // own hostname is CNAME'd to, and the one place that name is written — the
806
+ // attach flow and the guide both read it here.
807
+ //
808
+ // Two labels deep on purpose. `route()` below reads everything before
809
+ // `.yaks.app` as a space slug, and `SLUG` admits no dot, so `x.y.yaks.app` is
810
+ // already outside the space namespace and no person can ever claim the space
811
+ // that would shadow our own origin. A one-label name (`origin.yaks.app`)
812
+ // would have needed a reserved-word list to hold that line, and a list is a
813
+ // thing to forget; the namespace's own shape does not forget.
814
+ //
815
+ // This is also the reason a domain mid-provisioning reaches the Worker at
816
+ // all instead of timing out (T-33036): the CNAME above and the `*/*` route
817
+ // mean traffic for any custom hostname on this zone arrives here, active or
818
+ // not — a visitor of a domain whose DNS, validation or certificate step has
819
+ // not finished yet used to get a raw 522 with nothing between them and it.
820
+ // index.ts `settling` is the branded page that answers there now.
821
+ export let ORIGIN = `origin.saas.${PLATFORM}`
822
+
823
+ // Where the app serving this request is mounted for the browser that asked:
824
+ // the prefix its pages resolve relative URLs against, and the address its own
825
+ // `/<app>/` would forward to. `/<app>/` normally, and `/` when a custom
826
+ // domain carried the request here — there the app is the domain's root
827
+ // (index.ts `aimed`), even though the address the platform routes on names
828
+ // the app's prefix. The router sets this header on a request it rewrote
829
+ // itself and strips it off anything a client sent, so it is never a way to
830
+ // move an app's address from outside.
831
+ export let MOUNT = 'x-yak-mount'
832
+
833
+ /** The header an app's own worker carries its sealed visitor in, coming back
834
+ * through its service binding (dispatch.ts). */
835
+ export let GRANT = 'x-yak-grant'
836
+
837
+ /** Whether a request carries one, valid or not: it is the kernel's to open. */
838
+ export let bearing = (req: Request): boolean => req.headers.has(GRANT)
839
+
840
+ // The addresses on a space's hostname its apps never answer: a repository's
841
+ // (@yaks/git/door, mounted by workers/yak git_door.ts) and a service's
842
+ // webhooks (connections.ts). They come before the apps and before the edge's
843
+ // kept pages.
844
+ export let spaceDoor = (path: string): boolean =>
845
+ knocks(path) || path.startsWith(`${OURS}/hooks/`)
846
+
847
+ /** The browser-facing URL retained when the router aims a custom domain. */
848
+ export let ADDRESS = 'x-yak-address'
849
+
850
+ /** Where an app's own `api/` is for the browser that asked, where it is not
851
+ * under the app's mount (`MOUNT`): the home app's at the apex (workers/yak
852
+ * site.ts `HOME`), whose pages are mounted at `/`, where `/api/` is the
853
+ * apex's own doors. The pencil reads its doors there (page-script.ts). Set
854
+ * by the router alone, as `MOUNT` is. */
855
+ export let API_AT = 'x-yak-api-at'
856
+
857
+ export type Route = {
858
+ // null at the apex
859
+ space: string | null
860
+ // null at a space's bare hostname, or when the first segment is no slug
861
+ app: string | null
862
+ // inside an app: '' for `/<app>` itself (the caller adds the slash), else
863
+ // the path from its slash; at the apex or a bare space, the whole path
864
+ path: string
865
+ }
866
+
867
+ // Where a hostname somebody else owns is served from: the address on our own
868
+ // zone that the request is carried to, and the mount the app sits at there
869
+ // (T-34596). The directory says which place the domain names — a space, or one
870
+ // app of it — and this is the whole of what that difference means.
871
+ //
872
+ // A domain on a space is that space's own hostname with the path untouched, so
873
+ // it routes through `route()` and every rung of apps.ts exactly as
874
+ // `<space>.yaks.app` does: the front page at `/`, each app at `/<app>/`, the
875
+ // space's own doors where they always were. There is no second path rule for
876
+ // it, because it is the rule.
877
+ //
878
+ // A domain on an app is that app's prefix under the same hostname, mounted at
879
+ // `/`: `herbusiness.com/menu` is `<space>.yaks.app/<app>/menu`, and the mount
880
+ // says the app's pages resolve from the domain's root rather than from the
881
+ // prefix the platform routed by. Both may point at one space at once — the
882
+ // app's own domain opens it at `/`, the space's opens it at `/<app>/`.
883
+ export let aimedAt = (
884
+ space: string,
885
+ app: string | null,
886
+ pathname: string,
887
+ env: Host = {},
888
+ ): { host: string; pathname: string; mount: string | null } => ({
889
+ host: spaceHost(env, space),
890
+ pathname: app ? `/${app}${pathname}` : pathname,
891
+ mount: app ? '/' : null,
892
+ })
893
+
894
+ /** A custom domain as the directory reads it (directory.ts `serves`): the
895
+ * place it opens, and how far it has come. */
896
+ export type Domain = {
897
+ space: { slug: string }
898
+ app: { slug: string } | null
899
+ host: {
900
+ eid: string
901
+ stage: string | null
902
+ verified: string | null
903
+ verification: unknown
904
+ to: string | null
905
+ }
906
+ }
907
+
908
+ /** Whether a domain serves its place: provisioned, and shown to be its
909
+ * owner's where Cloudflare asked for that. Anything else is answered the
910
+ * page that says how far it has come (kernel.ts `settling`). */
911
+ export let ready = (at: Domain | null): boolean =>
912
+ at?.host.stage == 'active' &&
913
+ (!!at.host.verified || at.host.verification == null)
914
+
915
+ /** A request to a hostname that is a place of ours, a custom domain or the
916
+ * apex's own pages (workers/yak site.ts `HOME`), carried to the address that
917
+ * place already has on our own zone (`aimedAt`), naming the address the
918
+ * browser asked (`ADDRESS`) and, for an app, the mount it answers at
919
+ * (`MOUNT`).
920
+ *
921
+ * ```ts
922
+ * import { ADDRESS, aim, MOUNT } from '@yaks/platform/routes'
923
+ * import { assertEquals } from '@std/assert'
924
+ * let at = { space: { slug: 'ada' }, app: { slug: 'menu' } }
925
+ * let req = aim(new Request('http://her.com/soup?x=1'), 'her.com', at)
926
+ * assertEquals(req.url, 'https://ada.yaks.app/menu/soup?x=1')
927
+ * assertEquals(req.headers.get(ADDRESS), 'https://her.com/soup?x=1')
928
+ * assertEquals(req.headers.get(MOUNT), '/')
929
+ * ```
930
+ */
931
+ export let aim = (
932
+ req: Request,
933
+ host: string,
934
+ at: Pick<Domain, 'space' | 'app'>,
935
+ env: Host = {},
936
+ ): Request => {
937
+ let url = new URL(req.url)
938
+ let address = new URL(req.url)
939
+ address.host = host
940
+ address.port = ''
941
+ address.protocol = 'https:'
942
+ let to = aimedAt(at.space.slug, at.app?.slug ?? null, url.pathname, env)
943
+ url.protocol = 'https:'
944
+ url.host = to.host
945
+ url.pathname = to.pathname
946
+ let headers = new Headers(req.headers)
947
+ headers.set(ADDRESS, address.href)
948
+ if (to.mount) headers.set(MOUNT, to.mount)
949
+ return new Request(url, new Request(req, { headers }))
950
+ }
951
+
952
+ // The path a customer's own hostname answers the handoff at (handoff.ts).
953
+ // Namespaced so an app's own routes do not collide with it.
954
+ export let HANDOFF = '/__yak/signin'
955
+
956
+ /** Whether this is a custom domain's sign-in handoff, the one identity door
957
+ * a customer's own hostname answers (identity.ts `handoff`). */
958
+ export let handedOff = (
959
+ host: string,
960
+ pathname: string,
961
+ env: Host = {},
962
+ ): boolean => foreign(host, env) && pathname == HANDOFF
963
+
964
+ /** Whether a hostname is this machine's: a local dev run's, never deployed. */
965
+ export let loopback = (host: string): boolean =>
966
+ host == 'localhost' || host == '127.0.0.1' || host == '[::1]' ||
967
+ host.endsWith('.localhost')
968
+
969
+ export let hostOf = (req: Request, env: Host = {}): string => {
970
+ let host = new URL(req.url).hostname.toLowerCase()
971
+ return env.LOCAL_DEV == '1' && loopback(host)
972
+ ? (req.headers.get('x-yak-host') ?? host).toLowerCase()
973
+ : host
974
+ }
975
+
976
+ // A hostname that is neither ours nor a dev host — someone else's domain,
977
+ // which the directory may know as a customer's (T-33037). Everything the
978
+ // platform already answers on is not foreign, so every route that exists
979
+ // today is decided before this is ever asked: the apex, a space, a dev host,
980
+ // and `x.y.yaks.app`, which was the apex before custom domains and still is.
981
+ export let foreign = (host: string, env: Host = {}): boolean =>
982
+ !loopback(host) && host != apex(env) && !host.endsWith(`.${apex(env)}`)
983
+
984
+ // An address on the platform's own zone: https, and the apex or a hostname
985
+ // under it. It is what a sign-in may hand someone back to (T-32593) — a
986
+ // stranger's address is nowhere we send anyone, so it answers null and the
987
+ // caller goes home instead. Pure, like the rest of this file.
988
+ //
989
+ // A custom domain is deliberately not on the zone (T-33037). We serve it, but
990
+ // the return address arrives from whoever asked, this check is the only thing
991
+ // between that and an open redirect, and it is pure and synchronous — reading
992
+ // the directory here to see whether a stranger's hostname is a customer's
993
+ // would make the one guard in the path an async lookup that can fail open.
994
+ // Nothing is lost by refusing: the platform session cookie is `yaks.app`'s, so
995
+ // a person handed back to `herbusiness.com` would arrive signed out anyway.
996
+ // index.ts serves a custom domain at its app's own address on this zone, so
997
+ // sign-in hands them back there, signed in. A domain that wants to keep
998
+ // someone on their own hostname needs its own verified return, not a wider
999
+ // `onZone`.
1000
+ export let onZone = (href: string, env: Host = {}): string | null => {
1001
+ // A bare path is on the zone by construction, and it is what the platform's
1002
+ // own returns are made of (`/login?return=/connect`), so refusing one threw
1003
+ // away every address we minted ourselves. `//host` — and `/\host`, which a
1004
+ // browser reads the same way — is a stranger's URL wearing a path's
1005
+ // clothes, and is refused with the rest.
1006
+ if (href.startsWith('/')) return /^\/[/\\]/.test(href) ? null : href
1007
+ let url
1008
+ try {
1009
+ url = new URL(href)
1010
+ } catch {
1011
+ return null
1012
+ }
1013
+ let host = url.hostname.toLowerCase()
1014
+ return url.protocol == 'https:' &&
1015
+ (host == apex(env) || host.endsWith(`.${apex(env)}`))
1016
+ ? url.href
1017
+ : null
1018
+ }
1019
+
1020
+ export let route = (host: string, pathname: string, env: Host = {}): Route => {
1021
+ let space = host.endsWith(`.${apex(env)}`)
1022
+ ? host.slice(0, -apex(env).length - 1)
1023
+ : null
1024
+ if (space == null || !SLUG.test(space)) {
1025
+ return { space: null, app: null, path: pathname }
1026
+ }
1027
+ let [, first, ...rest] = pathname.split('/')
1028
+ if (!first || !SLUG.test(first)) return { space, app: null, path: pathname }
1029
+ return {
1030
+ space,
1031
+ app: first,
1032
+ path: pathname.length > first.length + 1 ? `/${rest.join('/')}` : '',
1033
+ }
1034
+ }
1035
+
1036
+ // What the PLATFORM owns rather than an app, read from the hostname and the
1037
+ // path. The whole rule in one idea: `/.well-known/` is where a site grants
1038
+ // authority over its own name, and the name under `<space>.yaks.app` is ours
1039
+ // — a space rents a label of our hostname, it does not own it.
1040
+ //
1041
+ // The test is NOT whether a file is host-scoped. `robots.txt` is host-scoped
1042
+ // and stays the app's, deliberately: a robots file grants nobody anything,
1043
+ // it is a preference about the site, and the site's face is the home app.
1044
+ // The test is whether the file hands somebody a capability over a name we
1045
+ // own. `assetlinks.json` grants a native Android app the right to intercept
1046
+ // URLs for the whole hostname; `apple-app-site-association` does the same on
1047
+ // iOS; an HTTP-01 challenge yields a publicly trusted certificate for a
1048
+ // hostname on our zone. A space's app must not be able to grant those on our
1049
+ // name, and that holds for the HOME app too, which otherwise answers every
1050
+ // address no other app claims (T-33040) — which is how all of this landed in
1051
+ // an app in the first place, and why top-level routing has to say out loud
1052
+ // that it wins.
1053
+ //
1054
+ // The whole prefix rather than the three files, because a list of names that
1055
+ // grant authority is a thing to forget — the next one ships without us —
1056
+ // and on our own hostname there is nothing under it we lose by keeping.
1057
+ //
1058
+ // The same files are the app's on a customer's own domain (`foreign`), by
1059
+ // this idea rather than despite it: there the name is theirs, so the
1060
+ // authority is theirs to grant. Proving domain control to a third party is
1061
+ // exactly what `pki-validation` is for at Sectigo and DigiCert, Stripe asks
1062
+ // for `apple-developer-merchantid-domain-association` before Apple Pay
1063
+ // works, App Links, Universal Links, `security.txt`, WebFinger, Matrix
1064
+ // delegation and fediverse verification all live here, and obtaining a
1065
+ // certificate for your own domain is your own business. Nothing is reserved
1066
+ // there, and there is no list of exceptions to keep: a path is the
1067
+ // platform's when the platform has something to serve at it, and everything
1068
+ // else falls through to the app. The apps-directory token is the shape of
1069
+ // that — the apex has content at `/.well-known/openai-apps-challenge` and
1070
+ // answers it (index.ts), while `/.well-known/anything-else` is nobody's and
1071
+ // 404s. When Stripe or Apple Pay needs to answer somewhere, it will answer
1072
+ // because it has content, not because a string was added to a table.
1073
+ //
1074
+ // Our own renewal of a customer's custom-hostname certificate is not at risk
1075
+ // from that. This zone has a `*/*` Worker route (wrangler.toml, T-33036), and
1076
+ // Cloudflare warns it can intercept a CA's request
1077
+ // (developers.cloudflare.com/ssl/edge-certificates/changing-dcv-method/troubleshooting/).
1078
+ // Measured 2026-09-03: with that route live and the Worker answering these
1079
+ // paths itself, a probe hostname was attached as a custom hostname and
1080
+ // ssl.com issued its certificate within a minute, while a request to
1081
+ // `/.well-known/acme-challenge/x` on that hostname reached the Worker and got
1082
+ // its soft 404. Cloudflare's edge answers the CA before the route ever runs.
1083
+ // That measurement is also why the platform can answer its own 404 on our
1084
+ // hostnames instead of passing a request through to a fallback origin that is
1085
+ // deliberately originless (`AAAA 100::`).
1086
+ export let platform = (
1087
+ host: string,
1088
+ pathname: string,
1089
+ env: Host = {},
1090
+ ): boolean => !foreign(host, env) && pathname.startsWith('/.well-known/')
1091
+
1092
+ // What a page at another address may not ask for here, read from the method
1093
+ // and the path (`sameOrigin` below is the check itself).
1094
+ //
1095
+ // Every write, wherever it is aimed. Sibling spaces are same-site, so any
1096
+ // form a page in anybody's space aims at a door that acts on the session
1097
+ // cookie arrives with the cookie. A list of the doors that write was the
1098
+ // guard once, and every door added after it was open: the OAuth consent, the
1099
+ // space delete, the standing link and the address picker were all forged from
1100
+ // a free space (T-37874), as the billing webhook had been by being renamed
1101
+ // out of the list (T-35357). The method is the one thing a new door cannot
1102
+ // forget to say. Guarding costs a server-to-server caller nothing — Stripe
1103
+ // posts with no `Origin`, and an absent one is allowed.
1104
+ //
1105
+ // Except the two doors the OAuth provider answers with CORS on purpose:
1106
+ // token and registration read no cookie at all, a code, its PKCE verifier
1107
+ // and a client's own metadata being the whole of what they take, and a
1108
+ // browser-based client posts to them from its own origin.
1109
+ //
1110
+ // And the doors the graph answers at, whatever the method: an app's
1111
+ // `/<app>/api/…`, a front page's own `/api/…` (apps.ts `fetch` serves the home
1112
+ // app everything no other app claims), and the connector at `/mcp`, where a
1113
+ // socket or a stream is a read that carries the session's write grant.
1114
+ // Pages, files and images are deliberately not here — an app's bytes are the
1115
+ // web's, and a cross-origin GET of one carries no `Origin` anyway. The shape
1116
+ // over-reaches a little: a static asset at `/x/api/y` on the apex matches too,
1117
+ // which costs nothing, since nothing a browser fetches cross-origin without
1118
+ // CORS can read the answer either way.
1119
+ //
1120
+ // And every WebSocket handshake, wherever it is aimed: a handshake is a GET
1121
+ // that carries the cookie and is outside the same-origin policy, and the page
1122
+ // that opens a socket reads and writes it. The upgrade header, like the
1123
+ // method, is one no new socket can forget to send, so no list of socket paths
1124
+ // has to keep up.
1125
+ export let guarded = (req: Request): boolean => {
1126
+ let { method } = req, path = new URL(req.url).pathname
1127
+ return (method != 'GET' && method != 'HEAD' && method != 'OPTIONS' &&
1128
+ path != OAUTH.token && path != OAUTH.register) ||
1129
+ path == '/mcp' || /^(?:\/[^/]+)?\/api\//.test(path) || upgrading(req)
1130
+ }
1131
+
1132
+ // The browser's own word for the page that asked, against the hostname it
1133
+ // asked at. Every space is a subdomain of one registrable domain, so sibling
1134
+ // spaces are same-site: `SameSite=Lax` does not keep the session cookie off a
1135
+ // request one space's page aims at another's, and a websocket handshake is
1136
+ // outside the same-origin policy altogether. This is the line that separates
1137
+ // them, and it is the whole of it everywhere except the one door below, where
1138
+ // the answer carries CORS headers precisely because no cookie was read.
1139
+ //
1140
+ // Absent is allowed on purpose. A browser sends `Origin` on every
1141
+ // cross-origin fetch and on every handshake, so refusing only a mismatch
1142
+ // closes the browser attack completely; curl, a server-to-server client and
1143
+ // the kernel's own internal requests send none and have no page to be tricked
1144
+ // through. Requiring the header would break them for no security at all.
1145
+ //
1146
+ // Hostname only: scheme and port differ between a dev host and the platform,
1147
+ // and neither is what a space is isolated by.
1148
+ //
1149
+ // The apex is no sibling: it is the platform's own pages, with no app's code
1150
+ // in them, and the dashboard there aims at a space's doors (pages.ts `desk`:
1151
+ // the drop zone). A page that could forge a request
1152
+ // from the apex could already consent to an agent or close a space there, so
1153
+ // admitting it here gives nothing away.
1154
+ //
1155
+ // `Origin: null` is a stranger (a sandboxed frame's opaque origin), unless the
1156
+ // browser's own `Sec-Fetch-Site`, which no page can set, says the request
1157
+ // came from this very origin: a form posted from one of our pages served with
1158
+ // `Referrer-Policy: no-referrer` (the approval and sign-in pages) is sent with
1159
+ // `Origin: null`. A sandboxed frame's requests are `cross-site` there.
1160
+ export let sameOrigin = (
1161
+ host: string,
1162
+ origin: string | null,
1163
+ env: Host = {},
1164
+ site: string | null = null,
1165
+ ): boolean => {
1166
+ if (!origin) return true
1167
+ if (origin == 'null') return site == 'same-origin'
1168
+ try {
1169
+ let from = new URL(origin).hostname.toLowerCase()
1170
+ return from == host.toLowerCase() || from == apex(env)
1171
+ } catch {
1172
+ return false
1173
+ }
1174
+ }
1175
+
1176
+ // The one door above that a stranger's page may reach anyway (T-33408), and
1177
+ // the shape of the whole permission: the app's read door, asked with GET, and
1178
+ // answered as nobody — the router drops the request's credentials before it is
1179
+ // served and sends `Access-Control-Allow-Origin: *` with no
1180
+ // `Access-Control-Allow-Credentials` beside it, which is the browser's own
1181
+ // guarantee that no cookie was used and none can be read (`cors`).
1182
+ //
1183
+ // It is safe because what `sameOrigin` closes is ambient credentials, not
1184
+ // secrecy: a public app's rows already answer to anyone with curl, and the
1185
+ // attack was the session cookie riding along on a request one space's page
1186
+ // aimed at another's. Take the cookie away and the request is curl with a
1187
+ // referrer. What the caller may then read is the app's own `access`, unchanged
1188
+ // and decided downstream: `public` and `open` answer a stranger, `private`
1189
+ // refuses one.
1190
+ //
1191
+ // Writes are not here and must not be. An `open` app lets a stranger write —
1192
+ // with the link, from its own page — and a cross-origin write is the forgery
1193
+ // origin_test.ts fires. Nor is `/ws`, which is a read but carries the
1194
+ // write grant on the same socket, nor `/graph`, `/who` or `/blob`: this is the
1195
+ // door the answer is data at, and nothing else has asked to be shared.
1196
+ //
1197
+ // No preflight door is needed and none is built: a GET with no author-set
1198
+ // headers is a CORS simple request, so the browser sends it and reads the
1199
+ // answer with no `OPTIONS` in between. A client that adds a header would need
1200
+ // one, and can ask for it when it exists.
1201
+ export let shared = (method: string, pathname: string): boolean =>
1202
+ (method == 'GET' || method == 'HEAD') &&
1203
+ /^(?:\/[^/]+)?\/api\/query$/.test(pathname)
1204
+
1205
+ /** A read the query Worker can take on a space's hostname. The directory
1206
+ * still decides which app owns the address and what its caller may read. */
1207
+ export let queryRequest = (req: Request, env: Host = {}): boolean => {
1208
+ if (!['GET', 'HEAD', 'OPTIONS'].includes(req.method)) return false
1209
+ if (req.headers.has('upgrade')) return false
1210
+ let path = collapsedPath(new URL(req.url).pathname)
1211
+ let host = hostOf(req, env)
1212
+ let at = route(host, path, env)
1213
+ if (
1214
+ !at.space || platform(host, path, env) || previews(path) ||
1215
+ spaceDoor(path)
1216
+ ) return false
1217
+ return queryPath(path) || queryPath(at.path)
1218
+ }
1219
+
1220
+ /** A store query at the app-relative address, with or without a page token. */
1221
+ export let queryPath = (path: string): boolean =>
1222
+ /^(?:\/~[^/]+)?\/api\/query$/.test(path)
1223
+
1224
+ /** A private binding response asking the front to send the original request
1225
+ * to the kernel, where the address belongs to a different door. */
1226
+ export let QUERY_PASS = 'x-yak-query-pass'
1227
+
1228
+ // The pages of ours at other addresses that ask the sign-in door for a code
1229
+ // (D-138669): yak.sh's "Get set up on yaks.app" section posts the address
1230
+ // typed there, and gets the letter any sign-in gets (signin.ts `codeLetter`).
1231
+ export let ASKERS = ['yak.sh']
1232
+
1233
+ // Whether a request's `Origin` is one of {@link ASKERS}.
1234
+ let asker = (origin: string | null): boolean => {
1235
+ try {
1236
+ return ASKERS.includes(new URL(origin ?? '').hostname.toLowerCase())
1237
+ } catch {
1238
+ return false
1239
+ }
1240
+ }
1241
+
1242
+ // The second door a page elsewhere may reach, opened the way the first is,
1243
+ // with the credentials taken off (`admitted`): asking for a
1244
+ // code reads no cookie, and answers a page exactly what it answers curl. Only
1245
+ // for {@link ASKERS}, so no other page can spread its asks over its visitors'
1246
+ // addresses.
1247
+ export let askable = (
1248
+ method: string,
1249
+ pathname: string,
1250
+ origin: string | null,
1251
+ ): boolean => method == 'POST' && pathname == '/login' && asker(origin)
1252
+
1253
+ // A sandboxed app's page asking its own doors (./installs.ts, D-37901): the
1254
+ // path carries its page token as `/<app>/~<token>/…`, or `/~<token>/…` for a
1255
+ // front page or an app on its own domain. Such a page has an opaque origin,
1256
+ // so it sends `Origin: null`, which `sameOrigin` refuses — and it should,
1257
+ // everywhere a cookie could ride along. Here none may: the router takes the
1258
+ // cookie off before the request is served and marks the answer readable by
1259
+ // any origin (`admitted`), because the credential is the token in the URL,
1260
+ // which no browser attaches on its own. What the token opens is the one app
1261
+ // it was sealed for; every other request on such a path is anonymous. A
1262
+ // draft's preview link is read the same way: its ticket is its path's
1263
+ // (`previews`).
1264
+ export let paged = (pathname: string): boolean =>
1265
+ /^(?:\/[^/]+)?\/~[^/]+(?:\/|$)/.test(pathname) || previews(pathname)
1266
+
1267
+ /** The segment under an app its drafts' preview links are mounted at
1268
+ * (@yaks/platform/preview `mountOf`). */
1269
+ export let PREVIEW = '_preview'
1270
+
1271
+ let PREVIEWS = new RegExp(`^/[^/]+/(?:${PREVIEW}|~[a-z0-9]{12})(?:/|$)`)
1272
+
1273
+ /** Whether `pathname` is under an app's preview links, which the platform
1274
+ * answers and no app routes: a sealed ticket's under {@link PREVIEW}, or a
1275
+ * stored link's `/<app>/~<code>/`, twelve letters and digits
1276
+ * (@yaks/platform/preview `CODE`), which a page token, sealed `<body>.<mac>`,
1277
+ * never is. */
1278
+ /// previews('/cookbook/_preview/t/about') -> true
1279
+ /// previews('/cookbook/_preview') -> true
1280
+ /// previews('/cookbook/~k3f9x2ab7q1z/about') -> true
1281
+ /// previews('/cookbook/~k3f9x2ab7q1z') -> true
1282
+ /// previews('/cookbook/~abc.def/') -> false
1283
+ /// previews('/cookbook/_previews/') -> false
1284
+ /// previews('/_preview/t/') -> false
1285
+ export let previews = (pathname: string): boolean => PREVIEWS.test(pathname)
1286
+
1287
+ /** The preview page and its assets have their own response deadline. */
1288
+ export let previewRead = (req: Request): boolean => {
1289
+ if (!['GET', 'HEAD'].includes(req.method) || req.headers.has('upgrade')) {
1290
+ return false
1291
+ }
1292
+ let path = new URL(req.url).pathname
1293
+ let [, , marker, first, afterTicket] = path.split('/', 5)
1294
+ return previews(path) && (marker == PREVIEW ? afterTicket : first) != 'api'
1295
+ }
1296
+
1297
+ export let previewWait = { kernel: 10_000, front: 12_000 }
1298
+
1299
+ let RETRY = 2
1300
+
1301
+ /** A request a browser shows as a page, in a tab or a frame. */
1302
+ let shown = (req: Request) => {
1303
+ let dest = req.headers.get('sec-fetch-dest')
1304
+ return dest
1305
+ ? dest == 'document' || dest == 'iframe'
1306
+ : !!req.headers.get('accept')?.includes('text/html')
1307
+ }
1308
+
1309
+ /** A preview that cannot answer yet says so and when to ask again. A page
1310
+ * asks again on its own, so a person who opened the link while it was being
1311
+ * built, or while a store restarted, sees it arrive without reloading. */
1312
+ export let previewWaiting = (req: Request, preparing = false): Response => {
1313
+ let said = preparing
1314
+ ? 'This preview is still preparing.'
1315
+ : 'This preview is temporarily unavailable.'
1316
+ let page = shown(req)
1317
+ let body = page
1318
+ ? `<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="${RETRY}"><title>Preview</title><p>${said} This page tries again in a moment.</p>`
1319
+ : `${said} Try again shortly.`
1320
+ return new Response(req.method == 'HEAD' ? null : body, {
1321
+ status: preparing ? 202 : 503,
1322
+ headers: {
1323
+ 'cache-control': 'private, no-store',
1324
+ 'content-type': page
1325
+ ? 'text/html; charset=utf-8'
1326
+ : 'text/plain; charset=utf-8',
1327
+ 'referrer-policy': 'no-referrer',
1328
+ 'retry-after': String(RETRY),
1329
+ },
1330
+ })
1331
+ }
1332
+
1333
+ /** The connector and app or platform API doors answer failures as JSON. */
1334
+ export let jsonDoor = (path: string) =>
1335
+ path == '/mcp' || /^(?:\/[^/]+)?\/api\//.test(path)
1336
+
1337
+ /** A request waiting for a response reached its deadline. */
1338
+ export let timedOut = (req: Request): Response => {
1339
+ let message = 'This request took too long. Try again shortly.'
1340
+ let init = { status: 504, headers: { 'cache-control': 'no-store' } }
1341
+ return jsonDoor(new URL(req.url).pathname)
1342
+ ? Response.json({ error: { code: 'timeout', message } }, init)
1343
+ : new Response(message, init)
1344
+ }
1345
+
1346
+ // One page, one address: a doubled slash (`/printbound//refund`, from a typed
1347
+ // link or a crawler's join) names the page its single slash names. Collapsed
1348
+ // before anything routes on it, no part below and no app's code ever reads a
1349
+ // path that starts `//`, which `new URL` takes for a host and throws on
1350
+ // (T-153266, T-153429).
1351
+ let collapsedPath = (path: string) => path.replace(/\/{2,}/g, '/')
1352
+
1353
+ export let collapsed = (req: Request): Request => {
1354
+ let url = new URL(req.url)
1355
+ let path = collapsedPath(url.pathname)
1356
+ if (path == url.pathname) return req
1357
+ url.pathname = path
1358
+ return new Request(url, req)
1359
+ }
1360
+
1361
+ // Headers taken off a request before it is served.
1362
+ let without = (req: Request, names: string[]): Request => {
1363
+ if (!names.some((n) => req.headers.has(n))) return req
1364
+ let headers = new Headers(req.headers)
1365
+ for (let n of names) headers.delete(n)
1366
+ return new Request(req, { headers })
1367
+ }
1368
+
1369
+ /** A request with the headers only the router writes ({@link MOUNT},
1370
+ * {@link ADDRESS}, {@link API_AT}) taken off: whatever a client sent under
1371
+ * those names is gone before anything reads it. */
1372
+ export let unmounted = (req: Request): Request =>
1373
+ without(req, [MOUNT, ADDRESS, API_AT])
1374
+
1375
+ // A page on somebody else's address, writing or at one of our graph doors
1376
+ // (`sameOrigin`, `guarded`). It is refused in the shape every other api
1377
+ // refusal has — a code the page's code reads, a sentence its person reads —
1378
+ // and it is a deliberate no, so nothing is filed about it.
1379
+ let stranger = () =>
1380
+ Response.json({
1381
+ error: {
1382
+ code: 'foreign_origin',
1383
+ message: 'that page is at another address and cannot use this door',
1384
+ },
1385
+ }, { status: 403 })
1386
+
1387
+ // The question a browser asks before a sandboxed page's JSON write or its
1388
+ // upload: yes, from anywhere, with the headers it named. No credentials are
1389
+ // allowed and none are read, so there is nothing an origin could add.
1390
+ let preflight = (req: Request) =>
1391
+ new Response(null, {
1392
+ status: 204,
1393
+ headers: {
1394
+ 'access-control-allow-origin': '*',
1395
+ 'access-control-allow-methods': 'GET, HEAD, POST, PUT, DELETE',
1396
+ 'access-control-allow-headers':
1397
+ req.headers.get('access-control-request-headers') ?? '',
1398
+ 'access-control-max-age': '86400',
1399
+ },
1400
+ })
1401
+
1402
+ /** How a request may be served, given the page that asked: the request to
1403
+ * serve, and whether its answer is to be marked readable by any origin
1404
+ * ({@link cors}), or the answer it gets instead. */
1405
+ export type Admitted = { req: Request; anyone: boolean } | { answer: Response }
1406
+
1407
+ /**
1408
+ * Space isolation, and the one place it holds (`sameOrigin`). It is asked
1409
+ * before a custom domain's request is carried to its place on our zone
1410
+ * (`aim`), because what must match is what the browser addressed: a page at
1411
+ * `herbusiness.com` asking its own `/api/…` is same-origin even though the
1412
+ * router is about to carry the request to `<space>.yaks.app/<app>/api/…`.
1413
+ *
1414
+ * One door is open to every page anyway: the app's read door, asked with
1415
+ * GET, served with the credentials stripped off and marked readable by any
1416
+ * origin (`shared`). So is asking for a sign-in code, to the pages of ours
1417
+ * that ask for one (`askable`). And a sandboxed app's page, on the path that
1418
+ * carries its token: its origin is opaque, so it is a stranger to every
1419
+ * page, and its request is served with no cookie at all (`paged`).
1420
+ *
1421
+ * The credentials go together because neither half is safe alone: an answer
1422
+ * marked readable by any origin must be an answer no session was used to
1423
+ * compute. The cookie is the whole of the ambient credential an app's door
1424
+ * reads, and `authorization` goes with it, so that the day a door reads one
1425
+ * it cannot arrive through here.
1426
+ *
1427
+ * ```ts
1428
+ * import { admitted } from '@yaks/platform/routes'
1429
+ * import { assertEquals } from '@std/assert'
1430
+ * let post = new Request('https://ada.yaks.app/menu/api/apply', {
1431
+ * method: 'POST',
1432
+ * headers: { origin: 'https://bob.yaks.app' },
1433
+ * })
1434
+ * let got = admitted(post, 'ada.yaks.app')
1435
+ * assertEquals('answer' in got && got.answer.status, 403)
1436
+ * ```
1437
+ */
1438
+ export let admitted = (
1439
+ req: Request,
1440
+ host: string,
1441
+ env: Host = {},
1442
+ ): Admitted => {
1443
+ let asked = new URL(req.url).pathname
1444
+ let origin = req.headers.get('origin')
1445
+ if (paged(asked)) {
1446
+ return req.method == 'OPTIONS'
1447
+ ? { answer: preflight(req) }
1448
+ : { req: without(req, ['cookie']), anyone: true }
1449
+ }
1450
+ if (
1451
+ !guarded(req) ||
1452
+ sameOrigin(host, origin, env, req.headers.get('sec-fetch-site'))
1453
+ ) {
1454
+ return { req, anyone: false }
1455
+ }
1456
+ if (!shared(req.method, asked) && !askable(req.method, asked, origin)) {
1457
+ return { answer: stranger() }
1458
+ }
1459
+ return { req: without(req, ['cookie', 'authorization']), anyone: true }
1460
+ }
1461
+
1462
+ /**
1463
+ * The mark on an answer {@link admitted} served to any page. The wildcard,
1464
+ * never the asking origin, and no `Access-Control-Allow-Credentials`: a
1465
+ * browser refuses to send a credentialed request to `*`, so the pair is a
1466
+ * promise the browser itself enforces, and echoing the origin back would let
1467
+ * a future mistake add credentials to it.
1468
+ *
1469
+ * `Vary: Origin` because the same URL answers differently to the page that
1470
+ * owns it. No shared cache may sit in front of such an answer: a Workers
1471
+ * cache key holds the path and not the hostname, so
1472
+ * `alice.yaks.app/recipes/api/query?x` and bob's would be one entry.
1473
+ */
1474
+ export let cors = (res: Response): Response => {
1475
+ if (res.status == 101) return res
1476
+ let headers = new Headers(res.headers)
1477
+ headers.set('access-control-allow-origin', '*')
1478
+ headers.append('vary', 'origin')
1479
+ return new Response(res.body, {
1480
+ status: res.status,
1481
+ statusText: res.statusText,
1482
+ headers,
1483
+ })
1484
+ }
1485
+
1486
+ /// firstOf({first: '["/recipes/*"]'}) -> ['/recipes/*']
1487
+ /// firstOf(undefined) -> []
1488
+ /// firstOf({first: 'not json'}) -> []
1489
+ /**
1490
+ * The property as the App row reads it (directory.ts `appOf`): the JSON array
1491
+ * in `home.first`, or nothing at all. Lenient where the Worker's `globs` is strict — a
1492
+ * read must answer whatever the row holds, since the graph tier writes this
1493
+ * property too, and a listing must not fall over on one somebody typed by hand.
1494
+ */
1495
+ export let firstOf = (home?: { first?: string | null } | null): string[] => {
1496
+ try {
1497
+ let held = JSON.parse(home?.first || '[]')
1498
+ return Array.isArray(held) ? held.filter((g) => typeof g == 'string') : []
1499
+ } catch {
1500
+ return []
1501
+ }
1502
+ }