@aigne/afs-did-space 1.12.0-beta.5

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 (510) hide show
  1. package/LICENSE.md +26 -0
  2. package/README.md +129 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
  5. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  6. package/dist/afs-metadata-context.cjs +20 -0
  7. package/dist/afs-metadata-context.d.cts +21 -0
  8. package/dist/afs-metadata-context.d.cts.map +1 -0
  9. package/dist/afs-metadata-context.d.mts +21 -0
  10. package/dist/afs-metadata-context.d.mts.map +1 -0
  11. package/dist/afs-metadata-context.mjs +18 -0
  12. package/dist/afs-metadata-context.mjs.map +1 -0
  13. package/dist/blocklet-hook.cjs +180 -0
  14. package/dist/blocklet-hook.d.cts +29 -0
  15. package/dist/blocklet-hook.d.cts.map +1 -0
  16. package/dist/blocklet-hook.d.mts +29 -0
  17. package/dist/blocklet-hook.d.mts.map +1 -0
  18. package/dist/blocklet-hook.mjs +178 -0
  19. package/dist/blocklet-hook.mjs.map +1 -0
  20. package/dist/changelog-schema.cjs +603 -0
  21. package/dist/changelog-schema.d.cts +395 -0
  22. package/dist/changelog-schema.d.cts.map +1 -0
  23. package/dist/changelog-schema.d.mts +395 -0
  24. package/dist/changelog-schema.d.mts.map +1 -0
  25. package/dist/changelog-schema.mjs +570 -0
  26. package/dist/changelog-schema.mjs.map +1 -0
  27. package/dist/changelog-write.cjs +80 -0
  28. package/dist/changelog-write.d.cts +70 -0
  29. package/dist/changelog-write.d.cts.map +1 -0
  30. package/dist/changelog-write.d.mts +70 -0
  31. package/dist/changelog-write.d.mts.map +1 -0
  32. package/dist/changelog-write.mjs +77 -0
  33. package/dist/changelog-write.mjs.map +1 -0
  34. package/dist/cid-byte-cache.cjs +126 -0
  35. package/dist/cid-byte-cache.d.cts +46 -0
  36. package/dist/cid-byte-cache.d.cts.map +1 -0
  37. package/dist/cid-byte-cache.d.mts +47 -0
  38. package/dist/cid-byte-cache.d.mts.map +1 -0
  39. package/dist/cid-byte-cache.mjs +125 -0
  40. package/dist/cid-byte-cache.mjs.map +1 -0
  41. package/dist/cid.cjs +68 -0
  42. package/dist/cid.d.cts +22 -0
  43. package/dist/cid.d.cts.map +1 -0
  44. package/dist/cid.d.mts +22 -0
  45. package/dist/cid.d.mts.map +1 -0
  46. package/dist/cid.mjs +65 -0
  47. package/dist/cid.mjs.map +1 -0
  48. package/dist/client.cjs +221 -0
  49. package/dist/client.d.cts +72 -0
  50. package/dist/client.d.cts.map +1 -0
  51. package/dist/client.d.mts +72 -0
  52. package/dist/client.d.mts.map +1 -0
  53. package/dist/client.mjs +220 -0
  54. package/dist/client.mjs.map +1 -0
  55. package/dist/cloudflare.cjs +510 -0
  56. package/dist/cloudflare.d.cts +307 -0
  57. package/dist/cloudflare.d.cts.map +1 -0
  58. package/dist/cloudflare.d.mts +308 -0
  59. package/dist/cloudflare.d.mts.map +1 -0
  60. package/dist/cloudflare.mjs +507 -0
  61. package/dist/cloudflare.mjs.map +1 -0
  62. package/dist/ctime-backfill.cjs +272 -0
  63. package/dist/ctime-backfill.d.cts +169 -0
  64. package/dist/ctime-backfill.d.cts.map +1 -0
  65. package/dist/ctime-backfill.d.mts +169 -0
  66. package/dist/ctime-backfill.d.mts.map +1 -0
  67. package/dist/ctime-backfill.mjs +267 -0
  68. package/dist/ctime-backfill.mjs.map +1 -0
  69. package/dist/d1-gc-queue.cjs +80 -0
  70. package/dist/d1-gc-queue.d.cts +59 -0
  71. package/dist/d1-gc-queue.d.cts.map +1 -0
  72. package/dist/d1-gc-queue.d.mts +59 -0
  73. package/dist/d1-gc-queue.d.mts.map +1 -0
  74. package/dist/d1-gc-queue.mjs +81 -0
  75. package/dist/d1-gc-queue.mjs.map +1 -0
  76. package/dist/d1-resolve-store.cjs +189 -0
  77. package/dist/d1-resolve-store.d.cts +93 -0
  78. package/dist/d1-resolve-store.d.cts.map +1 -0
  79. package/dist/d1-resolve-store.d.mts +93 -0
  80. package/dist/d1-resolve-store.d.mts.map +1 -0
  81. package/dist/d1-resolve-store.mjs +190 -0
  82. package/dist/d1-resolve-store.mjs.map +1 -0
  83. package/dist/d1-schema.cjs +361 -0
  84. package/dist/d1-schema.d.cts +237 -0
  85. package/dist/d1-schema.d.cts.map +1 -0
  86. package/dist/d1-schema.d.mts +237 -0
  87. package/dist/d1-schema.d.mts.map +1 -0
  88. package/dist/d1-schema.mjs +341 -0
  89. package/dist/d1-schema.mjs.map +1 -0
  90. package/dist/d1-share-store.cjs +0 -0
  91. package/dist/d1-share-store.d.cts +53 -0
  92. package/dist/d1-share-store.d.cts.map +1 -0
  93. package/dist/d1-share-store.d.mts +53 -0
  94. package/dist/d1-share-store.d.mts.map +1 -0
  95. package/dist/d1-share-store.mjs +0 -0
  96. package/dist/d1-share-store.mjs.map +1 -0
  97. package/dist/d1-tree-index.cjs +1098 -0
  98. package/dist/d1-tree-index.d.cts +203 -0
  99. package/dist/d1-tree-index.d.cts.map +1 -0
  100. package/dist/d1-tree-index.d.mts +203 -0
  101. package/dist/d1-tree-index.d.mts.map +1 -0
  102. package/dist/d1-tree-index.mjs +1094 -0
  103. package/dist/d1-tree-index.mjs.map +1 -0
  104. package/dist/data-backend.cjs +147 -0
  105. package/dist/data-backend.d.cts +30 -0
  106. package/dist/data-backend.d.cts.map +1 -0
  107. package/dist/data-backend.d.mts +30 -0
  108. package/dist/data-backend.d.mts.map +1 -0
  109. package/dist/data-backend.mjs +148 -0
  110. package/dist/data-backend.mjs.map +1 -0
  111. package/dist/dedup-backfill.cjs +278 -0
  112. package/dist/dedup-backfill.d.cts +165 -0
  113. package/dist/dedup-backfill.d.cts.map +1 -0
  114. package/dist/dedup-backfill.d.mts +165 -0
  115. package/dist/dedup-backfill.d.mts.map +1 -0
  116. package/dist/dedup-backfill.mjs +273 -0
  117. package/dist/dedup-backfill.mjs.map +1 -0
  118. package/dist/did-space-like.d.cts +2 -0
  119. package/dist/did-space-like.d.mts +2 -0
  120. package/dist/did-utils.cjs +44 -0
  121. package/dist/did-utils.d.cts +25 -0
  122. package/dist/did-utils.d.cts.map +1 -0
  123. package/dist/did-utils.d.mts +25 -0
  124. package/dist/did-utils.d.mts.map +1 -0
  125. package/dist/did-utils.mjs +43 -0
  126. package/dist/did-utils.mjs.map +1 -0
  127. package/dist/dirty-path-queue.cjs +31 -0
  128. package/dist/dirty-path-queue.d.cts +104 -0
  129. package/dist/dirty-path-queue.d.cts.map +1 -0
  130. package/dist/dirty-path-queue.d.mts +104 -0
  131. package/dist/dirty-path-queue.d.mts.map +1 -0
  132. package/dist/dirty-path-queue.mjs +31 -0
  133. package/dist/dirty-path-queue.mjs.map +1 -0
  134. package/dist/dirty-path-schema.cjs +142 -0
  135. package/dist/dirty-path-schema.d.cts +90 -0
  136. package/dist/dirty-path-schema.d.cts.map +1 -0
  137. package/dist/dirty-path-schema.d.mts +90 -0
  138. package/dist/dirty-path-schema.d.mts.map +1 -0
  139. package/dist/dirty-path-schema.mjs +136 -0
  140. package/dist/dirty-path-schema.mjs.map +1 -0
  141. package/dist/download-actions.cjs +43 -0
  142. package/dist/download-actions.mjs +40 -0
  143. package/dist/download-actions.mjs.map +1 -0
  144. package/dist/fs-object-store.cjs +153 -0
  145. package/dist/fs-object-store.d.cts +21 -0
  146. package/dist/fs-object-store.d.cts.map +1 -0
  147. package/dist/fs-object-store.d.mts +22 -0
  148. package/dist/fs-object-store.d.mts.map +1 -0
  149. package/dist/fs-object-store.mjs +153 -0
  150. package/dist/fs-object-store.mjs.map +1 -0
  151. package/dist/gc-queue.d.cts +43 -0
  152. package/dist/gc-queue.d.cts.map +1 -0
  153. package/dist/gc-queue.d.mts +43 -0
  154. package/dist/gc-queue.d.mts.map +1 -0
  155. package/dist/index.cjs +2712 -0
  156. package/dist/index.d.cts +504 -0
  157. package/dist/index.d.cts.map +1 -0
  158. package/dist/index.d.mts +505 -0
  159. package/dist/index.d.mts.map +1 -0
  160. package/dist/index.mjs +2537 -0
  161. package/dist/index.mjs.map +1 -0
  162. package/dist/inline-content-migration.cjs +212 -0
  163. package/dist/inline-content-migration.d.cts +110 -0
  164. package/dist/inline-content-migration.d.cts.map +1 -0
  165. package/dist/inline-content-migration.d.mts +111 -0
  166. package/dist/inline-content-migration.d.mts.map +1 -0
  167. package/dist/inline-content-migration.mjs +207 -0
  168. package/dist/inline-content-migration.mjs.map +1 -0
  169. package/dist/inline-content.cjs +145 -0
  170. package/dist/inline-content.d.cts +98 -0
  171. package/dist/inline-content.d.cts.map +1 -0
  172. package/dist/inline-content.d.mts +98 -0
  173. package/dist/inline-content.d.mts.map +1 -0
  174. package/dist/inline-content.mjs +137 -0
  175. package/dist/inline-content.mjs.map +1 -0
  176. package/dist/local-changelog.cjs +241 -0
  177. package/dist/local-changelog.d.cts +119 -0
  178. package/dist/local-changelog.d.cts.map +1 -0
  179. package/dist/local-changelog.d.mts +119 -0
  180. package/dist/local-changelog.d.mts.map +1 -0
  181. package/dist/local-changelog.mjs +240 -0
  182. package/dist/local-changelog.mjs.map +1 -0
  183. package/dist/local.cjs +435 -0
  184. package/dist/local.d.cts +254 -0
  185. package/dist/local.d.cts.map +1 -0
  186. package/dist/local.d.mts +254 -0
  187. package/dist/local.d.mts.map +1 -0
  188. package/dist/local.mjs +427 -0
  189. package/dist/local.mjs.map +1 -0
  190. package/dist/memory-gc-queue.cjs +36 -0
  191. package/dist/memory-gc-queue.d.cts +22 -0
  192. package/dist/memory-gc-queue.d.cts.map +1 -0
  193. package/dist/memory-gc-queue.d.mts +22 -0
  194. package/dist/memory-gc-queue.d.mts.map +1 -0
  195. package/dist/memory-gc-queue.mjs +36 -0
  196. package/dist/memory-gc-queue.mjs.map +1 -0
  197. package/dist/memory-tree-index.cjs +734 -0
  198. package/dist/memory-tree-index.d.cts +159 -0
  199. package/dist/memory-tree-index.d.cts.map +1 -0
  200. package/dist/memory-tree-index.d.mts +159 -0
  201. package/dist/memory-tree-index.d.mts.map +1 -0
  202. package/dist/memory-tree-index.mjs +735 -0
  203. package/dist/memory-tree-index.mjs.map +1 -0
  204. package/dist/metadata-db.cjs +562 -0
  205. package/dist/metadata-db.d.cts +102 -0
  206. package/dist/metadata-db.d.cts.map +1 -0
  207. package/dist/metadata-db.d.mts +102 -0
  208. package/dist/metadata-db.d.mts.map +1 -0
  209. package/dist/metadata-db.mjs +562 -0
  210. package/dist/metadata-db.mjs.map +1 -0
  211. package/dist/mime-utils.cjs +2 -0
  212. package/dist/mime-utils.d.cts +2 -0
  213. package/dist/mime-utils.d.mts +2 -0
  214. package/dist/mime-utils.mjs +3 -0
  215. package/dist/object-key.cjs +41 -0
  216. package/dist/object-key.d.cts +25 -0
  217. package/dist/object-key.d.cts.map +1 -0
  218. package/dist/object-key.d.mts +25 -0
  219. package/dist/object-key.d.mts.map +1 -0
  220. package/dist/object-key.mjs +40 -0
  221. package/dist/object-key.mjs.map +1 -0
  222. package/dist/packages/session/dist/index.cjs +788 -0
  223. package/dist/packages/session/dist/index.mjs +782 -0
  224. package/dist/packages/session/dist/index.mjs.map +1 -0
  225. package/dist/platform/r2/dist/types.d.cts +49 -0
  226. package/dist/platform/r2/dist/types.d.cts.map +1 -0
  227. package/dist/prefix-range.cjs +33 -0
  228. package/dist/prefix-range.d.cts +29 -0
  229. package/dist/prefix-range.d.cts.map +1 -0
  230. package/dist/prefix-range.d.mts +29 -0
  231. package/dist/prefix-range.d.mts.map +1 -0
  232. package/dist/prefix-range.mjs +33 -0
  233. package/dist/prefix-range.mjs.map +1 -0
  234. package/dist/prefixed-tree-index.cjs +238 -0
  235. package/dist/prefixed-tree-index.d.cts +85 -0
  236. package/dist/prefixed-tree-index.d.cts.map +1 -0
  237. package/dist/prefixed-tree-index.d.mts +85 -0
  238. package/dist/prefixed-tree-index.d.mts.map +1 -0
  239. package/dist/prefixed-tree-index.mjs +239 -0
  240. package/dist/prefixed-tree-index.mjs.map +1 -0
  241. package/dist/presign-signer.cjs +7 -0
  242. package/dist/presign-signer.d.cts +99 -0
  243. package/dist/presign-signer.d.cts.map +1 -0
  244. package/dist/presign-signer.d.mts +99 -0
  245. package/dist/presign-signer.d.mts.map +1 -0
  246. package/dist/presign-signer.mjs +7 -0
  247. package/dist/presign-signer.mjs.map +1 -0
  248. package/dist/providers/platform/r2/dist/index.d.mts +3 -0
  249. package/dist/providers/platform/r2/dist/types.d.mts +49 -0
  250. package/dist/providers/platform/r2/dist/types.d.mts.map +1 -0
  251. package/dist/reconcile.cjs +184 -0
  252. package/dist/reconcile.d.cts +26 -0
  253. package/dist/reconcile.d.cts.map +1 -0
  254. package/dist/reconcile.d.mts +26 -0
  255. package/dist/reconcile.d.mts.map +1 -0
  256. package/dist/reconcile.mjs +184 -0
  257. package/dist/reconcile.mjs.map +1 -0
  258. package/dist/reference-check.cjs +49 -0
  259. package/dist/reference-check.d.cts +10 -0
  260. package/dist/reference-check.d.cts.map +1 -0
  261. package/dist/reference-check.d.mts +10 -0
  262. package/dist/reference-check.d.mts.map +1 -0
  263. package/dist/reference-check.mjs +48 -0
  264. package/dist/reference-check.mjs.map +1 -0
  265. package/dist/remote-afs.cjs +681 -0
  266. package/dist/remote-afs.d.cts +236 -0
  267. package/dist/remote-afs.d.cts.map +1 -0
  268. package/dist/remote-afs.d.mts +236 -0
  269. package/dist/remote-afs.d.mts.map +1 -0
  270. package/dist/remote-afs.mjs +676 -0
  271. package/dist/remote-afs.mjs.map +1 -0
  272. package/dist/rename-guard.cjs +18 -0
  273. package/dist/rename-guard.mjs +18 -0
  274. package/dist/rename-guard.mjs.map +1 -0
  275. package/dist/resolve.cjs +260 -0
  276. package/dist/resolve.d.cts +113 -0
  277. package/dist/resolve.d.cts.map +1 -0
  278. package/dist/resolve.d.mts +113 -0
  279. package/dist/resolve.d.mts.map +1 -0
  280. package/dist/resolve.mjs +260 -0
  281. package/dist/resolve.mjs.map +1 -0
  282. package/dist/rsync-content.cjs +33 -0
  283. package/dist/rsync-content.mjs +33 -0
  284. package/dist/rsync-content.mjs.map +1 -0
  285. package/dist/rsync.cjs +400 -0
  286. package/dist/rsync.d.cts +157 -0
  287. package/dist/rsync.d.cts.map +1 -0
  288. package/dist/rsync.d.mts +157 -0
  289. package/dist/rsync.d.mts.map +1 -0
  290. package/dist/rsync.mjs +397 -0
  291. package/dist/rsync.mjs.map +1 -0
  292. package/dist/run-gc.cjs +57 -0
  293. package/dist/run-gc.d.cts +40 -0
  294. package/dist/run-gc.d.cts.map +1 -0
  295. package/dist/run-gc.d.mts +41 -0
  296. package/dist/run-gc.d.mts.map +1 -0
  297. package/dist/run-gc.mjs +57 -0
  298. package/dist/run-gc.mjs.map +1 -0
  299. package/dist/scope-id.cjs +70 -0
  300. package/dist/scope-id.d.cts +35 -0
  301. package/dist/scope-id.d.cts.map +1 -0
  302. package/dist/scope-id.d.mts +35 -0
  303. package/dist/scope-id.d.mts.map +1 -0
  304. package/dist/scope-id.mjs +68 -0
  305. package/dist/scope-id.mjs.map +1 -0
  306. package/dist/scope-migration-node.cjs +172 -0
  307. package/dist/scope-migration-node.d.cts +44 -0
  308. package/dist/scope-migration-node.d.cts.map +1 -0
  309. package/dist/scope-migration-node.d.mts +44 -0
  310. package/dist/scope-migration-node.d.mts.map +1 -0
  311. package/dist/scope-migration-node.mjs +171 -0
  312. package/dist/scope-migration-node.mjs.map +1 -0
  313. package/dist/scope-migration.cjs +155 -0
  314. package/dist/scope-migration.d.cts +65 -0
  315. package/dist/scope-migration.d.cts.map +1 -0
  316. package/dist/scope-migration.d.mts +65 -0
  317. package/dist/scope-migration.d.mts.map +1 -0
  318. package/dist/scope-migration.mjs +154 -0
  319. package/dist/scope-migration.mjs.map +1 -0
  320. package/dist/share-declaration.cjs +225 -0
  321. package/dist/share-declaration.d.cts +30 -0
  322. package/dist/share-declaration.d.cts.map +1 -0
  323. package/dist/share-declaration.d.mts +32 -0
  324. package/dist/share-declaration.d.mts.map +1 -0
  325. package/dist/share-declaration.mjs +221 -0
  326. package/dist/share-declaration.mjs.map +1 -0
  327. package/dist/share-hook.cjs +63 -0
  328. package/dist/share-hook.mjs +62 -0
  329. package/dist/share-hook.mjs.map +1 -0
  330. package/dist/share-resolve.cjs +176 -0
  331. package/dist/share-resolve.d.cts +36 -0
  332. package/dist/share-resolve.d.cts.map +1 -0
  333. package/dist/share-resolve.d.mts +36 -0
  334. package/dist/share-resolve.d.mts.map +1 -0
  335. package/dist/share-resolve.mjs +177 -0
  336. package/dist/share-resolve.mjs.map +1 -0
  337. package/dist/share-serve.cjs +145 -0
  338. package/dist/share-serve.d.cts +30 -0
  339. package/dist/share-serve.d.cts.map +1 -0
  340. package/dist/share-serve.d.mts +30 -0
  341. package/dist/share-serve.d.mts.map +1 -0
  342. package/dist/share-serve.mjs +144 -0
  343. package/dist/share-serve.mjs.map +1 -0
  344. package/dist/share-store.cjs +25 -0
  345. package/dist/share-store.d.cts +65 -0
  346. package/dist/share-store.d.cts.map +1 -0
  347. package/dist/share-store.d.mts +65 -0
  348. package/dist/share-store.d.mts.map +1 -0
  349. package/dist/share-store.mjs +25 -0
  350. package/dist/share-store.mjs.map +1 -0
  351. package/dist/share-virtual-path.cjs +102 -0
  352. package/dist/share-virtual-path.mjs +101 -0
  353. package/dist/share-virtual-path.mjs.map +1 -0
  354. package/dist/space-resolver.cjs +54 -0
  355. package/dist/space-resolver.d.cts +34 -0
  356. package/dist/space-resolver.d.cts.map +1 -0
  357. package/dist/space-resolver.d.mts +34 -0
  358. package/dist/space-resolver.d.mts.map +1 -0
  359. package/dist/space-resolver.mjs +55 -0
  360. package/dist/space-resolver.mjs.map +1 -0
  361. package/dist/sqlite-gc-queue.cjs +51 -0
  362. package/dist/sqlite-gc-queue.d.cts +22 -0
  363. package/dist/sqlite-gc-queue.d.cts.map +1 -0
  364. package/dist/sqlite-gc-queue.d.mts +22 -0
  365. package/dist/sqlite-gc-queue.d.mts.map +1 -0
  366. package/dist/sqlite-gc-queue.mjs +52 -0
  367. package/dist/sqlite-gc-queue.mjs.map +1 -0
  368. package/dist/sqlite-resolve-store.cjs +163 -0
  369. package/dist/sqlite-resolve-store.d.cts +50 -0
  370. package/dist/sqlite-resolve-store.d.cts.map +1 -0
  371. package/dist/sqlite-resolve-store.d.mts +50 -0
  372. package/dist/sqlite-resolve-store.d.mts.map +1 -0
  373. package/dist/sqlite-resolve-store.mjs +164 -0
  374. package/dist/sqlite-resolve-store.mjs.map +1 -0
  375. package/dist/sqlite-share-store.cjs +157 -0
  376. package/dist/sqlite-share-store.d.cts +31 -0
  377. package/dist/sqlite-share-store.d.cts.map +1 -0
  378. package/dist/sqlite-share-store.d.mts +31 -0
  379. package/dist/sqlite-share-store.d.mts.map +1 -0
  380. package/dist/sqlite-share-store.mjs +157 -0
  381. package/dist/sqlite-share-store.mjs.map +1 -0
  382. package/dist/sqlite-tree-index.cjs +901 -0
  383. package/dist/sqlite-tree-index.d.cts +107 -0
  384. package/dist/sqlite-tree-index.d.cts.map +1 -0
  385. package/dist/sqlite-tree-index.d.mts +107 -0
  386. package/dist/sqlite-tree-index.d.mts.map +1 -0
  387. package/dist/sqlite-tree-index.mjs +902 -0
  388. package/dist/sqlite-tree-index.mjs.map +1 -0
  389. package/dist/sync-engine.cjs +1324 -0
  390. package/dist/sync-engine.d.cts +473 -0
  391. package/dist/sync-engine.d.cts.map +1 -0
  392. package/dist/sync-engine.d.mts +473 -0
  393. package/dist/sync-engine.d.mts.map +1 -0
  394. package/dist/sync-engine.mjs +1315 -0
  395. package/dist/sync-engine.mjs.map +1 -0
  396. package/dist/sync-state.cjs +303 -0
  397. package/dist/sync-state.d.cts +224 -0
  398. package/dist/sync-state.d.cts.map +1 -0
  399. package/dist/sync-state.d.mts +224 -0
  400. package/dist/sync-state.d.mts.map +1 -0
  401. package/dist/sync-state.mjs +297 -0
  402. package/dist/sync-state.mjs.map +1 -0
  403. package/dist/timestamp.cjs +92 -0
  404. package/dist/timestamp.mjs +91 -0
  405. package/dist/timestamp.mjs.map +1 -0
  406. package/dist/transports/http.cjs +54 -0
  407. package/dist/transports/http.d.cts +26 -0
  408. package/dist/transports/http.d.cts.map +1 -0
  409. package/dist/transports/http.d.mts +26 -0
  410. package/dist/transports/http.d.mts.map +1 -0
  411. package/dist/transports/http.mjs +54 -0
  412. package/dist/transports/http.mjs.map +1 -0
  413. package/dist/transports/static.cjs +55 -0
  414. package/dist/transports/static.d.cts +28 -0
  415. package/dist/transports/static.d.cts.map +1 -0
  416. package/dist/transports/static.d.mts +28 -0
  417. package/dist/transports/static.d.mts.map +1 -0
  418. package/dist/transports/static.mjs +55 -0
  419. package/dist/transports/static.mjs.map +1 -0
  420. package/dist/transports/types.cjs +13 -0
  421. package/dist/transports/types.d.cts +72 -0
  422. package/dist/transports/types.d.cts.map +1 -0
  423. package/dist/transports/types.d.mts +72 -0
  424. package/dist/transports/types.d.mts.map +1 -0
  425. package/dist/transports/types.mjs +13 -0
  426. package/dist/transports/types.mjs.map +1 -0
  427. package/dist/transports/ws.cjs +207 -0
  428. package/dist/transports/ws.d.cts +47 -0
  429. package/dist/transports/ws.d.cts.map +1 -0
  430. package/dist/transports/ws.d.mts +47 -0
  431. package/dist/transports/ws.d.mts.map +1 -0
  432. package/dist/transports/ws.mjs +206 -0
  433. package/dist/transports/ws.mjs.map +1 -0
  434. package/dist/tree-index.cjs +333 -0
  435. package/dist/tree-index.d.cts +524 -0
  436. package/dist/tree-index.d.cts.map +1 -0
  437. package/dist/tree-index.d.mts +524 -0
  438. package/dist/tree-index.d.mts.map +1 -0
  439. package/dist/tree-index.mjs +322 -0
  440. package/dist/tree-index.mjs.map +1 -0
  441. package/dist/tree-query.cjs +655 -0
  442. package/dist/tree-query.d.cts +70 -0
  443. package/dist/tree-query.d.cts.map +1 -0
  444. package/dist/tree-query.d.mts +70 -0
  445. package/dist/tree-query.d.mts.map +1 -0
  446. package/dist/tree-query.mjs +648 -0
  447. package/dist/tree-query.mjs.map +1 -0
  448. package/dist/upload-actions.cjs +97 -0
  449. package/dist/upload-actions.d.cts +19 -0
  450. package/dist/upload-actions.d.cts.map +1 -0
  451. package/dist/upload-actions.d.mts +21 -0
  452. package/dist/upload-actions.d.mts.map +1 -0
  453. package/dist/upload-actions.mjs +90 -0
  454. package/dist/upload-actions.mjs.map +1 -0
  455. package/dist/upload-session-store.cjs +185 -0
  456. package/dist/upload-session-store.d.cts +99 -0
  457. package/dist/upload-session-store.d.cts.map +1 -0
  458. package/dist/upload-session-store.d.mts +99 -0
  459. package/dist/upload-session-store.d.mts.map +1 -0
  460. package/dist/upload-session-store.mjs +184 -0
  461. package/dist/upload-session-store.mjs.map +1 -0
  462. package/dist/url-normalize.cjs +61 -0
  463. package/dist/url-normalize.d.cts +33 -0
  464. package/dist/url-normalize.d.cts.map +1 -0
  465. package/dist/url-normalize.d.mts +33 -0
  466. package/dist/url-normalize.d.mts.map +1 -0
  467. package/dist/url-normalize.mjs +61 -0
  468. package/dist/url-normalize.mjs.map +1 -0
  469. package/dist/versioned-content-backends.cjs +155 -0
  470. package/dist/versioned-content-backends.d.cts +49 -0
  471. package/dist/versioned-content-backends.d.cts.map +1 -0
  472. package/dist/versioned-content-backends.d.mts +49 -0
  473. package/dist/versioned-content-backends.d.mts.map +1 -0
  474. package/dist/versioned-content-backends.mjs +154 -0
  475. package/dist/versioned-content-backends.mjs.map +1 -0
  476. package/dist/versioned-content-index.cjs +102 -0
  477. package/dist/versioned-content-index.d.cts +46 -0
  478. package/dist/versioned-content-index.d.cts.map +1 -0
  479. package/dist/versioned-content-index.d.mts +46 -0
  480. package/dist/versioned-content-index.d.mts.map +1 -0
  481. package/dist/versioned-content-index.mjs +103 -0
  482. package/dist/versioned-content-index.mjs.map +1 -0
  483. package/dist/versioned-content-store.cjs +121 -0
  484. package/dist/versioned-content-store.d.cts +90 -0
  485. package/dist/versioned-content-store.d.cts.map +1 -0
  486. package/dist/versioned-content-store.d.mts +90 -0
  487. package/dist/versioned-content-store.d.mts.map +1 -0
  488. package/dist/versioned-content-store.mjs +122 -0
  489. package/dist/versioned-content-store.mjs.map +1 -0
  490. package/dist/versioned-scope.cjs +39 -0
  491. package/dist/versioned-scope.d.cts +57 -0
  492. package/dist/versioned-scope.d.cts.map +1 -0
  493. package/dist/versioned-scope.d.mts +57 -0
  494. package/dist/versioned-scope.d.mts.map +1 -0
  495. package/dist/versioned-scope.mjs +37 -0
  496. package/dist/versioned-scope.mjs.map +1 -0
  497. package/migrations/0001_tree_entries.sql +17 -0
  498. package/migrations/0002_resolve_entries.sql +7 -0
  499. package/migrations/0003_entries_v2.sql +38 -0
  500. package/migrations/0004_gc_queue.sql +5 -0
  501. package/migrations/0006_resolve_enhance.sql +14 -0
  502. package/migrations/0007_resolve_created_at.sql +10 -0
  503. package/migrations/0008_changelog.sql +34 -0
  504. package/migrations/0009_device_sync_state.sql +29 -0
  505. package/migrations/0010_scope_meta.sql +33 -0
  506. package/migrations/0011_shares.sql +25 -0
  507. package/migrations/0012_scope_meta_file_count.sql +41 -0
  508. package/migrations/0013_scope_meta_total_bytes.sql +47 -0
  509. package/migrations/0014_rename_tables.sql +62 -0
  510. package/package.json +102 -0
@@ -0,0 +1,237 @@
1
+ //#region src/d1-schema.d.ts
2
+ /**
3
+ * D1 schema — the single source of truth for the did-space D1 DDL.
4
+ *
5
+ * Consumed by BOTH:
6
+ * 1. The runtime safety-net creators (`D1TreeIndex.ensureTable`,
7
+ * `D1ResolveStore.ensureTable`, `D1GCQueue.ensureTable`) — fresh-DB
8
+ * bootstrap for tests / first-ever deploys.
9
+ * 2. The generated wrangler migration (`0100_did_space_schema.sql`,
10
+ * assembled by runtimes/cloudflare/scripts/apply-d1-migrations.mjs) —
11
+ * the deploy-time path that lets production isolates SKIP the runtime
12
+ * schema probe entirely (`AFS_SKIP_SCHEMA_PROBE`).
13
+ *
14
+ * Because the migration is GENERATED from these constants at build time,
15
+ * the two paths cannot drift — there is no hand-maintained SQL copy.
16
+ * (Same single-source pattern as changelog-schema.ts, which keeps the four
17
+ * device runtimes byte-equivalent.)
18
+ *
19
+ * Every statement is idempotent (`IF NOT EXISTS`) so re-applying on an
20
+ * existing database — including one originally bootstrapped by the runtime
21
+ * path — is a no-op.
22
+ */
23
+ /**
24
+ * Inline-content column migration (Layer 0 inline capability, see
25
+ * `inline-content.ts`). Shipped as an ADDITIVE `ALTER TABLE` — NOT folded
26
+ * into `ENTRIES_TABLE_SQL` — because the generated 0100 migration is already
27
+ * recorded as applied on existing deployments and `ALTER TABLE ADD COLUMN`
28
+ * has no `IF NOT EXISTS` (folding it into the CREATE would make the additive
29
+ * migration fail on fresh databases with "duplicate column"). Same pattern
30
+ * as connect-service's 0002.
31
+ *
32
+ * Consumed by BOTH:
33
+ * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) — they
34
+ * probe `pragma_table_info('entries')` and apply this only when the
35
+ * column is missing;
36
+ * 2. the generated wrangler migration
37
+ * (`0102_entries_inline_content.sql`, apply-d1-migrations.mjs) — the
38
+ * deploy-time path, applied exactly once per database via the
39
+ * `d1_migrations` bookkeeping table.
40
+ *
41
+ * `LENGTH(CAST(content AS BLOB))` counts BYTES (TEXT `LENGTH()` counts
42
+ * characters and stops at an embedded NUL) — the hard cap is a byte cap.
43
+ * The CHECK is the fixed defensive upper bound; the configurable app-level
44
+ * threshold lives in `inline-content.ts` (two values, never conflated).
45
+ */
46
+ declare const ENTRIES_INLINE_CONTENT_COLUMN_SQL = "ALTER TABLE ds_entries ADD COLUMN content TEXT CHECK (content IS NULL OR LENGTH(CAST(content AS BLOB)) <= 65536)";
47
+ /**
48
+ * Application metadata column (planning/agent-hub/metadata-foundation.md).
49
+ * Stores `AFSWriteEntryPayload.meta` as a JSON blob — application-level
50
+ * dimension fields (`user_did / blocklet_id / hub / model / cost / ...`)
51
+ * that the application uses for filter / aggregate via collection-query's
52
+ * `meta.*` paths. NULL when the application wrote no meta. Provider-computed
53
+ * fields (`kind / size / cid / mimeType`) are NOT stored here — they live
54
+ * in their own columns and are merged into `entry.meta` at read time.
55
+ *
56
+ * Shipped as an ADDITIVE ALTER (same reasoning as
57
+ * `ENTRIES_INLINE_CONTENT_COLUMN_SQL`): the generated 0100 migration is
58
+ * already applied on existing deployments and ADD COLUMN has no
59
+ * IF NOT EXISTS, so this must stay separate from `ENTRIES_TABLE_SQL`.
60
+ *
61
+ * Consumed by BOTH:
62
+ * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) —
63
+ * they probe `pragma_table_info('entries')` and apply this only when
64
+ * the column is missing;
65
+ * 2. the generated wrangler migration
66
+ * (`0107_entries_metadata.sql`, apply-d1-migrations.mjs).
67
+ */
68
+ declare const ENTRIES_METADATA_COLUMN_SQL = "ALTER TABLE ds_entries ADD COLUMN metadata TEXT";
69
+ /**
70
+ * Dedup-on-write secondary index columns (#1159). Replace the old
71
+ * cid-in-path dedup scheme (`{collection}/{cid(url)}.json`) with a real
72
+ * DB-enforced unique index so a dedup record lives at a stable readable path
73
+ * (`{collection}/{uuid}.json`) and dedup resolves via an O(log n) point seek —
74
+ * not a `json_extract` scan and not a normalization-derived filename.
75
+ *
76
+ * - `dedup_scope` = the collection the record dedups within (the write `path`),
77
+ * deliberately decoupled from the row's physical `parent` so flat and legacy
78
+ * dir-per-record layouts dedup against the same scope.
79
+ * - `dedup_key` = the normalized identity value (e.g. `normalizeItemUrl`).
80
+ *
81
+ * Shipped as ADDITIVE `ALTER`s (same reasoning as the inline-content / metadata
82
+ * columns: the base `ENTRIES_TABLE_SQL` and the generated 0100 migration are
83
+ * already applied on existing deployments, and `ADD COLUMN` has no
84
+ * `IF NOT EXISTS`). The partial UNIQUE index is created AFTER both columns
85
+ * exist. Precedent for the composite unique: `SHARES_TABLE_SQL`'s
86
+ * `UNIQUE(owner_did, decl_path)`.
87
+ *
88
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
89
+ * `MetadataDB.open`) and the generated wrangler migration
90
+ * (`0117_entries_dedup.sql`, apply-d1-migrations.mjs).
91
+ */
92
+ declare const ENTRIES_DEDUP_SCOPE_COLUMN_SQL = "ALTER TABLE ds_entries ADD COLUMN dedup_scope TEXT";
93
+ declare const ENTRIES_DEDUP_KEY_COLUMN_SQL = "ALTER TABLE ds_entries ADD COLUMN dedup_key TEXT";
94
+ /**
95
+ * Partial UNIQUE index backing dedup-on-write. `WHERE dedup_key IS NOT NULL`
96
+ * keeps every non-dedup row (the overwhelming majority) out of the index, so it
97
+ * costs nothing for normal writes and only enforces uniqueness among records
98
+ * that opted into dedup. This is BOTH the fast lookup path (`findByDedupKey`)
99
+ * AND the concurrency backstop (a racing create collides here, the loser
100
+ * re-queries and merges).
101
+ */
102
+ declare const ENTRIES_DEDUP_INDEX_SQL = "CREATE UNIQUE INDEX IF NOT EXISTS idx_entries_dedup ON ds_entries(scope, dedup_scope, dedup_key) WHERE dedup_key IS NOT NULL";
103
+ /**
104
+ * Content-type virtual generated column (#1293). Materializes `$.type` from
105
+ * the inline-content JSON column. Virtual (not stored): zero write overhead —
106
+ * the value is computed on read from the already-present `content` column,
107
+ * NULL for entries whose `content` is NULL or is not valid JSON / lacks a
108
+ * `$.type` field.
109
+ *
110
+ * The column is RETAINED but INERT (#1367): its backing index
111
+ * `idx_entries_content_type` has been dropped (see
112
+ * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` below) because no query ever referenced
113
+ * the generated column by name — collection-query's `compileLeaf` emits
114
+ * `lower(json_extract(content, '$.type')) = lower(?)` (tree-query.ts), which
115
+ * SQLite's expression-index equivalence cannot rewrite to `WHERE content_type
116
+ * = ?`, so the index was never hit and only taxed every write. The virtual
117
+ * column costs nothing (computed on read, currently never read) and is left in
118
+ * place; whether rare-type filtering is re-homed (via the generic `metadata`
119
+ * `meta.*` channel, NOT by the provider reaching into `content`) is the open
120
+ * decision in #1367. `$.type` is aside application schema; a generic storage
121
+ * provider should not hard-code it — hence no runtime re-creation of the index.
122
+ *
123
+ * Shipped as an ADDITIVE `ALTER` (same reasoning as every prior additive
124
+ * column: the generated 0100 migration is already recorded as applied on
125
+ * existing deployments and `ALTER TABLE ADD COLUMN` has no `IF NOT EXISTS`).
126
+ * SQLite explicitly permits virtual generated columns in `ALTER TABLE ADD
127
+ * COLUMN` — stored generated columns are prohibited, virtual ones are not.
128
+ *
129
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
130
+ * `MetadataDB.open`) and the generated wrangler migration
131
+ * (`0120_entries_content_type.sql`, apply-d1-migrations.mjs).
132
+ */
133
+ declare const ENTRIES_CONTENT_TYPE_COLUMN_SQL = "ALTER TABLE ds_entries ADD COLUMN content_type TEXT GENERATED ALWAYS AS (CASE WHEN json_valid(content) THEN json_extract(content, '$.type') ELSE NULL END) VIRTUAL";
134
+ /**
135
+ * The original composite index for the aside feed rare-type filter (#1293).
136
+ *
137
+ * RETAINED SOLELY to regenerate the already-shipped `0120` migration
138
+ * byte-for-byte (a shipped migration must never change — `d1_migrations`
139
+ * tracks by filename, so mutating 0120 would be silently skipped on deployed
140
+ * DBs anyway). It is NO LONGER created at runtime and is dropped by
141
+ * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` / migration `0121` (#1367): nothing
142
+ * ever emitted `WHERE content_type = ?`, so it was pure write-cost tax.
143
+ */
144
+ declare const ENTRIES_CONTENT_TYPE_INDEX_SQL = "CREATE INDEX IF NOT EXISTS idx_entries_content_type ON ds_entries(scope, parent, content_type, ctime)";
145
+ /**
146
+ * Drop of the unused `idx_entries_content_type` (#1367). This is the reversing
147
+ * DDL for the historical `ENTRIES_CONTENT_TYPE_INDEX_SQL` create: the index
148
+ * was never wired to any query (see the column comment above) and only added
149
+ * B-tree maintenance to every `ds_entries` insert. Dropping it removes 100% of
150
+ * that waste; the virtual column itself stays (zero cost).
151
+ *
152
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
153
+ * `MetadataDB.open`) — as an idempotent one-time cleanup for existing DBs that
154
+ * a prior `ensureTable` already indexed — AND the generated wrangler migration
155
+ * (`0121_drop_content_type_index.sql`, apply-d1-migrations.mjs) for
156
+ * schema-probe-skipped production isolates.
157
+ */
158
+ declare const ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL = "DROP INDEX IF EXISTS idx_entries_content_type";
159
+ /** entries — the tree index (one row per file/dir node, scoped per user DID). */
160
+ declare const ENTRIES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_entries (\n scope TEXT NOT NULL,\n path TEXT NOT NULL,\n parent TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'file',\n cid TEXT,\n size INTEGER NOT NULL DEFAULT 0,\n mime_type TEXT,\n ctime INTEGER NOT NULL,\n mtime INTEGER NOT NULL,\n PRIMARY KEY (scope, path),\n CHECK (LENGTH(path) <= 4096),\n CHECK (LENGTH(name) <= 255),\n CHECK (kind IN ('file', 'dir')),\n CHECK (LENGTH(scope) <= 128)\n ) WITHOUT ROWID";
161
+ /** entries indexes. Order matches the historical ensureTable batch. */
162
+ declare const ENTRIES_INDEX_SQL: readonly string[];
163
+ /**
164
+ * versioned_scopes — completion markers for the versioned content store
165
+ * (Layer 1, `versioned-content-store.ts`). One row per fully-materialized
166
+ * scope; `seed_digest` is a metadata column (dev-mode stale detection),
167
+ * NEVER part of the scope key. Additive table — ships as the generated
168
+ * 0103 migration plus runtime ensureTable guards (idempotent CREATEs).
169
+ */
170
+ declare const VERSIONED_SCOPES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_versioned_scopes (\n scope TEXT PRIMARY KEY,\n scope_group TEXT NOT NULL,\n seed_digest TEXT,\n ingested_at INTEGER NOT NULL,\n file_count INTEGER NOT NULL DEFAULT 0,\n CHECK (LENGTH(scope) <= 128),\n CHECK (LENGTH(scope_group) <= 128)\n )";
171
+ declare const VERSIONED_SCOPES_INDEX_SQL: readonly string[];
172
+ /**
173
+ * shares — materialised index of `.share` declaration files (share-out).
174
+ *
175
+ * Owner-scoped composite identity key `UNIQUE(owner_did, decl_path)`: the same
176
+ * relative `decl_path` (`.share`, `docs/.share`) is legitimately reusable by
177
+ * different owners that share one D1 (CF) or one daemon-global `_shares.db`
178
+ * (Node). `slug` stays globally UNIQUE — it is the public URL identifier.
179
+ *
180
+ * Single source of truth (same pattern as VERSIONED_SCOPES_TABLE_SQL): this
181
+ * constant feeds BOTH `ShareStore.ensureTable()` (runtime safety-net) AND the
182
+ * provider's canonical `migrations/0011_shares.sql` + the generated CF
183
+ * migration `0104_shares.sql`. `share-migration.test.ts` asserts the file is
184
+ * byte-equal (after DDL normalisation) to these constants, so they cannot
185
+ * drift.
186
+ */
187
+ declare const SHARES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_shares (\n id TEXT PRIMARY KEY,\n owner_did TEXT NOT NULL,\n source_path TEXT NOT NULL,\n decl_path TEXT NOT NULL,\n slug TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL DEFAULT 'raw',\n status TEXT NOT NULL DEFAULT 'active',\n decl_cid TEXT,\n config_json TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE(owner_did, decl_path)\n )";
188
+ declare const SHARES_INDEX_SQL: readonly string[];
189
+ /** resolve_entries — the DID resolve store (key → value docs + owner/kind). */
190
+ declare const RESOLVE_ENTRIES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_resolve_entries (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n owner TEXT,\n kind TEXT,\n updated_at INTEGER,\n created_at INTEGER\n )";
191
+ /** resolve_entries indexes. Order matches the historical ensureTable sequence. */
192
+ declare const RESOLVE_ENTRIES_INDEX_SQL: readonly string[];
193
+ /** gc_queue — deferred-GC CID queue (GC plan §4.3, Model B global pool). */
194
+ declare const GC_QUEUE_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_gc_queue (\n cid TEXT NOT NULL,\n queued_at INTEGER NOT NULL,\n PRIMARY KEY (cid)\n )";
195
+ /**
196
+ * gc_queue index. The deferred-GC sweep (`GcQueue.fetchCandidates`) selects
197
+ * `WHERE queued_at <= ? LIMIT ?` every cron tick. With only the `cid` primary
198
+ * key, that predicate has no usable index and full-scans the whole queue —
199
+ * `rows_read` grows with queue size (D1 Insights measured ~15k rows read per
200
+ * sweep at near-zero efficiency), the classic D1 rows_read cliff. This index
201
+ * makes the grace-boundary scan a range seek. Mirrors the table+index pairing
202
+ * the sibling base tables (entries/changelog/resolve_entries) already use.
203
+ */
204
+ declare const GC_QUEUE_INDEX_SQL: readonly string[];
205
+ /**
206
+ * upload_sessions — recoverable in-flight upload session registry (DID Space
207
+ * upload plane, design §9). Holds the prepared/committed/aborted lifecycle so
208
+ * (a) commit can re-validate against the prepared contract, and (b) GC can
209
+ * protect objects referenced by a non-expired `prepared` session (in-flight
210
+ * protection, §9 / reference-check.ts).
211
+ *
212
+ * scope de-identification discipline (§9, NON-negotiable): `scope` is the SAME
213
+ * `this._scope` derived value as `entries.scope` / `changelog.scope` (an opaque
214
+ * HMAC when de-id is on), NEVER a plaintext DID — `CHECK(LENGTH(scope)<=128)`
215
+ * mirrors `entries`. `caller` may hold ONLY a blocklet bareInstanceId (app DID),
216
+ * never a user `did:abt:` — a raw D1 dump must not re-attribute uploads to users.
217
+ */
218
+ declare const UPLOAD_SESSIONS_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_upload_sessions (\n id TEXT PRIMARY KEY,\n scope TEXT NOT NULL,\n caller TEXT,\n expires_at INTEGER NOT NULL,\n status TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n CHECK (LENGTH(scope) <= 128),\n CHECK (status IN ('prepared','committed','aborted','expired'))\n )";
219
+ /**
220
+ * upload_session_entries — per-entry rows of an upload session. Carries NO
221
+ * independent identity column: it joins back to `upload_sessions` via
222
+ * `session_id` (§9 scope discipline — never duplicate the scope/DID here).
223
+ */
224
+ declare const UPLOAD_SESSION_ENTRIES_TABLE_SQL = "CREATE TABLE IF NOT EXISTS ds_upload_session_entries (\n session_id TEXT NOT NULL,\n path TEXT NOT NULL,\n cid TEXT NOT NULL,\n object_key TEXT NOT NULL,\n checksum_sha256 TEXT NOT NULL,\n size INTEGER NOT NULL,\n mime_type TEXT,\n if_match TEXT,\n device_id TEXT,\n mtime INTEGER,\n status TEXT NOT NULL,\n PRIMARY KEY (session_id, path),\n CHECK (status IN ('needs_upload','already_present','committed','failed'))\n )";
225
+ declare const UPLOAD_SESSIONS_INDEX_SQL: readonly string[];
226
+ /**
227
+ * The complete did-space D1 schema, in apply order — exactly the statements
228
+ * `CloudflareSpaceResolver.ensureTables` would issue on a fresh database
229
+ * (TreeIndex: entries + changelog; ResolveStore; GCQueue). The generated
230
+ * migration serializes THIS list; the runtime probe checks for the four
231
+ * table names this list creates (entries, changelog, resolve_entries,
232
+ * gc_queue).
233
+ */
234
+ declare const D1_DID_SPACE_SCHEMA_SQL: readonly string[];
235
+ //#endregion
236
+ export { D1_DID_SPACE_SCHEMA_SQL, ENTRIES_CONTENT_TYPE_COLUMN_SQL, ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL, ENTRIES_CONTENT_TYPE_INDEX_SQL, ENTRIES_DEDUP_INDEX_SQL, ENTRIES_DEDUP_KEY_COLUMN_SQL, ENTRIES_DEDUP_SCOPE_COLUMN_SQL, ENTRIES_INDEX_SQL, ENTRIES_INLINE_CONTENT_COLUMN_SQL, ENTRIES_METADATA_COLUMN_SQL, ENTRIES_TABLE_SQL, GC_QUEUE_INDEX_SQL, GC_QUEUE_TABLE_SQL, RESOLVE_ENTRIES_INDEX_SQL, RESOLVE_ENTRIES_TABLE_SQL, SHARES_INDEX_SQL, SHARES_TABLE_SQL, UPLOAD_SESSIONS_INDEX_SQL, UPLOAD_SESSIONS_TABLE_SQL, UPLOAD_SESSION_ENTRIES_TABLE_SQL, VERSIONED_SCOPES_INDEX_SQL, VERSIONED_SCOPES_TABLE_SQL };
237
+ //# sourceMappingURL=d1-schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d1-schema.d.mts","names":[],"sources":["../src/d1-schema.ts"],"mappings":";;AAgDA;;;;;AAuBA;;;;;AAyBA;;;;;AACA;;;;;AAUA;;;;;AAgCA;;;;;AAYA;;;;;AAeA;;;;;AAGA;;;AA9DA,cA3Da,iCAAA;;AA4Ib;;;;;AA4BA;;;;;AAUA;;;;;AAmBA;;;;;cA9Ka,2BAAA;;;;;AAoMb;;;;;AAUA;;;;;AAQA;;;;;AAeA;;;;cA5Ma,8BAAA;AAAA,cACA,4BAAA;;;;;AA4Ob;;;;cAlOa,uBAAA;AAkPb;;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;AAtBA,cAlNa,+BAAA;;;;;;;;;;;cAYA,8BAAA;;;;;;;;;;;;;;cAeA,mCAAA;;cAGA,iBAAA;;cAmBA,iBAAA;;;;;;;;cA4BA,0BAAA;AAAA,cAUA,0BAAA;;;;;;;;;;;;;;;;cAmBA,gBAAA;AAAA,cAeA,gBAAA;;cAOA,yBAAA;;cAUA,yBAAA;;cAQA,kBAAA;;;;;;;;;;cAeA,kBAAA;;;;;;;;;;;;;;cAiBA,yBAAA;;;;;;cAgBA,gCAAA;AAAA,cAgBA,yBAAA;;;;;;;;;cAsBA,uBAAA"}
@@ -0,0 +1,341 @@
1
+ import { CHANGELOG_INDEX_SQL, CHANGELOG_TABLE_SQL } from "./changelog-schema.mjs";
2
+ import { INLINE_CONTENT_HARD_CAP } from "./inline-content.mjs";
3
+
4
+ //#region src/d1-schema.ts
5
+ /**
6
+ * D1 schema — the single source of truth for the did-space D1 DDL.
7
+ *
8
+ * Consumed by BOTH:
9
+ * 1. The runtime safety-net creators (`D1TreeIndex.ensureTable`,
10
+ * `D1ResolveStore.ensureTable`, `D1GCQueue.ensureTable`) — fresh-DB
11
+ * bootstrap for tests / first-ever deploys.
12
+ * 2. The generated wrangler migration (`0100_did_space_schema.sql`,
13
+ * assembled by runtimes/cloudflare/scripts/apply-d1-migrations.mjs) —
14
+ * the deploy-time path that lets production isolates SKIP the runtime
15
+ * schema probe entirely (`AFS_SKIP_SCHEMA_PROBE`).
16
+ *
17
+ * Because the migration is GENERATED from these constants at build time,
18
+ * the two paths cannot drift — there is no hand-maintained SQL copy.
19
+ * (Same single-source pattern as changelog-schema.ts, which keeps the four
20
+ * device runtimes byte-equivalent.)
21
+ *
22
+ * Every statement is idempotent (`IF NOT EXISTS`) so re-applying on an
23
+ * existing database — including one originally bootstrapped by the runtime
24
+ * path — is a no-op.
25
+ */
26
+ /**
27
+ * Inline-content column migration (Layer 0 inline capability, see
28
+ * `inline-content.ts`). Shipped as an ADDITIVE `ALTER TABLE` — NOT folded
29
+ * into `ENTRIES_TABLE_SQL` — because the generated 0100 migration is already
30
+ * recorded as applied on existing deployments and `ALTER TABLE ADD COLUMN`
31
+ * has no `IF NOT EXISTS` (folding it into the CREATE would make the additive
32
+ * migration fail on fresh databases with "duplicate column"). Same pattern
33
+ * as connect-service's 0002.
34
+ *
35
+ * Consumed by BOTH:
36
+ * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) — they
37
+ * probe `pragma_table_info('entries')` and apply this only when the
38
+ * column is missing;
39
+ * 2. the generated wrangler migration
40
+ * (`0102_entries_inline_content.sql`, apply-d1-migrations.mjs) — the
41
+ * deploy-time path, applied exactly once per database via the
42
+ * `d1_migrations` bookkeeping table.
43
+ *
44
+ * `LENGTH(CAST(content AS BLOB))` counts BYTES (TEXT `LENGTH()` counts
45
+ * characters and stops at an embedded NUL) — the hard cap is a byte cap.
46
+ * The CHECK is the fixed defensive upper bound; the configurable app-level
47
+ * threshold lives in `inline-content.ts` (two values, never conflated).
48
+ */
49
+ const ENTRIES_INLINE_CONTENT_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN content TEXT CHECK (content IS NULL OR LENGTH(CAST(content AS BLOB)) <= ${INLINE_CONTENT_HARD_CAP})`;
50
+ /**
51
+ * Application metadata column (planning/agent-hub/metadata-foundation.md).
52
+ * Stores `AFSWriteEntryPayload.meta` as a JSON blob — application-level
53
+ * dimension fields (`user_did / blocklet_id / hub / model / cost / ...`)
54
+ * that the application uses for filter / aggregate via collection-query's
55
+ * `meta.*` paths. NULL when the application wrote no meta. Provider-computed
56
+ * fields (`kind / size / cid / mimeType`) are NOT stored here — they live
57
+ * in their own columns and are merged into `entry.meta` at read time.
58
+ *
59
+ * Shipped as an ADDITIVE ALTER (same reasoning as
60
+ * `ENTRIES_INLINE_CONTENT_COLUMN_SQL`): the generated 0100 migration is
61
+ * already applied on existing deployments and ADD COLUMN has no
62
+ * IF NOT EXISTS, so this must stay separate from `ENTRIES_TABLE_SQL`.
63
+ *
64
+ * Consumed by BOTH:
65
+ * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) —
66
+ * they probe `pragma_table_info('entries')` and apply this only when
67
+ * the column is missing;
68
+ * 2. the generated wrangler migration
69
+ * (`0107_entries_metadata.sql`, apply-d1-migrations.mjs).
70
+ */
71
+ const ENTRIES_METADATA_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN metadata TEXT`;
72
+ /**
73
+ * Dedup-on-write secondary index columns (#1159). Replace the old
74
+ * cid-in-path dedup scheme (`{collection}/{cid(url)}.json`) with a real
75
+ * DB-enforced unique index so a dedup record lives at a stable readable path
76
+ * (`{collection}/{uuid}.json`) and dedup resolves via an O(log n) point seek —
77
+ * not a `json_extract` scan and not a normalization-derived filename.
78
+ *
79
+ * - `dedup_scope` = the collection the record dedups within (the write `path`),
80
+ * deliberately decoupled from the row's physical `parent` so flat and legacy
81
+ * dir-per-record layouts dedup against the same scope.
82
+ * - `dedup_key` = the normalized identity value (e.g. `normalizeItemUrl`).
83
+ *
84
+ * Shipped as ADDITIVE `ALTER`s (same reasoning as the inline-content / metadata
85
+ * columns: the base `ENTRIES_TABLE_SQL` and the generated 0100 migration are
86
+ * already applied on existing deployments, and `ADD COLUMN` has no
87
+ * `IF NOT EXISTS`). The partial UNIQUE index is created AFTER both columns
88
+ * exist. Precedent for the composite unique: `SHARES_TABLE_SQL`'s
89
+ * `UNIQUE(owner_did, decl_path)`.
90
+ *
91
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
92
+ * `MetadataDB.open`) and the generated wrangler migration
93
+ * (`0117_entries_dedup.sql`, apply-d1-migrations.mjs).
94
+ */
95
+ const ENTRIES_DEDUP_SCOPE_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN dedup_scope TEXT`;
96
+ const ENTRIES_DEDUP_KEY_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN dedup_key TEXT`;
97
+ /**
98
+ * Partial UNIQUE index backing dedup-on-write. `WHERE dedup_key IS NOT NULL`
99
+ * keeps every non-dedup row (the overwhelming majority) out of the index, so it
100
+ * costs nothing for normal writes and only enforces uniqueness among records
101
+ * that opted into dedup. This is BOTH the fast lookup path (`findByDedupKey`)
102
+ * AND the concurrency backstop (a racing create collides here, the loser
103
+ * re-queries and merges).
104
+ */
105
+ const ENTRIES_DEDUP_INDEX_SQL = `CREATE UNIQUE INDEX IF NOT EXISTS idx_entries_dedup ON ds_entries(scope, dedup_scope, dedup_key) WHERE dedup_key IS NOT NULL`;
106
+ /**
107
+ * Content-type virtual generated column (#1293). Materializes `$.type` from
108
+ * the inline-content JSON column. Virtual (not stored): zero write overhead —
109
+ * the value is computed on read from the already-present `content` column,
110
+ * NULL for entries whose `content` is NULL or is not valid JSON / lacks a
111
+ * `$.type` field.
112
+ *
113
+ * The column is RETAINED but INERT (#1367): its backing index
114
+ * `idx_entries_content_type` has been dropped (see
115
+ * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` below) because no query ever referenced
116
+ * the generated column by name — collection-query's `compileLeaf` emits
117
+ * `lower(json_extract(content, '$.type')) = lower(?)` (tree-query.ts), which
118
+ * SQLite's expression-index equivalence cannot rewrite to `WHERE content_type
119
+ * = ?`, so the index was never hit and only taxed every write. The virtual
120
+ * column costs nothing (computed on read, currently never read) and is left in
121
+ * place; whether rare-type filtering is re-homed (via the generic `metadata`
122
+ * `meta.*` channel, NOT by the provider reaching into `content`) is the open
123
+ * decision in #1367. `$.type` is aside application schema; a generic storage
124
+ * provider should not hard-code it — hence no runtime re-creation of the index.
125
+ *
126
+ * Shipped as an ADDITIVE `ALTER` (same reasoning as every prior additive
127
+ * column: the generated 0100 migration is already recorded as applied on
128
+ * existing deployments and `ALTER TABLE ADD COLUMN` has no `IF NOT EXISTS`).
129
+ * SQLite explicitly permits virtual generated columns in `ALTER TABLE ADD
130
+ * COLUMN` — stored generated columns are prohibited, virtual ones are not.
131
+ *
132
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
133
+ * `MetadataDB.open`) and the generated wrangler migration
134
+ * (`0120_entries_content_type.sql`, apply-d1-migrations.mjs).
135
+ */
136
+ const ENTRIES_CONTENT_TYPE_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN content_type TEXT GENERATED ALWAYS AS (CASE WHEN json_valid(content) THEN json_extract(content, '$.type') ELSE NULL END) VIRTUAL`;
137
+ /**
138
+ * The original composite index for the aside feed rare-type filter (#1293).
139
+ *
140
+ * RETAINED SOLELY to regenerate the already-shipped `0120` migration
141
+ * byte-for-byte (a shipped migration must never change — `d1_migrations`
142
+ * tracks by filename, so mutating 0120 would be silently skipped on deployed
143
+ * DBs anyway). It is NO LONGER created at runtime and is dropped by
144
+ * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` / migration `0121` (#1367): nothing
145
+ * ever emitted `WHERE content_type = ?`, so it was pure write-cost tax.
146
+ */
147
+ const ENTRIES_CONTENT_TYPE_INDEX_SQL = `CREATE INDEX IF NOT EXISTS idx_entries_content_type ON ds_entries(scope, parent, content_type, ctime)`;
148
+ /**
149
+ * Drop of the unused `idx_entries_content_type` (#1367). This is the reversing
150
+ * DDL for the historical `ENTRIES_CONTENT_TYPE_INDEX_SQL` create: the index
151
+ * was never wired to any query (see the column comment above) and only added
152
+ * B-tree maintenance to every `ds_entries` insert. Dropping it removes 100% of
153
+ * that waste; the virtual column itself stays (zero cost).
154
+ *
155
+ * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,
156
+ * `MetadataDB.open`) — as an idempotent one-time cleanup for existing DBs that
157
+ * a prior `ensureTable` already indexed — AND the generated wrangler migration
158
+ * (`0121_drop_content_type_index.sql`, apply-d1-migrations.mjs) for
159
+ * schema-probe-skipped production isolates.
160
+ */
161
+ const ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL = `DROP INDEX IF EXISTS idx_entries_content_type`;
162
+ /** entries — the tree index (one row per file/dir node, scoped per user DID). */
163
+ const ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_entries (
164
+ scope TEXT NOT NULL,
165
+ path TEXT NOT NULL,
166
+ parent TEXT NOT NULL,
167
+ name TEXT NOT NULL,
168
+ kind TEXT NOT NULL DEFAULT 'file',
169
+ cid TEXT,
170
+ size INTEGER NOT NULL DEFAULT 0,
171
+ mime_type TEXT,
172
+ ctime INTEGER NOT NULL,
173
+ mtime INTEGER NOT NULL,
174
+ PRIMARY KEY (scope, path),
175
+ CHECK (LENGTH(path) <= 4096),
176
+ CHECK (LENGTH(name) <= 255),
177
+ CHECK (kind IN ('file', 'dir')),
178
+ CHECK (LENGTH(scope) <= 128)
179
+ ) WITHOUT ROWID`;
180
+ /** entries indexes. Order matches the historical ensureTable batch. */
181
+ const ENTRIES_INDEX_SQL = [
182
+ "CREATE INDEX IF NOT EXISTS idx_entries_children ON ds_entries(scope, parent, name)",
183
+ "CREATE INDEX IF NOT EXISTS idx_entries_cid ON ds_entries(cid) WHERE cid IS NOT NULL",
184
+ "CREATE INDEX IF NOT EXISTS idx_entries_mtime ON ds_entries(scope, mtime DESC)",
185
+ "CREATE INDEX IF NOT EXISTS idx_entries_kind ON ds_entries(scope, kind)",
186
+ "CREATE INDEX IF NOT EXISTS idx_entries_parent_mtime ON ds_entries(scope, parent, mtime, name)",
187
+ "CREATE INDEX IF NOT EXISTS idx_entries_parent_ctime ON ds_entries(scope, parent, ctime, name)"
188
+ ];
189
+ /**
190
+ * versioned_scopes — completion markers for the versioned content store
191
+ * (Layer 1, `versioned-content-store.ts`). One row per fully-materialized
192
+ * scope; `seed_digest` is a metadata column (dev-mode stale detection),
193
+ * NEVER part of the scope key. Additive table — ships as the generated
194
+ * 0103 migration plus runtime ensureTable guards (idempotent CREATEs).
195
+ */
196
+ const VERSIONED_SCOPES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_versioned_scopes (
197
+ scope TEXT PRIMARY KEY,
198
+ scope_group TEXT NOT NULL,
199
+ seed_digest TEXT,
200
+ ingested_at INTEGER NOT NULL,
201
+ file_count INTEGER NOT NULL DEFAULT 0,
202
+ CHECK (LENGTH(scope) <= 128),
203
+ CHECK (LENGTH(scope_group) <= 128)
204
+ )`;
205
+ const VERSIONED_SCOPES_INDEX_SQL = ["CREATE INDEX IF NOT EXISTS idx_versioned_scopes_group ON ds_versioned_scopes(scope_group)"];
206
+ /**
207
+ * shares — materialised index of `.share` declaration files (share-out).
208
+ *
209
+ * Owner-scoped composite identity key `UNIQUE(owner_did, decl_path)`: the same
210
+ * relative `decl_path` (`.share`, `docs/.share`) is legitimately reusable by
211
+ * different owners that share one D1 (CF) or one daemon-global `_shares.db`
212
+ * (Node). `slug` stays globally UNIQUE — it is the public URL identifier.
213
+ *
214
+ * Single source of truth (same pattern as VERSIONED_SCOPES_TABLE_SQL): this
215
+ * constant feeds BOTH `ShareStore.ensureTable()` (runtime safety-net) AND the
216
+ * provider's canonical `migrations/0011_shares.sql` + the generated CF
217
+ * migration `0104_shares.sql`. `share-migration.test.ts` asserts the file is
218
+ * byte-equal (after DDL normalisation) to these constants, so they cannot
219
+ * drift.
220
+ */
221
+ const SHARES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_shares (
222
+ id TEXT PRIMARY KEY,
223
+ owner_did TEXT NOT NULL,
224
+ source_path TEXT NOT NULL,
225
+ decl_path TEXT NOT NULL,
226
+ slug TEXT NOT NULL UNIQUE,
227
+ kind TEXT NOT NULL DEFAULT 'raw',
228
+ status TEXT NOT NULL DEFAULT 'active',
229
+ decl_cid TEXT,
230
+ config_json TEXT NOT NULL DEFAULT '{}',
231
+ created_at INTEGER NOT NULL,
232
+ updated_at INTEGER NOT NULL,
233
+ UNIQUE(owner_did, decl_path)
234
+ )`;
235
+ const SHARES_INDEX_SQL = [
236
+ "CREATE INDEX IF NOT EXISTS idx_shares_owner_did ON ds_shares(owner_did)",
237
+ "CREATE INDEX IF NOT EXISTS idx_shares_owner_source ON ds_shares(owner_did, source_path)",
238
+ "CREATE INDEX IF NOT EXISTS idx_shares_slug ON ds_shares(slug)"
239
+ ];
240
+ /** resolve_entries — the DID resolve store (key → value docs + owner/kind). */
241
+ const RESOLVE_ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_resolve_entries (
242
+ key TEXT PRIMARY KEY,
243
+ value TEXT NOT NULL,
244
+ owner TEXT,
245
+ kind TEXT,
246
+ updated_at INTEGER,
247
+ created_at INTEGER
248
+ )`;
249
+ /** resolve_entries indexes. Order matches the historical ensureTable sequence. */
250
+ const RESOLVE_ENTRIES_INDEX_SQL = [
251
+ "CREATE INDEX IF NOT EXISTS idx_resolve_owner ON ds_resolve_entries(owner)",
252
+ "CREATE INDEX IF NOT EXISTS idx_resolve_kind ON ds_resolve_entries(kind)",
253
+ "CREATE INDEX IF NOT EXISTS idx_resolve_updated ON ds_resolve_entries(updated_at)",
254
+ "CREATE INDEX IF NOT EXISTS idx_resolve_created ON ds_resolve_entries(created_at)"
255
+ ];
256
+ /** gc_queue — deferred-GC CID queue (GC plan §4.3, Model B global pool). */
257
+ const GC_QUEUE_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_gc_queue (
258
+ cid TEXT NOT NULL,
259
+ queued_at INTEGER NOT NULL,
260
+ PRIMARY KEY (cid)
261
+ )`;
262
+ /**
263
+ * gc_queue index. The deferred-GC sweep (`GcQueue.fetchCandidates`) selects
264
+ * `WHERE queued_at <= ? LIMIT ?` every cron tick. With only the `cid` primary
265
+ * key, that predicate has no usable index and full-scans the whole queue —
266
+ * `rows_read` grows with queue size (D1 Insights measured ~15k rows read per
267
+ * sweep at near-zero efficiency), the classic D1 rows_read cliff. This index
268
+ * makes the grace-boundary scan a range seek. Mirrors the table+index pairing
269
+ * the sibling base tables (entries/changelog/resolve_entries) already use.
270
+ */
271
+ const GC_QUEUE_INDEX_SQL = ["CREATE INDEX IF NOT EXISTS idx_gc_queue_queued_at ON ds_gc_queue(queued_at)"];
272
+ /**
273
+ * upload_sessions — recoverable in-flight upload session registry (DID Space
274
+ * upload plane, design §9). Holds the prepared/committed/aborted lifecycle so
275
+ * (a) commit can re-validate against the prepared contract, and (b) GC can
276
+ * protect objects referenced by a non-expired `prepared` session (in-flight
277
+ * protection, §9 / reference-check.ts).
278
+ *
279
+ * scope de-identification discipline (§9, NON-negotiable): `scope` is the SAME
280
+ * `this._scope` derived value as `entries.scope` / `changelog.scope` (an opaque
281
+ * HMAC when de-id is on), NEVER a plaintext DID — `CHECK(LENGTH(scope)<=128)`
282
+ * mirrors `entries`. `caller` may hold ONLY a blocklet bareInstanceId (app DID),
283
+ * never a user `did:abt:` — a raw D1 dump must not re-attribute uploads to users.
284
+ */
285
+ const UPLOAD_SESSIONS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_upload_sessions (
286
+ id TEXT PRIMARY KEY,
287
+ scope TEXT NOT NULL,
288
+ caller TEXT,
289
+ expires_at INTEGER NOT NULL,
290
+ status TEXT NOT NULL,
291
+ created_at INTEGER NOT NULL,
292
+ CHECK (LENGTH(scope) <= 128),
293
+ CHECK (status IN ('prepared','committed','aborted','expired'))
294
+ )`;
295
+ /**
296
+ * upload_session_entries — per-entry rows of an upload session. Carries NO
297
+ * independent identity column: it joins back to `upload_sessions` via
298
+ * `session_id` (§9 scope discipline — never duplicate the scope/DID here).
299
+ */
300
+ const UPLOAD_SESSION_ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_upload_session_entries (
301
+ session_id TEXT NOT NULL,
302
+ path TEXT NOT NULL,
303
+ cid TEXT NOT NULL,
304
+ object_key TEXT NOT NULL,
305
+ checksum_sha256 TEXT NOT NULL,
306
+ size INTEGER NOT NULL,
307
+ mime_type TEXT,
308
+ if_match TEXT,
309
+ device_id TEXT,
310
+ mtime INTEGER,
311
+ status TEXT NOT NULL,
312
+ PRIMARY KEY (session_id, path),
313
+ CHECK (status IN ('needs_upload','already_present','committed','failed'))
314
+ )`;
315
+ const UPLOAD_SESSIONS_INDEX_SQL = [
316
+ "CREATE INDEX IF NOT EXISTS idx_upload_session_entries_cid ON ds_upload_session_entries(cid)",
317
+ "CREATE INDEX IF NOT EXISTS idx_upload_sessions_expiry ON ds_upload_sessions(status, expires_at)",
318
+ "CREATE INDEX IF NOT EXISTS idx_upload_sessions_expires_at ON ds_upload_sessions(expires_at)"
319
+ ];
320
+ /**
321
+ * The complete did-space D1 schema, in apply order — exactly the statements
322
+ * `CloudflareSpaceResolver.ensureTables` would issue on a fresh database
323
+ * (TreeIndex: entries + changelog; ResolveStore; GCQueue). The generated
324
+ * migration serializes THIS list; the runtime probe checks for the four
325
+ * table names this list creates (entries, changelog, resolve_entries,
326
+ * gc_queue).
327
+ */
328
+ const D1_DID_SPACE_SCHEMA_SQL = [
329
+ ENTRIES_TABLE_SQL,
330
+ ...ENTRIES_INDEX_SQL,
331
+ CHANGELOG_TABLE_SQL,
332
+ ...CHANGELOG_INDEX_SQL,
333
+ RESOLVE_ENTRIES_TABLE_SQL,
334
+ ...RESOLVE_ENTRIES_INDEX_SQL,
335
+ GC_QUEUE_TABLE_SQL,
336
+ ...GC_QUEUE_INDEX_SQL
337
+ ];
338
+
339
+ //#endregion
340
+ export { D1_DID_SPACE_SCHEMA_SQL, ENTRIES_CONTENT_TYPE_COLUMN_SQL, ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL, ENTRIES_CONTENT_TYPE_INDEX_SQL, ENTRIES_DEDUP_INDEX_SQL, ENTRIES_DEDUP_KEY_COLUMN_SQL, ENTRIES_DEDUP_SCOPE_COLUMN_SQL, ENTRIES_INDEX_SQL, ENTRIES_INLINE_CONTENT_COLUMN_SQL, ENTRIES_METADATA_COLUMN_SQL, ENTRIES_TABLE_SQL, GC_QUEUE_INDEX_SQL, GC_QUEUE_TABLE_SQL, RESOLVE_ENTRIES_INDEX_SQL, RESOLVE_ENTRIES_TABLE_SQL, SHARES_INDEX_SQL, SHARES_TABLE_SQL, UPLOAD_SESSIONS_INDEX_SQL, UPLOAD_SESSIONS_TABLE_SQL, UPLOAD_SESSION_ENTRIES_TABLE_SQL, VERSIONED_SCOPES_INDEX_SQL, VERSIONED_SCOPES_TABLE_SQL };
341
+ //# sourceMappingURL=d1-schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d1-schema.mjs","names":[],"sources":["../src/d1-schema.ts"],"sourcesContent":["/**\n * D1 schema — the single source of truth for the did-space D1 DDL.\n *\n * Consumed by BOTH:\n * 1. The runtime safety-net creators (`D1TreeIndex.ensureTable`,\n * `D1ResolveStore.ensureTable`, `D1GCQueue.ensureTable`) — fresh-DB\n * bootstrap for tests / first-ever deploys.\n * 2. The generated wrangler migration (`0100_did_space_schema.sql`,\n * assembled by runtimes/cloudflare/scripts/apply-d1-migrations.mjs) —\n * the deploy-time path that lets production isolates SKIP the runtime\n * schema probe entirely (`AFS_SKIP_SCHEMA_PROBE`).\n *\n * Because the migration is GENERATED from these constants at build time,\n * the two paths cannot drift — there is no hand-maintained SQL copy.\n * (Same single-source pattern as changelog-schema.ts, which keeps the four\n * device runtimes byte-equivalent.)\n *\n * Every statement is idempotent (`IF NOT EXISTS`) so re-applying on an\n * existing database — including one originally bootstrapped by the runtime\n * path — is a no-op.\n */\n\nimport { CHANGELOG_INDEX_SQL, CHANGELOG_TABLE_SQL } from \"./changelog-schema.js\";\nimport { INLINE_CONTENT_HARD_CAP } from \"./inline-content.js\";\n\n/**\n * Inline-content column migration (Layer 0 inline capability, see\n * `inline-content.ts`). Shipped as an ADDITIVE `ALTER TABLE` — NOT folded\n * into `ENTRIES_TABLE_SQL` — because the generated 0100 migration is already\n * recorded as applied on existing deployments and `ALTER TABLE ADD COLUMN`\n * has no `IF NOT EXISTS` (folding it into the CREATE would make the additive\n * migration fail on fresh databases with \"duplicate column\"). Same pattern\n * as connect-service's 0002.\n *\n * Consumed by BOTH:\n * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) — they\n * probe `pragma_table_info('entries')` and apply this only when the\n * column is missing;\n * 2. the generated wrangler migration\n * (`0102_entries_inline_content.sql`, apply-d1-migrations.mjs) — the\n * deploy-time path, applied exactly once per database via the\n * `d1_migrations` bookkeeping table.\n *\n * `LENGTH(CAST(content AS BLOB))` counts BYTES (TEXT `LENGTH()` counts\n * characters and stops at an embedded NUL) — the hard cap is a byte cap.\n * The CHECK is the fixed defensive upper bound; the configurable app-level\n * threshold lives in `inline-content.ts` (two values, never conflated).\n */\nexport const ENTRIES_INLINE_CONTENT_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN content TEXT CHECK (content IS NULL OR LENGTH(CAST(content AS BLOB)) <= ${INLINE_CONTENT_HARD_CAP})`;\n\n/**\n * Application metadata column (planning/agent-hub/metadata-foundation.md).\n * Stores `AFSWriteEntryPayload.meta` as a JSON blob — application-level\n * dimension fields (`user_did / blocklet_id / hub / model / cost / ...`)\n * that the application uses for filter / aggregate via collection-query's\n * `meta.*` paths. NULL when the application wrote no meta. Provider-computed\n * fields (`kind / size / cid / mimeType`) are NOT stored here — they live\n * in their own columns and are merged into `entry.meta` at read time.\n *\n * Shipped as an ADDITIVE ALTER (same reasoning as\n * `ENTRIES_INLINE_CONTENT_COLUMN_SQL`): the generated 0100 migration is\n * already applied on existing deployments and ADD COLUMN has no\n * IF NOT EXISTS, so this must stay separate from `ENTRIES_TABLE_SQL`.\n *\n * Consumed by BOTH:\n * 1. runtime guards (`D1TreeIndex.ensureTable`, `MetadataDB.open`) —\n * they probe `pragma_table_info('entries')` and apply this only when\n * the column is missing;\n * 2. the generated wrangler migration\n * (`0107_entries_metadata.sql`, apply-d1-migrations.mjs).\n */\nexport const ENTRIES_METADATA_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN metadata TEXT`;\n\n/**\n * Dedup-on-write secondary index columns (#1159). Replace the old\n * cid-in-path dedup scheme (`{collection}/{cid(url)}.json`) with a real\n * DB-enforced unique index so a dedup record lives at a stable readable path\n * (`{collection}/{uuid}.json`) and dedup resolves via an O(log n) point seek —\n * not a `json_extract` scan and not a normalization-derived filename.\n *\n * - `dedup_scope` = the collection the record dedups within (the write `path`),\n * deliberately decoupled from the row's physical `parent` so flat and legacy\n * dir-per-record layouts dedup against the same scope.\n * - `dedup_key` = the normalized identity value (e.g. `normalizeItemUrl`).\n *\n * Shipped as ADDITIVE `ALTER`s (same reasoning as the inline-content / metadata\n * columns: the base `ENTRIES_TABLE_SQL` and the generated 0100 migration are\n * already applied on existing deployments, and `ADD COLUMN` has no\n * `IF NOT EXISTS`). The partial UNIQUE index is created AFTER both columns\n * exist. Precedent for the composite unique: `SHARES_TABLE_SQL`'s\n * `UNIQUE(owner_did, decl_path)`.\n *\n * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,\n * `MetadataDB.open`) and the generated wrangler migration\n * (`0117_entries_dedup.sql`, apply-d1-migrations.mjs).\n */\nexport const ENTRIES_DEDUP_SCOPE_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN dedup_scope TEXT`;\nexport const ENTRIES_DEDUP_KEY_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN dedup_key TEXT`;\n\n/**\n * Partial UNIQUE index backing dedup-on-write. `WHERE dedup_key IS NOT NULL`\n * keeps every non-dedup row (the overwhelming majority) out of the index, so it\n * costs nothing for normal writes and only enforces uniqueness among records\n * that opted into dedup. This is BOTH the fast lookup path (`findByDedupKey`)\n * AND the concurrency backstop (a racing create collides here, the loser\n * re-queries and merges).\n */\nexport const ENTRIES_DEDUP_INDEX_SQL = `CREATE UNIQUE INDEX IF NOT EXISTS idx_entries_dedup ON ds_entries(scope, dedup_scope, dedup_key) WHERE dedup_key IS NOT NULL`;\n\n/**\n * Content-type virtual generated column (#1293). Materializes `$.type` from\n * the inline-content JSON column. Virtual (not stored): zero write overhead —\n * the value is computed on read from the already-present `content` column,\n * NULL for entries whose `content` is NULL or is not valid JSON / lacks a\n * `$.type` field.\n *\n * The column is RETAINED but INERT (#1367): its backing index\n * `idx_entries_content_type` has been dropped (see\n * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` below) because no query ever referenced\n * the generated column by name — collection-query's `compileLeaf` emits\n * `lower(json_extract(content, '$.type')) = lower(?)` (tree-query.ts), which\n * SQLite's expression-index equivalence cannot rewrite to `WHERE content_type\n * = ?`, so the index was never hit and only taxed every write. The virtual\n * column costs nothing (computed on read, currently never read) and is left in\n * place; whether rare-type filtering is re-homed (via the generic `metadata`\n * `meta.*` channel, NOT by the provider reaching into `content`) is the open\n * decision in #1367. `$.type` is aside application schema; a generic storage\n * provider should not hard-code it — hence no runtime re-creation of the index.\n *\n * Shipped as an ADDITIVE `ALTER` (same reasoning as every prior additive\n * column: the generated 0100 migration is already recorded as applied on\n * existing deployments and `ALTER TABLE ADD COLUMN` has no `IF NOT EXISTS`).\n * SQLite explicitly permits virtual generated columns in `ALTER TABLE ADD\n * COLUMN` — stored generated columns are prohibited, virtual ones are not.\n *\n * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,\n * `MetadataDB.open`) and the generated wrangler migration\n * (`0120_entries_content_type.sql`, apply-d1-migrations.mjs).\n */\nexport const ENTRIES_CONTENT_TYPE_COLUMN_SQL = `ALTER TABLE ds_entries ADD COLUMN content_type TEXT GENERATED ALWAYS AS (CASE WHEN json_valid(content) THEN json_extract(content, '$.type') ELSE NULL END) VIRTUAL`;\n\n/**\n * The original composite index for the aside feed rare-type filter (#1293).\n *\n * RETAINED SOLELY to regenerate the already-shipped `0120` migration\n * byte-for-byte (a shipped migration must never change — `d1_migrations`\n * tracks by filename, so mutating 0120 would be silently skipped on deployed\n * DBs anyway). It is NO LONGER created at runtime and is dropped by\n * `ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL` / migration `0121` (#1367): nothing\n * ever emitted `WHERE content_type = ?`, so it was pure write-cost tax.\n */\nexport const ENTRIES_CONTENT_TYPE_INDEX_SQL = `CREATE INDEX IF NOT EXISTS idx_entries_content_type ON ds_entries(scope, parent, content_type, ctime)`;\n\n/**\n * Drop of the unused `idx_entries_content_type` (#1367). This is the reversing\n * DDL for the historical `ENTRIES_CONTENT_TYPE_INDEX_SQL` create: the index\n * was never wired to any query (see the column comment above) and only added\n * B-tree maintenance to every `ds_entries` insert. Dropping it removes 100% of\n * that waste; the virtual column itself stays (zero cost).\n *\n * Consumed by BOTH runtime guards (`D1TreeIndex.ensureTable`,\n * `MetadataDB.open`) — as an idempotent one-time cleanup for existing DBs that\n * a prior `ensureTable` already indexed — AND the generated wrangler migration\n * (`0121_drop_content_type_index.sql`, apply-d1-migrations.mjs) for\n * schema-probe-skipped production isolates.\n */\nexport const ENTRIES_CONTENT_TYPE_INDEX_DROP_SQL = `DROP INDEX IF EXISTS idx_entries_content_type`;\n\n/** entries — the tree index (one row per file/dir node, scoped per user DID). */\nexport const ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_entries (\n scope TEXT NOT NULL,\n path TEXT NOT NULL,\n parent TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'file',\n cid TEXT,\n size INTEGER NOT NULL DEFAULT 0,\n mime_type TEXT,\n ctime INTEGER NOT NULL,\n mtime INTEGER NOT NULL,\n PRIMARY KEY (scope, path),\n CHECK (LENGTH(path) <= 4096),\n CHECK (LENGTH(name) <= 255),\n CHECK (kind IN ('file', 'dir')),\n CHECK (LENGTH(scope) <= 128)\n ) WITHOUT ROWID`;\n\n/** entries indexes. Order matches the historical ensureTable batch. */\nexport const ENTRIES_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_entries_children ON ds_entries(scope, parent, name)\",\n \"CREATE INDEX IF NOT EXISTS idx_entries_cid ON ds_entries(cid) WHERE cid IS NOT NULL\",\n \"CREATE INDEX IF NOT EXISTS idx_entries_mtime ON ds_entries(scope, mtime DESC)\",\n \"CREATE INDEX IF NOT EXISTS idx_entries_kind ON ds_entries(scope, kind)\",\n // Ordered listChildren (did-space-sorting Phase 2): WHERE scope=? AND\n // parent=? ORDER BY mtime|ctime <dir>, name <dir> — the trailing `name`\n // column makes the tiebreak index-only. ctime DESC is the aside feed's\n // hot query. size/mimeType ride the (scope, parent, name) scan for now\n // (observe before indexing). Additive only — existing deployments get\n // these via migration 0101.\n \"CREATE INDEX IF NOT EXISTS idx_entries_parent_mtime ON ds_entries(scope, parent, mtime, name)\",\n \"CREATE INDEX IF NOT EXISTS idx_entries_parent_ctime ON ds_entries(scope, parent, ctime, name)\",\n // No scope-composite cid index here: `entries` is WITHOUT ROWID with\n // PRIMARY KEY(scope, path), so SQLite appends the PK to every secondary\n // index — `idx_entries_cid` is physically (cid, scope, path) and already\n // serves `isReferencedMany`'s `scope=? AND cid IN(…) AND path-range` branch\n // as a tight covering seek (verified via EXPLAIN QUERY PLAN). Only the\n // rowid-keyed `changelog` table needs an explicit `(scope, cid)` index.\n];\n\n/**\n * versioned_scopes — completion markers for the versioned content store\n * (Layer 1, `versioned-content-store.ts`). One row per fully-materialized\n * scope; `seed_digest` is a metadata column (dev-mode stale detection),\n * NEVER part of the scope key. Additive table — ships as the generated\n * 0103 migration plus runtime ensureTable guards (idempotent CREATEs).\n */\nexport const VERSIONED_SCOPES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_versioned_scopes (\n scope TEXT PRIMARY KEY,\n scope_group TEXT NOT NULL,\n seed_digest TEXT,\n ingested_at INTEGER NOT NULL,\n file_count INTEGER NOT NULL DEFAULT 0,\n CHECK (LENGTH(scope) <= 128),\n CHECK (LENGTH(scope_group) <= 128)\n )`;\n\nexport const VERSIONED_SCOPES_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_versioned_scopes_group ON ds_versioned_scopes(scope_group)\",\n];\n\n/**\n * shares — materialised index of `.share` declaration files (share-out).\n *\n * Owner-scoped composite identity key `UNIQUE(owner_did, decl_path)`: the same\n * relative `decl_path` (`.share`, `docs/.share`) is legitimately reusable by\n * different owners that share one D1 (CF) or one daemon-global `_shares.db`\n * (Node). `slug` stays globally UNIQUE — it is the public URL identifier.\n *\n * Single source of truth (same pattern as VERSIONED_SCOPES_TABLE_SQL): this\n * constant feeds BOTH `ShareStore.ensureTable()` (runtime safety-net) AND the\n * provider's canonical `migrations/0011_shares.sql` + the generated CF\n * migration `0104_shares.sql`. `share-migration.test.ts` asserts the file is\n * byte-equal (after DDL normalisation) to these constants, so they cannot\n * drift.\n */\nexport const SHARES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_shares (\n id TEXT PRIMARY KEY,\n owner_did TEXT NOT NULL,\n source_path TEXT NOT NULL,\n decl_path TEXT NOT NULL,\n slug TEXT NOT NULL UNIQUE,\n kind TEXT NOT NULL DEFAULT 'raw',\n status TEXT NOT NULL DEFAULT 'active',\n decl_cid TEXT,\n config_json TEXT NOT NULL DEFAULT '{}',\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n UNIQUE(owner_did, decl_path)\n )`;\n\nexport const SHARES_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_shares_owner_did ON ds_shares(owner_did)\",\n \"CREATE INDEX IF NOT EXISTS idx_shares_owner_source ON ds_shares(owner_did, source_path)\",\n \"CREATE INDEX IF NOT EXISTS idx_shares_slug ON ds_shares(slug)\",\n];\n\n/** resolve_entries — the DID resolve store (key → value docs + owner/kind). */\nexport const RESOLVE_ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_resolve_entries (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n owner TEXT,\n kind TEXT,\n updated_at INTEGER,\n created_at INTEGER\n )`;\n\n/** resolve_entries indexes. Order matches the historical ensureTable sequence. */\nexport const RESOLVE_ENTRIES_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_resolve_owner ON ds_resolve_entries(owner)\",\n \"CREATE INDEX IF NOT EXISTS idx_resolve_kind ON ds_resolve_entries(kind)\",\n \"CREATE INDEX IF NOT EXISTS idx_resolve_updated ON ds_resolve_entries(updated_at)\",\n \"CREATE INDEX IF NOT EXISTS idx_resolve_created ON ds_resolve_entries(created_at)\",\n];\n\n/** gc_queue — deferred-GC CID queue (GC plan §4.3, Model B global pool). */\nexport const GC_QUEUE_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_gc_queue (\n cid TEXT NOT NULL,\n queued_at INTEGER NOT NULL,\n PRIMARY KEY (cid)\n )`;\n\n/**\n * gc_queue index. The deferred-GC sweep (`GcQueue.fetchCandidates`) selects\n * `WHERE queued_at <= ? LIMIT ?` every cron tick. With only the `cid` primary\n * key, that predicate has no usable index and full-scans the whole queue —\n * `rows_read` grows with queue size (D1 Insights measured ~15k rows read per\n * sweep at near-zero efficiency), the classic D1 rows_read cliff. This index\n * makes the grace-boundary scan a range seek. Mirrors the table+index pairing\n * the sibling base tables (entries/changelog/resolve_entries) already use.\n */\nexport const GC_QUEUE_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_gc_queue_queued_at ON ds_gc_queue(queued_at)\",\n];\n\n/**\n * upload_sessions — recoverable in-flight upload session registry (DID Space\n * upload plane, design §9). Holds the prepared/committed/aborted lifecycle so\n * (a) commit can re-validate against the prepared contract, and (b) GC can\n * protect objects referenced by a non-expired `prepared` session (in-flight\n * protection, §9 / reference-check.ts).\n *\n * scope de-identification discipline (§9, NON-negotiable): `scope` is the SAME\n * `this._scope` derived value as `entries.scope` / `changelog.scope` (an opaque\n * HMAC when de-id is on), NEVER a plaintext DID — `CHECK(LENGTH(scope)<=128)`\n * mirrors `entries`. `caller` may hold ONLY a blocklet bareInstanceId (app DID),\n * never a user `did:abt:` — a raw D1 dump must not re-attribute uploads to users.\n */\nexport const UPLOAD_SESSIONS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_upload_sessions (\n id TEXT PRIMARY KEY,\n scope TEXT NOT NULL,\n caller TEXT,\n expires_at INTEGER NOT NULL,\n status TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n CHECK (LENGTH(scope) <= 128),\n CHECK (status IN ('prepared','committed','aborted','expired'))\n )`;\n\n/**\n * upload_session_entries — per-entry rows of an upload session. Carries NO\n * independent identity column: it joins back to `upload_sessions` via\n * `session_id` (§9 scope discipline — never duplicate the scope/DID here).\n */\nexport const UPLOAD_SESSION_ENTRIES_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ds_upload_session_entries (\n session_id TEXT NOT NULL,\n path TEXT NOT NULL,\n cid TEXT NOT NULL,\n object_key TEXT NOT NULL,\n checksum_sha256 TEXT NOT NULL,\n size INTEGER NOT NULL,\n mime_type TEXT,\n if_match TEXT,\n device_id TEXT,\n mtime INTEGER,\n status TEXT NOT NULL,\n PRIMARY KEY (session_id, path),\n CHECK (status IN ('needs_upload','already_present','committed','failed'))\n )`;\n\nexport const UPLOAD_SESSIONS_INDEX_SQL: readonly string[] = [\n \"CREATE INDEX IF NOT EXISTS idx_upload_session_entries_cid ON ds_upload_session_entries(cid)\",\n \"CREATE INDEX IF NOT EXISTS idx_upload_sessions_expiry ON ds_upload_sessions(status, expires_at)\",\n // sweepExpired's predicate is `expires_at < ?` with NO status equality, so\n // idx_upload_sessions_expiry (status-leading) cannot serve it — both sweep\n // statements full-scan upload_sessions (EXPLAIN: `SCAN upload_sessions`;\n // production D1 measured ~2k rows_read per sweep call during upload bursts).\n // Same rows_read-cliff class + fix as idx_gc_queue_queued_at (migration 0111).\n // idx_upload_sessions_expiry stays: reference-check's in-flight protection\n // filters `status = 'prepared' AND expires_at > ?`, which needs the\n // status-leading form.\n \"CREATE INDEX IF NOT EXISTS idx_upload_sessions_expires_at ON ds_upload_sessions(expires_at)\",\n];\n\n/**\n * The complete did-space D1 schema, in apply order — exactly the statements\n * `CloudflareSpaceResolver.ensureTables` would issue on a fresh database\n * (TreeIndex: entries + changelog; ResolveStore; GCQueue). The generated\n * migration serializes THIS list; the runtime probe checks for the four\n * table names this list creates (entries, changelog, resolve_entries,\n * gc_queue).\n */\nexport const D1_DID_SPACE_SCHEMA_SQL: readonly string[] = [\n ENTRIES_TABLE_SQL,\n ...ENTRIES_INDEX_SQL,\n CHANGELOG_TABLE_SQL,\n ...CHANGELOG_INDEX_SQL,\n RESOLVE_ENTRIES_TABLE_SQL,\n ...RESOLVE_ENTRIES_INDEX_SQL,\n GC_QUEUE_TABLE_SQL,\n ...GC_QUEUE_INDEX_SQL,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,oCAAoC,6GAA6G,wBAAwB;;;;;;;;;;;;;;;;;;;;;;AAuBtL,MAAa,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;AAyB3C,MAAa,iCAAiC;AAC9C,MAAa,+BAA+B;;;;;;;;;AAU5C,MAAa,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCvC,MAAa,kCAAkC;;;;;;;;;;;AAY/C,MAAa,iCAAiC;;;;;;;;;;;;;;AAe9C,MAAa,sCAAsC;;AAGnD,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;AAmBjC,MAAa,oBAAuC;CAClD;CACA;CACA;CACA;CAOA;CACA;CAOD;;;;;;;;AASD,MAAa,6BAA6B;;;;;;;;;AAU1C,MAAa,6BAAgD,CAC3D,4FACD;;;;;;;;;;;;;;;;AAiBD,MAAa,mBAAmB;;;;;;;;;;;;;;AAehC,MAAa,mBAAsC;CACjD;CACA;CACA;CACD;;AAGD,MAAa,4BAA4B;;;;;;;;;AAUzC,MAAa,4BAA+C;CAC1D;CACA;CACA;CACA;CACD;;AAGD,MAAa,qBAAqB;;;;;;;;;;;;;;AAelC,MAAa,qBAAwC,CACnD,8EACD;;;;;;;;;;;;;;AAeD,MAAa,4BAA4B;;;;;;;;;;;;;;;AAgBzC,MAAa,mCAAmC;;;;;;;;;;;;;;;AAgBhD,MAAa,4BAA+C;CAC1D;CACA;CASA;CACD;;;;;;;;;AAUD,MAAa,0BAA6C;CACxD;CACA,GAAG;CACH;CACA,GAAG;CACH;CACA,GAAG;CACH;CACA,GAAG;CACJ"}
Binary file