@dxos/echo 0.11.1 → 0.12.0-next-2be9f24c465d98f4bd186aa03ece788902e6c17a

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 (311) hide show
  1. package/dist/lib/Aggregate.mjs +78 -0
  2. package/dist/lib/Aggregate.mjs.map +1 -0
  3. package/dist/lib/Annotation.mjs +1 -1
  4. package/dist/lib/Blob.mjs +6 -6
  5. package/dist/lib/Blob.mjs.map +1 -1
  6. package/dist/lib/Collection.mjs +32 -0
  7. package/dist/lib/Collection.mjs.map +1 -0
  8. package/dist/lib/Database.mjs +2 -2
  9. package/dist/lib/Dataset.mjs +24 -0
  10. package/dist/lib/Dataset.mjs.map +1 -0
  11. package/dist/lib/Entity.mjs +4 -7
  12. package/dist/lib/Entity.mjs.map +1 -1
  13. package/dist/lib/{Err.mjs → Error.mjs} +4 -4
  14. package/dist/lib/Error.mjs.map +1 -0
  15. package/dist/lib/Feed.mjs +56 -34
  16. package/dist/lib/Feed.mjs.map +1 -1
  17. package/dist/lib/Filter.mjs +43 -7
  18. package/dist/lib/Filter.mjs.map +1 -1
  19. package/dist/lib/Hypergraph.mjs +7 -0
  20. package/dist/lib/Hypergraph.mjs.map +1 -0
  21. package/dist/lib/Json.mjs +54 -0
  22. package/dist/lib/Json.mjs.map +1 -0
  23. package/dist/lib/JsonSchema.mjs.map +1 -1
  24. package/dist/lib/Migration.mjs +50 -3
  25. package/dist/lib/Migration.mjs.map +1 -1
  26. package/dist/lib/Obj.mjs +44 -15
  27. package/dist/lib/Obj.mjs.map +1 -1
  28. package/dist/lib/Query.mjs +2 -2
  29. package/dist/lib/Query.mjs.map +1 -1
  30. package/dist/lib/QueryResult.mjs.map +1 -1
  31. package/dist/lib/Ref.mjs +22 -9
  32. package/dist/lib/Ref.mjs.map +1 -1
  33. package/dist/lib/Registry.mjs +2 -35
  34. package/dist/lib/Relation.mjs +6 -9
  35. package/dist/lib/Relation.mjs.map +1 -1
  36. package/dist/lib/Scope.mjs +8 -0
  37. package/dist/lib/Scope.mjs.map +1 -1
  38. package/dist/lib/Tag.mjs +62 -5
  39. package/dist/lib/Tag.mjs.map +1 -1
  40. package/dist/lib/Text.mjs +3 -3
  41. package/dist/lib/Text.mjs.map +1 -1
  42. package/dist/lib/Type.mjs +4 -4
  43. package/dist/lib/Type.mjs.map +1 -1
  44. package/dist/lib/View.mjs +78 -0
  45. package/dist/lib/View.mjs.map +1 -0
  46. package/dist/lib/chunk-Annotation.mjs +14 -11
  47. package/dist/lib/chunk-Annotation.mjs.map +1 -1
  48. package/dist/lib/chunk-Database.mjs +67 -48
  49. package/dist/lib/chunk-Database.mjs.map +1 -1
  50. package/dist/lib/chunk-Registry.mjs +73 -0
  51. package/dist/lib/chunk-Registry.mjs.map +1 -0
  52. package/dist/lib/chunk-atom-snapshot.mjs +31 -17
  53. package/dist/lib/chunk-atom-snapshot.mjs.map +1 -1
  54. package/dist/lib/chunk-internal.mjs +228 -125
  55. package/dist/lib/chunk-internal.mjs.map +1 -1
  56. package/dist/lib/chunk-json-schema.mjs +301 -166
  57. package/dist/lib/chunk-json-schema.mjs.map +1 -1
  58. package/dist/lib/chunk-number.mjs +14 -16
  59. package/dist/lib/chunk-number.mjs.map +1 -1
  60. package/dist/lib/chunk-ref.mjs +55 -45
  61. package/dist/lib/chunk-ref.mjs.map +1 -1
  62. package/dist/lib/chunk-select.mjs +45 -22
  63. package/dist/lib/chunk-select.mjs.map +1 -1
  64. package/dist/lib/chunk-util.mjs +7 -6
  65. package/dist/lib/chunk-util.mjs.map +1 -1
  66. package/dist/lib/index.mjs +11 -4
  67. package/dist/lib/internal.mjs +5 -5
  68. package/dist/lib/testing.mjs +49 -22
  69. package/dist/lib/testing.mjs.map +1 -1
  70. package/dist/types/src/Aggregate.d.ts +17 -5
  71. package/dist/types/src/Aggregate.d.ts.map +1 -1
  72. package/dist/types/src/Annotation.d.ts +15 -12
  73. package/dist/types/src/Annotation.d.ts.map +1 -1
  74. package/dist/types/src/Blob.d.ts +8 -8
  75. package/dist/types/src/Blob.d.ts.map +1 -1
  76. package/dist/types/src/Database.d.ts +128 -9
  77. package/dist/types/src/Database.d.ts.map +1 -1
  78. package/dist/types/src/Dataset.d.ts +1 -1
  79. package/dist/types/src/Dataset.d.ts.map +1 -1
  80. package/dist/types/src/Entity.d.ts +6 -6
  81. package/dist/types/src/Entity.d.ts.map +1 -1
  82. package/dist/types/src/{Err.d.ts → Error.d.ts} +1 -1
  83. package/dist/types/src/Error.d.ts.map +1 -0
  84. package/dist/types/src/Feed.d.ts +36 -27
  85. package/dist/types/src/Feed.d.ts.map +1 -1
  86. package/dist/types/src/Filter.d.ts +42 -3
  87. package/dist/types/src/Filter.d.ts.map +1 -1
  88. package/dist/types/src/JsonSchema.d.ts +3 -3
  89. package/dist/types/src/JsonSchema.d.ts.map +1 -1
  90. package/dist/types/src/Migration.d.ts +62 -8
  91. package/dist/types/src/Migration.d.ts.map +1 -1
  92. package/dist/types/src/Obj.d.ts +19 -16
  93. package/dist/types/src/Obj.d.ts.map +1 -1
  94. package/dist/types/src/Query.d.ts +6 -2
  95. package/dist/types/src/Query.d.ts.map +1 -1
  96. package/dist/types/src/QueryResult.d.ts +1 -1
  97. package/dist/types/src/QueryResult.d.ts.map +1 -1
  98. package/dist/types/src/Ref.d.ts +12 -1
  99. package/dist/types/src/Ref.d.ts.map +1 -1
  100. package/dist/types/src/Registry.d.ts +14 -2
  101. package/dist/types/src/Registry.d.ts.map +1 -1
  102. package/dist/types/src/Relation.d.ts +2 -2
  103. package/dist/types/src/Relation.d.ts.map +1 -1
  104. package/dist/types/src/Scope.d.ts +8 -0
  105. package/dist/types/src/Scope.d.ts.map +1 -1
  106. package/dist/types/src/Tag.d.ts +35 -0
  107. package/dist/types/src/Tag.d.ts.map +1 -1
  108. package/dist/types/src/Text.d.ts +1 -1
  109. package/dist/types/src/Type.d.ts +10 -10
  110. package/dist/types/src/Type.d.ts.map +1 -1
  111. package/dist/types/src/View.d.ts +12 -12
  112. package/dist/types/src/View.d.ts.map +1 -1
  113. package/dist/types/src/index.d.ts +1 -1
  114. package/dist/types/src/index.d.ts.map +1 -1
  115. package/dist/types/src/internal/Annotation/annotations.d.ts +42 -49
  116. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  117. package/dist/types/src/internal/Annotation/atoms.d.ts +1 -1
  118. package/dist/types/src/internal/Annotation/atoms.d.ts.map +1 -1
  119. package/dist/types/src/internal/Annotation/dictionary.d.ts +2 -2
  120. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -1
  121. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +1 -1
  122. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -1
  123. package/dist/types/src/internal/Annotation/util.d.ts +6 -6
  124. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
  125. package/dist/types/src/internal/Entity/entity.d.ts +3 -3
  126. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
  127. package/dist/types/src/internal/Entity/model.d.ts +1 -1
  128. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  129. package/dist/types/src/internal/Entity/object.d.ts +3 -3
  130. package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
  131. package/dist/types/src/internal/Entity/relation.d.ts +4 -4
  132. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
  133. package/dist/types/src/internal/Entity/type-kind.d.ts +2 -2
  134. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -1
  135. package/dist/types/src/internal/Entity/type-uri.d.ts +2 -2
  136. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -1
  137. package/dist/types/src/internal/Filter/match.d.ts +3 -0
  138. package/dist/types/src/internal/Filter/match.d.ts.map +1 -1
  139. package/dist/types/src/internal/Format/date.d.ts +18 -19
  140. package/dist/types/src/internal/Format/date.d.ts.map +1 -1
  141. package/dist/types/src/internal/Format/format.d.ts +16 -16
  142. package/dist/types/src/internal/Format/format.d.ts.map +1 -1
  143. package/dist/types/src/internal/Format/number.d.ts +6 -6
  144. package/dist/types/src/internal/Format/number.d.ts.map +1 -1
  145. package/dist/types/src/internal/Format/object.d.ts +1 -1
  146. package/dist/types/src/internal/Format/object.d.ts.map +1 -1
  147. package/dist/types/src/internal/Format/select.d.ts +3 -3
  148. package/dist/types/src/internal/Format/string.d.ts +7 -7
  149. package/dist/types/src/internal/Format/string.d.ts.map +1 -1
  150. package/dist/types/src/internal/Format/types.d.ts +5 -5
  151. package/dist/types/src/internal/Format/types.d.ts.map +1 -1
  152. package/dist/types/src/internal/JsonSchema/annotations.d.ts +3 -3
  153. package/dist/types/src/internal/JsonSchema/json-schema-shape.test.d.ts +2 -0
  154. package/dist/types/src/internal/JsonSchema/json-schema-shape.test.d.ts.map +1 -0
  155. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +94 -94
  156. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
  157. package/dist/types/src/internal/JsonSchema/json-schema-v3.test.d.ts +2 -0
  158. package/dist/types/src/internal/JsonSchema/json-schema-v3.test.d.ts.map +1 -0
  159. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +2 -7
  160. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  161. package/dist/types/src/internal/Obj/atoms.d.ts +1 -1
  162. package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
  163. package/dist/types/src/internal/Obj/common.d.ts +4 -3
  164. package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
  165. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
  166. package/dist/types/src/internal/Obj/index.d.ts +0 -1
  167. package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
  168. package/dist/types/src/internal/Obj/json-serializer.d.ts +1 -2
  169. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  170. package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
  171. package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
  172. package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -1
  173. package/dist/types/src/internal/Query/pretty.d.ts.map +1 -1
  174. package/dist/types/src/internal/Query/query-result-effect.d.ts.map +1 -1
  175. package/dist/types/src/internal/Ref/atoms.d.ts +1 -1
  176. package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -1
  177. package/dist/types/src/internal/Ref/ref.d.ts +12 -8
  178. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  179. package/dist/types/src/internal/Ref/utils.d.ts +2 -2
  180. package/dist/types/src/internal/Ref/utils.d.ts.map +1 -1
  181. package/dist/types/src/internal/Registry/atoms.d.ts +8 -0
  182. package/dist/types/src/internal/Registry/atoms.d.ts.map +1 -0
  183. package/dist/types/src/internal/Type/manipulation.d.ts +5 -5
  184. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
  185. package/dist/types/src/internal/Type/type-schema.d.ts +9 -9
  186. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -1
  187. package/dist/types/src/internal/common/atom-snapshot.d.ts +9 -0
  188. package/dist/types/src/internal/common/atom-snapshot.d.ts.map +1 -1
  189. package/dist/types/src/internal/common/atom-snapshot.test.d.ts +2 -0
  190. package/dist/types/src/internal/common/atom-snapshot.test.d.ts.map +1 -0
  191. package/dist/types/src/internal/common/proxy/entity-hash.test.d.ts +2 -0
  192. package/dist/types/src/internal/common/proxy/entity-hash.test.d.ts.map +1 -0
  193. package/dist/types/src/internal/common/proxy/make-object.d.ts +1 -1
  194. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  195. package/dist/types/src/internal/common/proxy/schema-validator.d.ts +21 -7
  196. package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
  197. package/dist/types/src/internal/common/proxy/schema-validator.test.d.ts.map +1 -0
  198. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +5 -5
  199. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  200. package/dist/types/src/internal/common/types/base.d.ts +3 -1
  201. package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
  202. package/dist/types/src/internal/common/types/entity.d.ts +3 -3
  203. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
  204. package/dist/types/src/internal/common/types/meta.d.ts +9 -9
  205. package/dist/types/src/testing/registry.d.ts.map +1 -1
  206. package/dist/types/src/testing/test-schema.d.ts +24 -44
  207. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  208. package/dist/types/src/testing/util.d.ts +2 -2
  209. package/dist/types/src/testing/util.d.ts.map +1 -1
  210. package/dist/types/tsconfig.tsbuildinfo +1 -1
  211. package/package.json +46 -17
  212. package/src/Aggregate.ts +18 -6
  213. package/src/Annotation.test.ts +15 -15
  214. package/src/Annotation.ts +11 -8
  215. package/src/Blob.ts +10 -10
  216. package/src/Database.ts +152 -16
  217. package/src/Dataset.ts +2 -2
  218. package/src/Entity.ts +3 -5
  219. package/src/Feed.ts +45 -38
  220. package/src/Filter.ts +57 -6
  221. package/src/JsonSchema.ts +1 -1
  222. package/src/Migration.ts +89 -12
  223. package/src/Obj.test.ts +43 -0
  224. package/src/Obj.ts +51 -14
  225. package/src/Query.test.ts +89 -54
  226. package/src/Query.ts +6 -2
  227. package/src/QueryResult.ts +1 -1
  228. package/src/Ref.ts +23 -13
  229. package/src/Registry.ts +19 -2
  230. package/src/Relation.ts +5 -5
  231. package/src/Scope.ts +8 -0
  232. package/src/Tag.md +98 -0
  233. package/src/Tag.ts +78 -3
  234. package/src/Text.ts +6 -6
  235. package/src/Type.ts +12 -12
  236. package/src/View.ts +1 -1
  237. package/src/index.ts +1 -1
  238. package/src/internal/Annotation/annotations.ts +63 -77
  239. package/src/internal/Annotation/atoms.ts +10 -10
  240. package/src/internal/Annotation/dictionary.ts +1 -1
  241. package/src/internal/Annotation/entity-dictionary.ts +11 -13
  242. package/src/internal/Annotation/util.ts +13 -11
  243. package/src/internal/Entity/entity.ts +21 -14
  244. package/src/internal/Entity/model.ts +1 -1
  245. package/src/internal/Entity/object.ts +21 -11
  246. package/src/internal/Entity/relation.ts +18 -10
  247. package/src/internal/Entity/type-kind.ts +15 -8
  248. package/src/internal/Entity/type-uri.ts +3 -3
  249. package/src/internal/Filter/match.ts +54 -2
  250. package/src/internal/Format/date.ts +14 -12
  251. package/src/internal/Format/format.test.ts +1 -1
  252. package/src/internal/Format/format.ts +1 -1
  253. package/src/internal/Format/number.ts +20 -13
  254. package/src/internal/Format/object.ts +16 -9
  255. package/src/internal/Format/string.ts +8 -7
  256. package/src/internal/Format/types.ts +9 -14
  257. package/src/internal/JsonSchema/annotations.ts +4 -4
  258. package/src/internal/JsonSchema/effect-schema.test.ts +52 -93
  259. package/src/internal/JsonSchema/json-schema-shape.test.ts +100 -0
  260. package/src/internal/JsonSchema/json-schema-type.ts +35 -56
  261. package/src/internal/JsonSchema/json-schema-v3-corpus.json +2183 -0
  262. package/src/internal/JsonSchema/json-schema-v3.test.ts +118 -0
  263. package/src/internal/JsonSchema/json-schema.test.ts +178 -74
  264. package/src/internal/JsonSchema/json-schema.ts +393 -151
  265. package/src/internal/Obj/atoms.ts +10 -9
  266. package/src/internal/Obj/common.ts +11 -16
  267. package/src/internal/Obj/create-object.test.ts +2 -4
  268. package/src/internal/Obj/create-object.ts +1 -2
  269. package/src/internal/Obj/index.ts +0 -1
  270. package/src/internal/Obj/json-serializer.test.ts +1 -1
  271. package/src/internal/Obj/json-serializer.ts +4 -7
  272. package/src/internal/Obj/set-value.ts +16 -14
  273. package/src/internal/Obj/typed-object.test.ts +2 -2
  274. package/src/internal/Obj/typed-object.ts +1 -1
  275. package/src/internal/Query/pretty.ts +22 -9
  276. package/src/internal/Query/query-result-effect.ts +10 -11
  277. package/src/internal/Ref/atoms.ts +1 -1
  278. package/src/internal/Ref/ref.test.ts +1 -1
  279. package/src/internal/Ref/ref.ts +77 -69
  280. package/src/internal/Ref/utils.ts +2 -2
  281. package/src/internal/Registry/atoms.ts +45 -0
  282. package/src/internal/Type/manipulation.ts +29 -33
  283. package/src/internal/Type/type-schema.ts +1 -1
  284. package/src/internal/common/atom-snapshot.test.ts +29 -0
  285. package/src/internal/common/atom-snapshot.ts +40 -0
  286. package/src/internal/common/proxy/entity-hash.test.ts +145 -0
  287. package/src/internal/common/proxy/make-object.ts +6 -3
  288. package/src/internal/{Obj → common/proxy}/schema-validator.test.ts +30 -27
  289. package/src/internal/common/proxy/schema-validator.ts +103 -67
  290. package/src/internal/common/proxy/schema.test.ts +32 -24
  291. package/src/internal/common/proxy/typed-handler.test.ts +6 -4
  292. package/src/internal/common/proxy/typed-handler.ts +37 -16
  293. package/src/internal/common/proxy/typed-object.test.ts +5 -10
  294. package/src/internal/common/types/base.ts +6 -4
  295. package/src/internal/common/types/entity.ts +4 -4
  296. package/src/internal/common/types/meta.ts +3 -3
  297. package/src/internal/common/types/typename.ts +2 -2
  298. package/src/testing/registry.ts +1 -1
  299. package/src/testing/test-schema.ts +16 -24
  300. package/src/testing/util.ts +37 -3
  301. package/dist/lib/Err.mjs.map +0 -1
  302. package/dist/lib/Registry.mjs.map +0 -1
  303. package/dist/lib/chunk-src.mjs +0 -234
  304. package/dist/lib/chunk-src.mjs.map +0 -1
  305. package/dist/types/src/Err.d.ts.map +0 -1
  306. package/dist/types/src/internal/Obj/schema-validator.d.ts +0 -2
  307. package/dist/types/src/internal/Obj/schema-validator.d.ts.map +0 -1
  308. package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +0 -1
  309. package/src/internal/Obj/schema-validator.ts +0 -6
  310. /package/dist/types/src/internal/{Obj → common/proxy}/schema-validator.test.d.ts +0 -0
  311. /package/src/{Err.ts → Error.ts} +0 -0
@@ -0,0 +1,78 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ //#region src/Aggregate.ts
3
+ var Aggregate_exports = /* @__PURE__ */ __exportAll({
4
+ AggregateTypeId: () => AggregateTypeId,
5
+ count: () => count,
6
+ group: () => group,
7
+ items: () => items,
8
+ max: () => max,
9
+ min: () => min
10
+ });
11
+ var AggregateTypeId = "~@dxos/echo/Aggregate";
12
+ var AggregateClass = class AggregateClass {
13
+ spec;
14
+ static "variance" = {};
15
+ static is(value) {
16
+ return typeof value === "object" && value !== null && "~@dxos/echo/Aggregate" in value;
17
+ }
18
+ constructor(spec) {
19
+ this.spec = spec;
20
+ }
21
+ [AggregateTypeId] = AggregateClass.variance;
22
+ };
23
+ /**
24
+ * Group members by a scalar property, or by the first property of a `coalesce` chain holding a
25
+ * scalar value (`threadId ?? id`). The record key names the result field carrying the coerced
26
+ * group-key value; multiple `group` entries form a composite key (a `coalesce` chain is one
27
+ * component, not several). Members whose key is missing, `null`, `undefined`, or non-scalar group
28
+ * under the `null` key, so the field value includes `null`.
29
+ *
30
+ * A chain ending in an always-present property (e.g. `{ coalesce: ['threadId', 'id'] }`) gives each
31
+ * member lacking the leading property its own singleton group instead of pooling them under `null`,
32
+ * where an {@link items} `limit` would truncate unrelated members. `id` qualifies: it resolves to
33
+ * the object's entity id even though documents don't store it as data.
34
+ */
35
+ var group = (key) => new AggregateClass({
36
+ kind: "group",
37
+ properties: typeof key === "string" ? [key] : key.coalesce
38
+ });
39
+ /**
40
+ * Aggregate the maximum of a scalar property across the group's members.
41
+ * `T` is inferred from the `Query.aggregate` context, so `property` is checked against the query's
42
+ * element type (like {@link Order.property}).
43
+ */
44
+ var max = (property) => new AggregateClass({
45
+ kind: "max",
46
+ property
47
+ });
48
+ /**
49
+ * Aggregate the minimum of a scalar property across the group's members.
50
+ */
51
+ var min = (property) => new AggregateClass({
52
+ kind: "min",
53
+ property
54
+ });
55
+ /**
56
+ * Collect the group's members, optionally ordered by `order` and capped to `limit` per group.
57
+ * Opt-in — groups carry no members unless this aggregate is declared.
58
+ *
59
+ * `order` is this aggregate's own per-group ordering — independent of any `orderBy` elsewhere in
60
+ * the query, which orders the whole input stream (and, following `aggregate`, the resulting
61
+ * groups), not this aggregate's member selection. Without `order`, members keep whatever order
62
+ * they arrived in from a preceding `orderBy` (unspecified if there is none), so a per-group
63
+ * top-`limit` moved position in the chain would silently change; declaring `order` here makes the
64
+ * ordering explicit and local to this aggregate regardless of where it sits.
65
+ */
66
+ var items = (options) => new AggregateClass({
67
+ kind: "items",
68
+ limit: options?.limit,
69
+ order: options?.order?.map((order) => order.ast)
70
+ });
71
+ /**
72
+ * Count the group's members. Opt-in — groups carry no count unless this aggregate is declared.
73
+ */
74
+ var count = () => new AggregateClass({ kind: "count" });
75
+ //#endregion
76
+ export { AggregateTypeId, count, group, items, max, min, Aggregate_exports as t };
77
+
78
+ //# sourceMappingURL=Aggregate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregate.mjs","names":[],"sources":["../../src/Aggregate.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as EffectTypes from 'effect/Types';\n\nimport type { QueryAST } from '@dxos/echo-protocol';\n\nimport type * as Order from './Order';\nimport type * as Query from './Query';\n\n/**\n * The aggregate spec sans name; the name is supplied by the `Query.aggregate` record key. A tagged\n * union per kind so `property`/`limit`/`order` are present exactly when the kind uses them (no\n * unused optional fields to guard against at read sites).\n */\nexport type Spec =\n | { kind: 'group'; properties: readonly [string, ...string[]] }\n | { kind: 'max'; property: string }\n | { kind: 'min'; property: string }\n | { kind: 'items'; limit?: number; order?: readonly QueryAST.Order[] }\n | { kind: 'count' };\n\nexport const AggregateTypeId = '~@dxos/echo/Aggregate' as const;\nexport type AggregateTypeId = typeof AggregateTypeId;\n\n/**\n * A per-group aggregate declaration, materialised as a top-level field on the flat result record\n * `Query.aggregate` produces and orderable via a following `orderBy(Order.property(name))`. Name it\n * via the record passed to `Query.aggregate({ name: Aggregate.max('created') })`.\n *\n * `T` is the query's element type (so a reduced/grouped property is checked against it); `V` is the\n * value the aggregate produces. {@link group} entries define the grouping keys; a record with no\n * `group` entries aggregates the entire input into a single row.\n */\nexport interface Aggregate<T, V> {\n readonly [AggregateTypeId]: { element: T; value: V };\n\n spec: Spec;\n}\n\nexport type Any = Aggregate<any, any>;\n\n/** Extracts the value type a {@link Aggregate} produces. */\nexport type ValueOf<A> = A extends Aggregate<any, infer V> ? V : never;\n\n/** Computes the flat result type of `Query.aggregate(aggregates)` for a given aggregate record `A`. */\nexport type AggregationResult<A extends Record<string, Any>> = EffectTypes.Simplify<\n Query.AggregateResult & { readonly [N in keyof A]: ValueOf<A[N]> }\n>;\n\nclass AggregateClass<T, V> implements Aggregate<T, V> {\n private static 'variance': Aggregate<any, any>[AggregateTypeId] = {} as Aggregate<any, any>[AggregateTypeId];\n\n static is(value: unknown): value is Any {\n return typeof value === 'object' && value !== null && AggregateTypeId in value;\n }\n\n constructor(public readonly spec: Spec) {}\n\n [AggregateTypeId] = AggregateClass.variance as Aggregate<T, V>[AggregateTypeId];\n}\n\n/**\n * Group members by a scalar property, or by the first property of a `coalesce` chain holding a\n * scalar value (`threadId ?? id`). The record key names the result field carrying the coerced\n * group-key value; multiple `group` entries form a composite key (a `coalesce` chain is one\n * component, not several). Members whose key is missing, `null`, `undefined`, or non-scalar group\n * under the `null` key, so the field value includes `null`.\n *\n * A chain ending in an always-present property (e.g. `{ coalesce: ['threadId', 'id'] }`) gives each\n * member lacking the leading property its own singleton group instead of pooling them under `null`,\n * where an {@link items} `limit` would truncate unrelated members. `id` qualifies: it resolves to\n * the object's entity id even though documents don't store it as data.\n */\nexport const group: {\n <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null>;\n <T, const K extends readonly [keyof T & string, ...(keyof T & string)[]]>(key: {\n coalesce: K;\n }): Aggregate<T, T[K[number]] | null>;\n} = (key: string | { coalesce: readonly [string, ...string[]] }): Any =>\n new AggregateClass({ kind: 'group', properties: typeof key === 'string' ? [key] : key.coalesce });\n\n/**\n * Aggregate the maximum of a scalar property across the group's members.\n * `T` is inferred from the `Query.aggregate` context, so `property` is checked against the query's\n * element type (like {@link Order.property}).\n */\nexport const max = <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null> =>\n new AggregateClass({ kind: 'max', property });\n\n/**\n * Aggregate the minimum of a scalar property across the group's members.\n */\nexport const min = <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null> =>\n new AggregateClass({ kind: 'min', property });\n\n/**\n * Collect the group's members, optionally ordered by `order` and capped to `limit` per group.\n * Opt-in — groups carry no members unless this aggregate is declared.\n *\n * `order` is this aggregate's own per-group ordering — independent of any `orderBy` elsewhere in\n * the query, which orders the whole input stream (and, following `aggregate`, the resulting\n * groups), not this aggregate's member selection. Without `order`, members keep whatever order\n * they arrived in from a preceding `orderBy` (unspecified if there is none), so a per-group\n * top-`limit` moved position in the chain would silently change; declaring `order` here makes the\n * ordering explicit and local to this aggregate regardless of where it sits.\n */\nexport const items = <T>(options?: { limit?: number; order?: Order.Any[] }): Aggregate<T, T[]> =>\n new AggregateClass({ kind: 'items', limit: options?.limit, order: options?.order?.map((order) => order.ast) });\n\n/**\n * Count the group's members. Opt-in — groups carry no count unless this aggregate is declared.\n */\nexport const count = <T>(): Aggregate<T, number> => new AggregateClass({ kind: 'count' });\n"],"mappings":";;;;;;;;;;AAyBA,IAAa,kBAAkB;AA4B/B,IAAM,iBAAN,MAAM,eAAgD;CAOxB;CAN5B,OAAe,aAAmD,CAAC;CAEnE,OAAO,GAAG,OAA8B;EACtC,OAAO,OAAO,UAAU,YAAY,UAAU,QAAA,2BAA2B;CAC3E;CAEA,YAAY,MAA4B;EAAZ,KAAA,OAAA;CAAa;CAEzC,CAAC,mBAAmB,eAAe;AACrC;;;;;;;;;;;;;AAcA,IAAa,SAKR,QACH,IAAI,eAAe;CAAE,MAAM;CAAS,YAAY,OAAO,QAAQ,WAAW,CAAC,GAAG,IAAI,IAAI;AAAS,CAAC;;;;;;AAOlG,IAAa,OAAsC,aACjD,IAAI,eAAe;CAAE,MAAM;CAAO;AAAS,CAAC;;;;AAK9C,IAAa,OAAsC,aACjD,IAAI,eAAe;CAAE,MAAM;CAAO;AAAS,CAAC;;;;;;;;;;;;AAa9C,IAAa,SAAY,YACvB,IAAI,eAAe;CAAE,MAAM;CAAS,OAAO,SAAS;CAAO,OAAO,SAAS,OAAO,KAAK,UAAU,MAAM,GAAG;AAAE,CAAC;;;;AAK/G,IAAa,cAAuC,IAAI,eAAe,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,3 +1,3 @@
1
- import { $ as ReferenceAnnotation, B as FormLayoutAnnotationId, D as DEFAULT_LAYOUT_NAME, Et as setDescriptionWithSchema, F as FormInlineAnnotation, G as HiddenAnnotation, J as IconFromRefAnnotation, L as FormInputAnnotation, N as FormCreateAnnotation, O as DescriptionAnnotation, Ot as setLabelWithSchema, P as FormCreateAnnotationId, U as GeneratorAnnotation, V as FormOrderedAnnotation, W as GeneratorAnnotationId, Y as LabelAnnotation, bt as getTypeAnnotation, et as ReferenceAnnotationId, ht as getLabelWithSchema, j as FieldLookupAnnotationId, lt as getDescriptionWithSchema, nt as TypeAnnotation, q as IconAnnotation, xt as getTypeIdentifierAnnotation, z as FormLayoutAnnotation } from "./chunk-Database.mjs";
1
+ import { A as DEFAULT_LAYOUT_NAME, B as FormInputAnnotation, Ct as getTypeAnnotation, H as FormLayoutAnnotation, I as FormCreateAnnotation, J as HiddenAnnotation, K as GeneratorAnnotation, L as FormCreateAnnotationId, P as FieldLookupAnnotationId, Q as LabelAnnotation, R as FormInlineAnnotation, U as FormLayoutAnnotationId, W as FormOrderedAnnotation, X as IconAnnotation, Z as IconFromRefAnnotation, at as TypeAnnotation, ft as getDescriptionWithSchema, j as DescriptionAnnotation, jt as setLabelWithSchema, kt as setDescriptionWithSchema, nt as ReferenceAnnotation, q as GeneratorAnnotationId, rt as ReferenceAnnotationId, vt as getLabelWithSchema, wt as getTypeIdentifierAnnotation } from "./chunk-Database.mjs";
2
2
  import { a as atom, c as get, d as make, f as set, i as TypeId, l as getDictionary, m as update, n as Dictionary, o as atomProperty, p as setDictionary, r as Key, s as buildDictionary, u as getFromAst } from "./chunk-Annotation.mjs";
3
3
  export { DEFAULT_LAYOUT_NAME, DescriptionAnnotation, Dictionary, FieldLookupAnnotationId, FormCreateAnnotation, FormCreateAnnotationId, FormInlineAnnotation, FormInputAnnotation, FormLayoutAnnotation, FormLayoutAnnotationId, FormOrderedAnnotation, GeneratorAnnotation, GeneratorAnnotationId, HiddenAnnotation, IconAnnotation, IconFromRefAnnotation, Key, LabelAnnotation, ReferenceAnnotation, ReferenceAnnotationId, TypeAnnotation, TypeId, atom, atomProperty, buildDictionary, get, getDescriptionWithSchema, getDictionary, getFromAst, getLabelWithSchema, getTypeAnnotation, getTypeIdentifierAnnotation, make, set, setDescriptionWithSchema, setDictionary, setLabelWithSchema, update };
package/dist/lib/Blob.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { G as HiddenAnnotation, q as IconAnnotation, r as Service } from "./chunk-Database.mjs";
3
- import { BlobNotAvailableError, BlobTooLargeError, BlobWriteError } from "./Err.mjs";
2
+ import { J as HiddenAnnotation, X as IconAnnotation, r as Service } from "./chunk-Database.mjs";
3
+ import { BlobNotAvailableError, BlobTooLargeError, BlobWriteError } from "./Error.mjs";
4
4
  import { makeObject } from "./Type.mjs";
5
5
  import { make as make$1 } from "./Obj.mjs";
6
6
  import { DXN } from "@dxos/keys";
@@ -27,7 +27,7 @@ var Blob_exports = /* @__PURE__ */ __exportAll({
27
27
  /**
28
28
  * Inline blob data: bytes stored directly on the ECHO object.
29
29
  */
30
- var InlineData = Schema.TaggedStruct("inline", { bytes: Schema.Uint8ArrayFromSelf.annotations({ jsonSchema: {
30
+ var InlineData = Schema.TaggedStruct("inline", { bytes: Schema.Uint8Array.annotate({ jsonSchema: {
31
31
  type: "string",
32
32
  contentEncoding: "base64"
33
33
  } }) });
@@ -44,7 +44,7 @@ var ExternalData = Schema.TaggedStruct("external", {
44
44
  * @see {@link https://www.rfc-editor.org/rfc/rfc6920 RFC 6920} for the `ni:` URI format.
45
45
  */
46
46
  uri: Schema.String });
47
- var BlobData = Schema.Union(InlineData, ExternalData);
47
+ var BlobData = Schema.Union([InlineData, ExternalData]);
48
48
  /**
49
49
  * Runtime schema for a Blob object.
50
50
  *
@@ -94,7 +94,7 @@ var Storage = {
94
94
  * Extensions (e.g. plugin-wnfs) define their own schemes in their own package.
95
95
  */
96
96
  var Scheme = { ni: "ni" };
97
- var MAX_INLINE_SIZE = 4 * 1024 * 1024;
97
+ var MAX_INLINE_SIZE = 4194304;
98
98
  /**
99
99
  * Creates a new blob object. Does not add it to the database — see {@link fromBytes}.
100
100
  */
@@ -153,7 +153,7 @@ var exists = (blob) => Service.pipe(Effect.flatMap(({ db }) => Effect.promise(()
153
153
  * Returns a renderable URL for the blob: inline blobs resolve to a `data:` URL; external blobs
154
154
  * are resolved by the registered backend's `getUrl`, if it implements one.
155
155
  */
156
- var url = (blob) => Service.pipe(Effect.flatMap(({ db }) => Effect.promise(() => db.getBlobUrl(blob))), Effect.map(Option.fromNullable)).pipe(Effect.withSpan("Blob.url"));
156
+ var url = (blob) => Service.pipe(Effect.flatMap(({ db }) => Effect.promise(() => db.getBlobUrl(blob))), Effect.map(Option.fromNullishOr)).pipe(Effect.withSpan("Blob.url"));
157
157
  //#endregion
158
158
  export { Blob, BlobData, ExternalData, InlineData, MAX_INLINE_SIZE, Scheme, Storage, exists, externalData, fromBytes, inlineData, make, read, Blob_exports as t, url };
159
159
 
@@ -1 +1 @@
1
- {"version":3,"file":"Blob.mjs","names":[],"sources":["../../src/Blob.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as Database from './Database';\nimport * as Err from './Err';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Type from './Type';\n\n/**\n * Inline blob data: bytes stored directly on the ECHO object.\n */\nexport const InlineData = Schema.TaggedStruct('inline', {\n bytes: Schema.Uint8ArrayFromSelf.annotations({ jsonSchema: { type: 'string', contentEncoding: 'base64' } }),\n});\n\n/**\n * External blob data: bytes stored by a registered blob backend, addressed by `uri`.\n */\nexport const ExternalData = Schema.TaggedStruct('external', {\n /**\n * URI locating the bytes. The scheme selects the backend at read time (e.g. `ni:///sha-256;…` for\n * the edge backend — an RFC 6920 content digest, not a backend name — or `wnfs://…` for the\n * plugin-wnfs extension), resolved via the scheme→backend map built from `registerBlobBackend`\n * calls. Core code never parses or constructs backend-specific URIs beyond reading the scheme.\n *\n * @see {@link https://www.rfc-editor.org/rfc/rfc6920 RFC 6920} for the `ni:` URI format.\n */\n uri: Schema.String,\n});\n\nexport const BlobData = Schema.Union(InlineData, ExternalData);\nexport type BlobData = Schema.Schema.Type<typeof BlobData>;\n\n/**\n * Runtime schema for a Blob object.\n *\n * NOTE: This export shadows the DOM `Blob` global within modules that import it as a namespace.\n * Code that needs the DOM class should use `globalThis.Blob` explicitly.\n *\n * @example\n * ```ts\n * const blob = yield* Blob.fromBytes(bytes, { type: 'image/png' });\n * ```\n */\nexport class Blob extends Type.makeObject<Blob>(DXN.make('org.dxos.type.blob', '0.1.0'))(\n Schema.Struct({\n /** MIME type. */\n type: Schema.optional(Schema.String),\n size: Schema.Number,\n data: BlobData,\n }).pipe(\n internal.HiddenAnnotation.set(true),\n Annotation.IconAnnotation.set({ icon: 'ph--file--regular', hue: 'teal' }),\n ),\n) {}\n\n//\n// Storage constants\n//\n\n/**\n * Storage backend names, selected at write time via {@link FromBytesOptions.storage}. Call sites\n * always use these constants, never raw string literals. Extensions (e.g. plugin-wnfs) define\n * their own storage names in their own package — core code knows nothing of them.\n *\n * Distinct from {@link Scheme}: a storage name picks *where* to write, a URI scheme describes\n * *what the identifier is* at read time. They coincide for backends with no content-addressing\n * (e.g. wnfs uses `'wnfs'` for both), but the edge backend's storage name (`'edge'`) differs from\n * its URI scheme (`Scheme.ni`) because the identifier it produces is a content hash, not an\n * edge-specific address.\n */\nexport const Storage = { inline: 'inline', edge: 'edge' } as const;\nexport type Storage = (typeof Storage)[keyof typeof Storage];\n\n/**\n * URI schemes claimed by core backends (see `BlobBackend.schemes` in `@dxos/echo-protocol`).\n *\n * `ni` marks an {@link https://www.rfc-editor.org/rfc/rfc6920 RFC 6920} Named Information URI whose\n * authority is empty and whose path carries a registered hash-algorithm name plus a base64url-encoded\n * digest (e.g. `ni:///sha-256;UyaQNQIUxQKgg1jVMKMbg1Yr8Rrb2Y3RaOx2N0mVJhc`, produced by the edge\n * backend). The scheme names *what the identifier is* — a content digest over the complete blob —\n * not which backend wrote it, so any backend or cache that can resolve that digest may claim it.\n * The URI is an identity claim, not a retrievability promise; transport is selected by the registered\n * backend at read time.\n *\n * Extensions (e.g. plugin-wnfs) define their own schemes in their own package.\n */\nexport const Scheme = { ni: 'ni' } as const;\nexport type Scheme = (typeof Scheme)[keyof typeof Scheme];\n\n//\n// Factory\n//\n\nexport const MAX_INLINE_SIZE = 4 * 1024 * 1024;\n\n/**\n * Creates a new blob object. Does not add it to the database — see {@link fromBytes}.\n */\nexport const make = (props: Obj.MakeProps<typeof Blob>): Blob => Obj.make(Blob, props);\n\n/**\n * Creates an inline {@link BlobData} variant that embeds raw bytes on the ECHO object.\n */\nexport const inlineData = (bytes: Uint8Array): BlobData => ({ _tag: 'inline', bytes });\n\n/**\n * Creates an external {@link BlobData} variant that references bytes held by a registered backend.\n * @param uri - Backend-scoped URI, e.g. as returned by a `BlobBackend.put` call.\n */\nexport const externalData = (uri: string): BlobData => ({ _tag: 'external', uri });\n\nexport interface FromBytesOptions {\n /** MIME type. */\n type?: string;\n /**\n * Storage backend name. Defaults to the registry's configured default (initially `'inline'`;\n * `@dxos/client` marks `'edge'` as the default when configured).\n */\n storage?: Storage | (string & {});\n}\n\n//\n// Operations\n//\n\n/**\n * Hashes and uploads `bytes` via the chosen storage backend (a no-op for `inline`), returning an\n * un-added Blob object. The caller is responsible for adding it to the database.\n *\n * @example\n * ```ts\n * const blob = yield* Blob.fromBytes(bytes, { type: 'image/png' });\n * yield* Database.add(blob);\n * ```\n */\nexport const fromBytes = (\n bytes: Uint8Array,\n options?: FromBytesOptions,\n): Effect.Effect<Blob, Err.BlobTooLargeError | Err.BlobWriteError, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) =>\n Effect.tryPromise({\n try: () => db.createBlob(bytes, options),\n catch: (error) =>\n error instanceof Err.BlobTooLargeError || error instanceof Err.BlobWriteError\n ? error\n : new Err.BlobWriteError({ backend: options?.storage ?? 'unknown' }, { cause: error }),\n }),\n ),\n ).pipe(Effect.withSpan('Blob.fromBytes'));\n\n/**\n * Loads a blob's bytes. Inline: read directly off the object. External: dispatched to the\n * registered backend for the URI's scheme.\n *\n * @example\n * ```ts\n * const bytes = yield* Blob.read(blob);\n * ```\n */\nexport const read = (blob: Blob): Effect.Effect<Uint8Array, Err.BlobNotAvailableError, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) =>\n Effect.tryPromise({\n try: () => db.readBlob(blob),\n catch: (error) =>\n error instanceof Err.BlobNotAvailableError\n ? error\n : new Err.BlobNotAvailableError(\n { backend: 'unknown', key: blob.id, reason: 'not-found' },\n { cause: error },\n ),\n }),\n ),\n ).pipe(Effect.withSpan('Blob.read'));\n\n/**\n * Checks whether a blob's bytes are currently available.\n */\nexport const exists = (blob: Blob): Effect.Effect<boolean, never, Database.Service> =>\n Database.Service.pipe(Effect.flatMap(({ db }) => Effect.promise(() => db.blobExists(blob)))).pipe(\n Effect.withSpan('Blob.exists'),\n );\n\n/**\n * Returns a renderable URL for the blob: inline blobs resolve to a `data:` URL; external blobs\n * are resolved by the registered backend's `getUrl`, if it implements one.\n */\nexport const url = (blob: Blob): Effect.Effect<Option.Option<string>, never, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) => Effect.promise(() => db.getBlobUrl(blob))),\n Effect.map(Option.fromNullable),\n ).pipe(Effect.withSpan('Blob.url'));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,aAAa,OAAO,aAAa,UAAU,EACtD,OAAO,OAAO,mBAAmB,YAAY,EAAE,YAAY;CAAE,MAAM;CAAU,iBAAiB;AAAS,EAAE,CAAC,EAC5G,CAAC;;;;AAKD,IAAa,eAAe,OAAO,aAAa,YAAY;;;;;;;;;AAS1D,KAAK,OAAO,OACd,CAAC;AAED,IAAa,WAAW,OAAO,MAAM,YAAY,YAAY;;;;;;;;;;;;AAc7D,IAAa,OAAb,cAA0B,WAAsB,IAAI,KAAK,sBAAsB,OAAO,CAAC,CAAC,CACtF,OAAO,OAAO;;CAEZ,MAAM,OAAO,SAAS,OAAO,MAAM;CACnC,MAAM,OAAO;CACb,MAAM;AACR,CAAC,CAAC,CAAC,KAAA,iBACyB,IAAI,IAAI,GAAA,eACR,IAAI;CAAE,MAAM;CAAqB,KAAK;AAAO,CAAC,CAC1E,CACF,CAAC,CAAC,CAAC;;;;;;;;;;;;AAiBH,IAAa,UAAU;CAAE,QAAQ;CAAU,MAAM;AAAO;;;;;;;;;;;;;;AAgBxD,IAAa,SAAS,EAAE,IAAI,KAAK;AAOjC,IAAa,kBAAkB,IAAI,OAAO;;;;AAK1C,IAAa,QAAQ,UAA4C,OAAS,MAAM,KAAK;;;;AAKrF,IAAa,cAAc,WAAiC;CAAE,MAAM;CAAU;AAAM;;;;;AAMpF,IAAa,gBAAgB,SAA2B;CAAE,MAAM;CAAY;AAAI;;;;;;;;;;;AA0BhF,IAAa,aACX,OACA,YAAA,QAEiB,KACf,OAAO,SAAS,EAAE,SAChB,OAAO,WAAW;CAChB,WAAW,GAAG,WAAW,OAAO,OAAO;CACvC,QAAQ,UACN,iBAAiB,qBAAyB,iBAAiB,iBACvD,QACA,IAAI,eAAmB,EAAE,SAAS,SAAS,WAAW,UAAU,GAAG,EAAE,OAAO,MAAM,CAAC;AAC3F,CAAC,CACH,CACF,CAAC,CAAC,KAAK,OAAO,SAAS,gBAAgB,CAAC;;;;;;;;;;AAW1C,IAAa,QAAQ,SAAA,QACF,KACf,OAAO,SAAS,EAAE,SAChB,OAAO,WAAW;CAChB,WAAW,GAAG,SAAS,IAAI;CAC3B,QAAQ,UACN,iBAAiB,wBACb,QACA,IAAI,sBACF;EAAE,SAAS;EAAW,KAAK,KAAK;EAAI,QAAQ;CAAY,GACxD,EAAE,OAAO,MAAM,CACjB;AACR,CAAC,CACH,CACF,CAAC,CAAC,KAAK,OAAO,SAAS,WAAW,CAAC;;;;AAKrC,IAAa,UAAU,SAAA,QACJ,KAAK,OAAO,SAAS,EAAE,SAAS,OAAO,cAAc,GAAG,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAC3F,OAAO,SAAS,aAAa,CAC/B;;;;;AAMF,IAAa,OAAO,SAAA,QACD,KACf,OAAO,SAAS,EAAE,SAAS,OAAO,cAAc,GAAG,WAAW,IAAI,CAAC,CAAC,GACpE,OAAO,IAAI,OAAO,YAAY,CAChC,CAAC,CAAC,KAAK,OAAO,SAAS,UAAU,CAAC"}
1
+ {"version":3,"file":"Blob.mjs","names":[],"sources":["../../src/Blob.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as Database from './Database';\nimport * as Error from './Error';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Type from './Type';\n\n/**\n * Inline blob data: bytes stored directly on the ECHO object.\n */\nexport const InlineData = Schema.TaggedStruct('inline', {\n bytes: Schema.Uint8Array.annotate({ jsonSchema: { type: 'string', contentEncoding: 'base64' } }),\n});\n\n/**\n * External blob data: bytes stored by a registered blob backend, addressed by `uri`.\n */\nexport const ExternalData = Schema.TaggedStruct('external', {\n /**\n * URI locating the bytes. The scheme selects the backend at read time (e.g. `ni:///sha-256;…` for\n * the edge backend — an RFC 6920 content digest, not a backend name — or `wnfs://…` for the\n * plugin-wnfs extension), resolved via the scheme→backend map built from `registerBlobBackend`\n * calls. Core code never parses or constructs backend-specific URIs beyond reading the scheme.\n *\n * @see {@link https://www.rfc-editor.org/rfc/rfc6920 RFC 6920} for the `ni:` URI format.\n */\n uri: Schema.String,\n});\n\nexport const BlobData = Schema.Union([InlineData, ExternalData]);\nexport type BlobData = Schema.Schema.Type<typeof BlobData>;\n\n/**\n * Runtime schema for a Blob object.\n *\n * NOTE: This export shadows the DOM `Blob` global within modules that import it as a namespace.\n * Code that needs the DOM class should use `globalThis.Blob` explicitly.\n *\n * @example\n * ```ts\n * const blob = yield* Blob.fromBytes(bytes, { type: 'image/png' });\n * ```\n */\nexport class Blob extends Type.makeObject<Blob>(DXN.make('org.dxos.type.blob', '0.1.0'))(\n Schema.Struct({\n /** MIME type. */\n type: Schema.optional(Schema.String),\n size: Schema.Number,\n data: BlobData,\n }).pipe(\n internal.HiddenAnnotation.set(true),\n Annotation.IconAnnotation.set({ icon: 'ph--file--regular', hue: 'teal' }),\n ),\n) {}\n\n//\n// Storage constants\n//\n\n/**\n * Storage backend names, selected at write time via {@link FromBytesOptions.storage}. Call sites\n * always use these constants, never raw string literals. Extensions (e.g. plugin-wnfs) define\n * their own storage names in their own package — core code knows nothing of them.\n *\n * Distinct from {@link Scheme}: a storage name picks *where* to write, a URI scheme describes\n * *what the identifier is* at read time. They coincide for backends with no content-addressing\n * (e.g. wnfs uses `'wnfs'` for both), but the edge backend's storage name (`'edge'`) differs from\n * its URI scheme (`Scheme.ni`) because the identifier it produces is a content hash, not an\n * edge-specific address.\n */\nexport const Storage = { inline: 'inline', edge: 'edge' } as const;\nexport type Storage = (typeof Storage)[keyof typeof Storage];\n\n/**\n * URI schemes claimed by core backends (see `BlobBackend.schemes` in `@dxos/echo-protocol`).\n *\n * `ni` marks an {@link https://www.rfc-editor.org/rfc/rfc6920 RFC 6920} Named Information URI whose\n * authority is empty and whose path carries a registered hash-algorithm name plus a base64url-encoded\n * digest (e.g. `ni:///sha-256;UyaQNQIUxQKgg1jVMKMbg1Yr8Rrb2Y3RaOx2N0mVJhc`, produced by the edge\n * backend). The scheme names *what the identifier is* — a content digest over the complete blob —\n * not which backend wrote it, so any backend or cache that can resolve that digest may claim it.\n * The URI is an identity claim, not a retrievability promise; transport is selected by the registered\n * backend at read time.\n *\n * Extensions (e.g. plugin-wnfs) define their own schemes in their own package.\n */\nexport const Scheme = { ni: 'ni' } as const;\nexport type Scheme = (typeof Scheme)[keyof typeof Scheme];\n\n//\n// Factory\n//\n\nexport const MAX_INLINE_SIZE = 4 * 1024 * 1024;\n\n/**\n * Creates a new blob object. Does not add it to the database — see {@link fromBytes}.\n */\nexport const make = (props: Obj.MakeProps<typeof Blob>): Blob => Obj.make(Blob, props);\n\n/**\n * Creates an inline {@link BlobData} variant that embeds raw bytes on the ECHO object.\n */\nexport const inlineData = (bytes: Uint8Array): BlobData => ({ _tag: 'inline', bytes });\n\n/**\n * Creates an external {@link BlobData} variant that references bytes held by a registered backend.\n * @param uri - Backend-scoped URI, e.g. as returned by a `BlobBackend.put` call.\n */\nexport const externalData = (uri: string): BlobData => ({ _tag: 'external', uri });\n\nexport interface FromBytesOptions {\n /** MIME type. */\n type?: string;\n /**\n * Storage backend name. Defaults to the registry's configured default (initially `'inline'`;\n * `@dxos/client` marks `'edge'` as the default when configured).\n */\n storage?: Storage | (string & {});\n}\n\n//\n// Operations\n//\n\n/**\n * Hashes and uploads `bytes` via the chosen storage backend (a no-op for `inline`), returning an\n * un-added Blob object. The caller is responsible for adding it to the database.\n *\n * @example\n * ```ts\n * const blob = yield* Blob.fromBytes(bytes, { type: 'image/png' });\n * yield* Database.add(blob);\n * ```\n */\nexport const fromBytes = (\n bytes: Uint8Array,\n options?: FromBytesOptions,\n): Effect.Effect<Blob, Error.BlobTooLargeError | Error.BlobWriteError, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) =>\n Effect.tryPromise({\n try: () => db.createBlob(bytes, options),\n catch: (error) =>\n error instanceof Error.BlobTooLargeError || error instanceof Error.BlobWriteError\n ? error\n : new Error.BlobWriteError({ backend: options?.storage ?? 'unknown' }, { cause: error }),\n }),\n ),\n ).pipe(Effect.withSpan('Blob.fromBytes'));\n\n/**\n * Loads a blob's bytes. Inline: read directly off the object. External: dispatched to the\n * registered backend for the URI's scheme.\n *\n * @example\n * ```ts\n * const bytes = yield* Blob.read(blob);\n * ```\n */\nexport const read = (blob: Blob): Effect.Effect<Uint8Array, Error.BlobNotAvailableError, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) =>\n Effect.tryPromise({\n try: () => db.readBlob(blob),\n catch: (error) =>\n error instanceof Error.BlobNotAvailableError\n ? error\n : new Error.BlobNotAvailableError(\n { backend: 'unknown', key: blob.id, reason: 'not-found' },\n { cause: error },\n ),\n }),\n ),\n ).pipe(Effect.withSpan('Blob.read'));\n\n/**\n * Checks whether a blob's bytes are currently available.\n */\nexport const exists = (blob: Blob): Effect.Effect<boolean, never, Database.Service> =>\n Database.Service.pipe(Effect.flatMap(({ db }) => Effect.promise(() => db.blobExists(blob)))).pipe(\n Effect.withSpan('Blob.exists'),\n );\n\n/**\n * Returns a renderable URL for the blob: inline blobs resolve to a `data:` URL; external blobs\n * are resolved by the registered backend's `getUrl`, if it implements one.\n */\nexport const url = (blob: Blob): Effect.Effect<Option.Option<string>, never, Database.Service> =>\n Database.Service.pipe(\n Effect.flatMap(({ db }) => Effect.promise(() => db.getBlobUrl(blob))),\n Effect.map(Option.fromNullishOr),\n ).pipe(Effect.withSpan('Blob.url'));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,aAAa,OAAO,aAAa,UAAU,EACtD,OAAO,OAAO,WAAW,SAAS,EAAE,YAAY;CAAE,MAAM;CAAU,iBAAiB;AAAS,EAAE,CAAC,EACjG,CAAC;;;;AAKD,IAAa,eAAe,OAAO,aAAa,YAAY;;;;;;;;;AAS1D,KAAK,OAAO,OACd,CAAC;AAED,IAAa,WAAW,OAAO,MAAM,CAAC,YAAY,YAAY,CAAC;;;;;;;;;;;;AAc/D,IAAa,OAAb,cAA0B,WAAsB,IAAI,KAAK,sBAAsB,OAAO,CAAC,CAAC,CACtF,OAAO,OAAO;;CAEZ,MAAM,OAAO,SAAS,OAAO,MAAM;CACnC,MAAM,OAAO;CACb,MAAM;AACR,CAAC,CAAC,CAAC,KAAA,iBACyB,IAAI,IAAI,GAAA,eACR,IAAI;CAAE,MAAM;CAAqB,KAAK;AAAO,CAAC,CAC1E,CACF,CAAC,CAAC,CAAC;;;;;;;;;;;;AAiBH,IAAa,UAAU;CAAE,QAAQ;CAAU,MAAM;AAAO;;;;;;;;;;;;;;AAgBxD,IAAa,SAAS,EAAE,IAAI,KAAK;AAOjC,IAAa,kBAAkB;;;;AAK/B,IAAa,QAAQ,UAA4C,OAAS,MAAM,KAAK;;;;AAKrF,IAAa,cAAc,WAAiC;CAAE,MAAM;CAAU;AAAM;;;;;AAMpF,IAAa,gBAAgB,SAA2B;CAAE,MAAM;CAAY;AAAI;;;;;;;;;;;AA0BhF,IAAa,aACX,OACA,YAAA,QAEiB,KACf,OAAO,SAAS,EAAE,SAChB,OAAO,WAAW;CAChB,WAAW,GAAG,WAAW,OAAO,OAAO;CACvC,QAAQ,UACN,iBAAiB,qBAA2B,iBAAiB,iBACzD,QACA,IAAI,eAAqB,EAAE,SAAS,SAAS,WAAW,UAAU,GAAG,EAAE,OAAO,MAAM,CAAC;AAC7F,CAAC,CACH,CACF,CAAC,CAAC,KAAK,OAAO,SAAS,gBAAgB,CAAC;;;;;;;;;;AAW1C,IAAa,QAAQ,SAAA,QACF,KACf,OAAO,SAAS,EAAE,SAChB,OAAO,WAAW;CAChB,WAAW,GAAG,SAAS,IAAI;CAC3B,QAAQ,UACN,iBAAiB,wBACb,QACA,IAAI,sBACF;EAAE,SAAS;EAAW,KAAK,KAAK;EAAI,QAAQ;CAAY,GACxD,EAAE,OAAO,MAAM,CACjB;AACR,CAAC,CACH,CACF,CAAC,CAAC,KAAK,OAAO,SAAS,WAAW,CAAC;;;;AAKrC,IAAa,UAAU,SAAA,QACJ,KAAK,OAAO,SAAS,EAAE,SAAS,OAAO,cAAc,GAAG,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAC3F,OAAO,SAAS,aAAa,CAC/B;;;;;AAMF,IAAa,OAAO,SAAA,QACD,KACf,OAAO,SAAS,EAAE,SAAS,OAAO,cAAc,GAAG,WAAW,IAAI,CAAC,CAAC,GACpE,OAAO,IAAI,OAAO,aAAa,CACjC,CAAC,CAAC,KAAK,OAAO,SAAS,UAAU,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { B as FormInputAnnotation, X as IconAnnotation } from "./chunk-Database.mjs";
3
+ import { makeObject } from "./Type.mjs";
4
+ import { Ref } from "./Ref.mjs";
5
+ import { Unknown, instanceOf, make as make$1 } from "./Obj.mjs";
6
+ import { DXN } from "@dxos/keys";
7
+ import * as Schema from "effect/Schema";
8
+ //#region src/Collection.ts
9
+ var Collection_exports = /* @__PURE__ */ __exportAll({
10
+ Collection: () => Collection,
11
+ isCollection: () => isCollection,
12
+ make: () => make
13
+ });
14
+ /**
15
+ * A an ordered set of objects.
16
+ */
17
+ var Collection = class extends makeObject(DXN.make("org.dxos.type.collection", "0.1.0"))(Schema.Struct({
18
+ name: Schema.String.pipe(Schema.optional),
19
+ objects: Schema.Array(Ref(Unknown)).pipe(FormInputAnnotation.set(false))
20
+ }).pipe(IconAnnotation.set({
21
+ icon: "ph--folder--regular",
22
+ hue: "indigo"
23
+ }))) {};
24
+ var make = (props = {}) => make$1(Collection, {
25
+ objects: [],
26
+ ...props
27
+ });
28
+ var isCollection = instanceOf(Collection);
29
+ //#endregion
30
+ export { Collection, isCollection, make, Collection_exports as t };
31
+
32
+ //# sourceMappingURL=Collection.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.mjs","names":[],"sources":["../../src/Collection.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Ref from './Ref';\nimport * as Type from './Type';\n\n/**\n * A an ordered set of objects.\n */\nexport class Collection extends Type.makeObject<Collection>(DXN.make('org.dxos.type.collection', '0.1.0'))(\n Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n objects: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(internal.FormInputAnnotation.set(false)),\n }).pipe(Annotation.IconAnnotation.set({ icon: 'ph--folder--regular', hue: 'indigo' })),\n) {}\n\nexport const make = (props: Partial<Obj.MakeProps<typeof Collection>> = {}): Type.InstanceType<typeof Collection> =>\n Obj.make(Collection, { objects: [], ...props });\n\nexport const isCollection: (value: unknown) => value is Type.InstanceType<typeof Collection> =\n Obj.instanceOf(Collection);\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAa,aAAb,cAAgC,WAA4B,IAAI,KAAK,4BAA4B,OAAO,CAAC,CAAC,CACxG,OAAO,OAAO;CACZ,MAAM,OAAO,OAAO,KAAK,OAAO,QAAQ;CACxC,SAAS,OAAO,MAAM,IAAQ,OAAW,CAAC,CAAC,CAAC,KAAA,oBAAkC,IAAI,KAAK,CAAC;AAC1F,CAAC,CAAC,CAAC,KAAA,eAA+B,IAAI;CAAE,MAAM;CAAuB,KAAK;AAAS,CAAC,CAAC,CACvF,CAAC,CAAC,CAAC;AAEH,IAAa,QAAQ,QAAmD,CAAC,MACvE,OAAS,YAAY;CAAE,SAAS,CAAC;CAAG,GAAG;AAAM,CAAC;AAEhD,IAAa,eACX,WAAe,UAAU"}
@@ -1,2 +1,2 @@
1
- import { _ as remove, a as add, b as subscribeToSyncState, c as deleteFromFeed, d as isDatabase, f as layer, g as query, h as notAvailable, i as TypeId, l as flush, m as makeService, o as addType, p as load, r as Service, s as appendToFeed, t as Database, u as getSyncState, v as resolve, y as spaceId } from "./chunk-Database.mjs";
2
- export { Database, Service, TypeId, add, addType, appendToFeed, deleteFromFeed, flush, getSyncState, isDatabase, layer, load, makeService, notAvailable, query, remove, resolve, spaceId, subscribeToSyncState };
1
+ import { C as subscribeToSyncState, S as stats, _ as remove, a as add, b as runGarbageCollection, c as deleteFromFeed, d as isDatabase, f as layer, g as query, h as notAvailable, i as TypeId, l as flush, m as makeService, o as addType, p as load, r as Service, s as appendToFeed, t as Database, u as getSyncState, v as resolve, x as spaceId, y as retainObjects } from "./chunk-Database.mjs";
2
+ export { Database, Service, TypeId, add, addType, appendToFeed, deleteFromFeed, flush, getSyncState, isDatabase, layer, load, makeService, notAvailable, query, remove, resolve, retainObjects, runGarbageCollection, spaceId, stats, subscribeToSyncState };
@@ -0,0 +1,24 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { getSchema } from "./Type.mjs";
3
+ import { instanceOf } from "./Obj.mjs";
4
+ import { Feed } from "./Feed.mjs";
5
+ import { Collection } from "./Collection.mjs";
6
+ import { View } from "./View.mjs";
7
+ import { pipe } from "effect/Function";
8
+ import * as Schema from "effect/Schema";
9
+ import * as Predicate from "effect/Predicate";
10
+ //#region src/Dataset.ts
11
+ var Dataset_exports = /* @__PURE__ */ __exportAll({
12
+ Dataset: () => Dataset,
13
+ isDataset: () => isDataset
14
+ });
15
+ var Dataset = Schema.Union([
16
+ getSchema(Feed),
17
+ getSchema(Collection),
18
+ getSchema(View)
19
+ ]);
20
+ var isDataset = pipe(instanceOf(Feed), Predicate.or(instanceOf(Collection)), Predicate.or(instanceOf(View)));
21
+ //#endregion
22
+ export { Dataset, isDataset, Dataset_exports as t };
23
+
24
+ //# sourceMappingURL=Dataset.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dataset.mjs","names":[],"sources":["../../src/Dataset.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { pipe } from 'effect/Function';\nimport * as Predicate from 'effect/Predicate';\nimport * as Schema from 'effect/Schema';\n\nimport * as Collection from './Collection';\nimport * as Feed from './Feed';\nimport * as Obj from './Obj';\nimport * as Type from './Type';\nimport * as View from './View';\n\n/**\n * Abstract set of objects, represented by a view, feed, or collection.\n * Schema-level union of the underlying type entities (rebuilt via\n * `Type.getSchema`) so this can still be consumed by Schema-side APIs such\n * as `Filter.type(...)` on a union.\n */\nexport type Dataset = Feed.Feed | Collection.Collection | View.View;\nexport const Dataset = Schema.Union([\n Type.getSchema(Feed.Feed),\n Type.getSchema(Collection.Collection),\n Type.getSchema(View.View),\n]);\n\nexport const isDataset: (value: unknown) => value is Dataset = pipe(\n Obj.instanceOf(Feed.Feed),\n Predicate.or(Obj.instanceOf(Collection.Collection)),\n Predicate.or(Obj.instanceOf(View.View)),\n);\n"],"mappings":";;;;;;;;;;;;;;AAuBA,IAAa,UAAU,OAAO,MAAM;CAClC,UAAe,IAAS;CACxB,UAAe,UAAqB;CACpC,UAAe,IAAS;AAC1B,CAAC;AAED,IAAa,YAAkD,KAC7D,WAAe,IAAS,GACxB,UAAU,GAAG,WAAe,UAAqB,CAAC,GAClD,UAAU,GAAG,WAAe,IAAS,CAAC,CACxC"}
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { a as isEntity$1, c as getKeys$1, l as getMetaChecked, o as addTag$1, u as removeTag$1 } from "./chunk-atom-snapshot.mjs";
2
+ import { d as removeTag$1, l as getKeys$1, o as isEntity$1, s as addTag$1, u as getMetaChecked } from "./chunk-atom-snapshot.mjs";
3
3
  import { T as objectToJSON, c as makeEntity, h as isDeleted$1, l as makeLabelAtom } from "./chunk-internal.mjs";
4
4
  import { d as SnapshotKindId$1, l as KindId$1, m as getEntityKindBrand, o as EntityKind, s as EntityKindSchema } from "./chunk-util.mjs";
5
- import { Ct as getTypename$1, Dt as setLabel$1, Gt as MetaId, Lt as getType$1, S as isInstanceOf, St as getTypeURI$1, T as getUri, ct as getDescription$1, ft as getIcon$1, mt as getLabelProperty, pt as getLabel$1, ut as getEntityKind, w as getDatabase$1 } from "./chunk-Database.mjs";
6
- import { g as subscribe$1, h as change } from "./chunk-ref.mjs";
5
+ import { At as setLabel$1, Bt as getType$1, D as getDatabase$1, Et as getTypename$1, Jt as MetaId, O as getUri, T as isInstanceOf, Tt as getTypeURI$1, _t as getLabelProperty, dt as getDescription$1, gt as getLabel$1, ht as getIcon$1, pt as getEntityKind } from "./chunk-Database.mjs";
6
+ import { _ as subscribe$1, g as change } from "./chunk-ref.mjs";
7
7
  import { Type, getTypename as getTypename$2, getURI as getURI$1 } from "./Type.mjs";
8
8
  import * as Schema from "effect/Schema";
9
9
  //#region src/Entity.ts
@@ -58,10 +58,7 @@ var KindSchema = EntityKindSchema;
58
58
  * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no
59
59
  * `TypeAnnotation`.
60
60
  */
61
- var Unknown = Schema.Struct({ id: Schema.String }).pipe(Schema.extend(Schema.Record({
62
- key: Schema.String,
63
- value: Schema.Unknown
64
- })));
61
+ var Unknown = Schema.StructWithRest(Schema.Struct({ id: Schema.String }), [Schema.Record(Schema.String, Schema.Unknown)]);
65
62
  /**
66
63
  * Check if a value is an ECHO entity (object or relation).
67
64
  * Returns `false` for snapshots.
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.mjs","names":[],"sources":["../../src/Entity.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport type { EntityId, URI } from '@dxos/keys';\n\nimport * as internal from './internal';\nimport * as objInternal from './internal/Obj';\nimport type * as Ref from './Ref';\nimport type * as Relation from './Relation';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\n// Re-export KindId and SnapshotKindId from internal.\nexport const KindId = internal.KindId;\nexport type KindId = typeof internal.KindId;\nexport const SnapshotKindId = internal.SnapshotKindId;\nexport type SnapshotKindId = typeof internal.SnapshotKindId;\n\n// NOTE: Relation does not extend Obj so that, for example, we can prevent Relations from being used as source and target objects.\n// However, we generally refer to Obj and Relation instances as \"objects\",\n// and many API methods accept both Obj.Unknown and Relation.Unknown (i.e., Entity.Unknown) instances.\n\nexport const Kind = internal.EntityKind;\nexport type Kind = internal.EntityKind;\nexport const KindSchema = internal.EntityKindSchema;\n\n/**\n * Assigns a kind to an Object or Relation instance.\n * NOTE: Needed to make `isRelation` and `isObject` checks work.\n */\nexport interface OfKind<K extends Kind> {\n readonly [KindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Assigns a snapshot kind to an Object or Relation snapshot.\n */\nexport interface SnapshotOfKind<K extends Kind> {\n readonly [SnapshotKindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Obj or Relation with a specific set of properties.\n */\nexport type Entity<Props> = OfKind<Kind> & Props;\n\n/**\n * Unknown Obj or Relation (reactive).\n */\nexport interface Unknown extends OfKind<Kind> {}\n\n/**\n * Effect Schema for any ECHO entity (object or relation).\n *\n * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates\n * the structural shape (id + properties) without constraining `[KindId]`. Used\n * in operation input schemas that accept any entity flavour (e.g.\n * `Schema.Array(Entity.Unknown)`).\n *\n * The cast bridges the runtime structural schema to the branded `Unknown` type:\n * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,\n * so the entity guarantee is carried at the type level only (same approach as\n * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it\n * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no\n * `TypeAnnotation`.\n */\nexport const Unknown: Schema.Schema<Unknown> = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n) as unknown as Schema.Schema<Unknown>;\n\n/**\n * Snapshot of an Obj or Relation.\n * Branded with SnapshotKindId instead of KindId.\n */\nexport interface Snapshot extends SnapshotOfKind<Kind> {}\n\n/**\n * Object with arbitrary properties.\n *\n * NOTE: Due to how typescript works, this type is not assignable to a specific schema type.\n * In that case, use `Obj.instanceOf` to check if an object is of a specific type.\n *\n * This type is very permissive and allows accessing any property on the object.\n * We should move to Obj.Unknown that is not permissive and requires explicit instanceof checks..\n */\nexport interface Any extends OfKind<Kind> {\n [key: string]: unknown;\n}\n\n/**\n * Returns all properties of an object or relation except for the id and kind.\n */\nexport type Properties<T> = Omit<T, 'id' | KindId | Relation.Source | Relation.Target>;\n\n/**\n * Check if a value is an ECHO entity (object or relation).\n * Returns `false` for snapshots.\n */\nexport const isEntity: (value: unknown) => value is Unknown = internal.isEntity;\n\n/**\n * Test if a value is an instance of a given object or relation type.\n *\n * Kind-agnostic counterpart to `Obj.instanceOf` / `Relation.instanceOf` —\n * use this when the caller's input type is `Type.AnyObj | Type.AnyRelation`.\n *\n * @example\n * ```ts\n * // Caller doesn't know whether `type` is object- or relation-kind.\n * const matches = <T extends Type.AnyObj | Type.AnyRelation>(type: T, value: unknown) =>\n * Entity.instanceOf(type, value);\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyEntity>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyEntity>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyEntity, value?: unknown]) => {\n if (args.length === 1) {\n return (entity: unknown) => internal.isInstanceOf(args[0], entity);\n }\n return internal.isInstanceOf(args[0], args[1]);\n}) as any;\n\n/**\n * Check if a value is an ECHO entity snapshot.\n * Returns `false` for entities.\n */\nexport const isSnapshot = (value: unknown): value is Snapshot => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[SnapshotKindId] !== undefined;\n};\n\n// TODO(dmaretskyi): Type introspection -- move to kind.\nexport const getKind = internal.getEntityKind;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport const Meta: unique symbol = internal.MetaId as any;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport type Meta = typeof Meta;\n\n//\n// Entity-level functions that work on any entity (object or relation).\n// Use these when you don't know or care about the specific entity kind.\n// For kind-specific functions, use Obj.* or Relation.*.\n//\n\n/**\n * JSON representation of an entity.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Whether the entity is a type-kind entity (a `Type.Type` produced by\n * `Type.makeObject` / `Type.makeRelation`, or a persisted schema). Type entities\n * carry their identity (typename/version) on themselves rather than referencing a\n * separate type, so the accessors below route them through the `Type.*` module.\n */\nconst isTypeEntity = (entity: unknown): boolean => internal.getEntityKindBrand(entity) === internal.EntityKind.Type;\n\n/**\n * Any value the read accessors operate on: a reactive entity or a snapshot.\n * Type entities (`Type.AnyEntity`) are also accepted — they're first-class\n * entities, and `Unknown`'s kind-agnostic brand already subsumes them.\n */\nexport type AnyInput = Unknown | Snapshot;\n\n/**\n * Get the canonical URI of an entity (object, relation, or type). Returns `URI.URI` —\n * an `EID` for object/relation instances and persisted types, or a typename\n * `DXN` for static type entities; narrow with `EID.parse(uri)` or\n * `DXN.tryMake(uri)` at the point of use.\n *\n * @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).\n */\nexport const getURI = (entity: AnyInput, options?: internal.GetURIOptions): URI.URI =>\n isTypeEntity(entity) ? Type.getURI(entity as Type.AnyEntity, options) : internal.getUri(entity as Unknown, options);\n\n/**\n * Get the DXN of an entity's type. For object/relation instances this is the URI\n * of the type they were created from; for a type entity it is the URI of the\n * meta-type ({@link Type.Type}, `dxn:org.dxos.type.schema:0.1.0`).\n */\nexport const getTypeURI = (entity: AnyInput): URI.URI | undefined =>\n isTypeEntity(entity) ? Type.getURI(Type.Type) : internal.getTypeURI(entity as Unknown);\n\n/**\n * Get the type entity (`Type.AnyEntity`) the instance was created from.\n *\n * Returns `undefined` when the entity's type isn't registered in this runtime\n * (e.g. a freshly deserialized snapshot whose type entity hasn't been wired\n * up yet, or an entity loaded from storage before its schema is known). To\n * get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n *\n * For a type entity, returns the meta-type {@link Type.Type} (a type entity's\n * type is \"Type\").\n */\nexport const getType = (entity: AnyInput): Type.AnyEntity | undefined =>\n isTypeEntity(entity) ? Type.Type : (internal.getType(entity) as Type.AnyEntity | undefined);\n\n/**\n * Get the typename of an entity's type. For object/relation instances this is the\n * typename of the type they were created from; for a type entity it is the type's\n * own typename (e.g. `com.example.type.person`).\n */\nexport const getTypename = (entity: AnyInput): string | undefined =>\n isTypeEntity(entity) ? Type.getTypename(entity as Type.AnyEntity) : internal.getTypename(entity as Unknown);\n\n/**\n * Get the database an entity belongs to.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): any | undefined => internal.getDatabase(entity);\n\n/**\n * Get the metadata for an entity.\n * Returns mutable meta when passed a mutable entity (inside change callback).\n * Returns read-only meta when passed a regular entity or snapshot.\n */\n// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\nexport function getMeta(entity: Mutable<Unknown>): internal.EntityMeta;\nexport function getMeta(entity: Unknown | Snapshot): internal.ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.EntityMeta | internal.ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * Get foreign keys for an entity from the specified source.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Check if an entity is deleted.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n/**\n * Get the label of an entity.\n *\n * @param options.fallback `'typename'` returns the entity's typename when no\n * label is set (e.g. `org.dxos.type.table`).\n */\nexport const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>\n internal.getLabel(entity, options);\n\n/**\n * Set the label of an entity.\n * Must be called within an `Entity.update` / `Obj.update` / `Relation.update` callback.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of an entity.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Get the icon annotation for an entity (object or relation), resolved via its type-level\n * `IconAnnotation`. Returns the full `{ icon, hue }` annotation so callers can use both\n * the phosphor icon name and the suggested colour.\n */\nexport const getIcon = (entity: Unknown | Snapshot): internal.IconAnnotation | undefined => internal.getIcon(entity);\n\n/**\n * Convert an entity to its JSON representation.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n/**\n * Subscribe to changes on an entity (object or relation).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (entity: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(entity, callback);\n};\n\n//\n// Change\n//\n\n/**\n * Used to provide a mutable view of an entity within `Entity.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an entity (object or relation) within a change context.\n *\n * Entities are read-only by default. Mutations are batched and notifications fire\n * when the callback completes. Direct mutations outside of `Entity.update` will throw\n * at runtime.\n *\n * @param entity - The echo entity (object or relation) to mutate.\n * @param callback - Receives a mutable view of the entity. All mutations must occur here.\n *\n * @example\n * ```typescript\n * // Mutate within Entity.update\n * Entity.update(entity, (obj) => {\n * obj.name = 'Updated';\n * obj.count = 42;\n * });\n *\n * // Direct mutation throws\n * entity.name = 'Bob'; // Error: Cannot modify outside Entity.update()\n * ```\n *\n * Note: For type-specific operations, prefer `Obj.update` or `Relation.update`.\n */\nexport const update = <T extends Unknown>(entity: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(entity, callback);\n};\n\n/**\n * Add a tag to an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n//\n// Atoms\n//\n\nexport const atom = objInternal.makeEntity;\nexport const labelAtom = objInternal.makeLabelAtom;\nexport const labelProperty = internal.getLabelProperty;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,SAAS;AAEtB,IAAa,iBAAiB;AAO9B,IAAa,OAAO;AAEpB,IAAa,aAAa;;;;;;;;;;;;;;;;AA4C1B,IAAa,UAAkC,OAAO,OAAO,EAC3D,IAAI,OAAO,OACb,CAAC,CAAC,CAAC,KACD,OAAO,OAAO,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,OAAO,OAAO;AAAQ,CAAC,CAAC,CAC5E;;;;;AA8BA,IAAa,WAAiD;;;;;;;;;;;;;;AAe9D,IAAa,eAGP,GAAG,SAAoD;CAC3D,IAAI,KAAK,WAAW,GAClB,QAAQ,WAAoB,aAAsB,KAAK,IAAI,MAAM;CAEnE,OAAO,aAAsB,KAAK,IAAI,KAAK,EAAE;AAC/C;;;;;AAMA,IAAa,cAAc,UAAsC;CAC/D,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAET,OAAQ,MAAc,oBAAoB,KAAA;AAC5C;AAGA,IAAa,UAAU;;;;AAKvB,IAAa,OAAsB;;;;;;;AAwBnC,IAAM,gBAAgB,WAA6B,mBAA4B,MAAM,MAAA,WAA0B;;;;;;;;;AAiB/G,IAAa,UAAU,QAAkB,YACvC,aAAa,MAAM,IAAI,SAAY,QAA0B,OAAO,IAAI,OAAgB,QAAmB,OAAO;;;;;;AAOpH,IAAa,cAAc,WACzB,aAAa,MAAM,IAAI,SAAY,IAAS,IAAI,aAAoB,MAAiB;;;;;;;;;;;;AAavF,IAAa,WAAW,WACtB,aAAa,MAAM,IAAI,OAAa,UAAiB,MAAM;;;;;;AAO7D,IAAa,eAAe,WAC1B,aAAa,MAAM,IAAI,cAAiB,MAAwB,IAAI,cAAqB,MAAiB;;;;AAK5G,IAAa,eAAe,WAAgD,cAAqB,MAAM;AAUvG,SAAgB,QAAQ,QAA4F;CAClH,OAAO,eAAwB,MAAM;AACvC;;;;AAKA,IAAa,WAAW,QAA4B,WAAiC,UAAiB,QAAQ,MAAM;;;;AAKpH,IAAa,aAAa,WAAwC,YAAmB,MAAM;;;;;;;AAQ3F,IAAa,YAAY,QAA4B,YACnD,WAAkB,QAAQ,OAAO;;;;;AAMnC,IAAa,YAAY,QAA0B,UAAwB,WAAkB,QAAQ,KAAK;;;;AAK1G,IAAa,kBAAkB,WAAmD,iBAAwB,MAAM;;;;;;AAOhH,IAAa,WAAW,WAAoE,UAAiB,MAAM;;;;AAKnH,IAAa,UAAU,WAAqC,aAAsB,MAAM;;;;;AAMxF,IAAa,aAAa,QAAiB,aAAuC;CAChF,OAAO,YAAmB,QAAQ,QAAQ;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa,UAA6B,QAAW,aAA+C;CAClG,OAAgB,QAAQ,QAAQ;AAClC;;;;;AAMA,IAAa,UAAU,QAA0B,QAAgC,SAAgB,QAAQ,GAAG;;;;;AAM5G,IAAa,aAAa,QAA0B,QAAgC,YAAmB,QAAQ,GAAG;AAMlH,IAAa,OAAO;AACpB,IAAa,YAAY;AACzB,IAAa,gBAAgB"}
1
+ {"version":3,"file":"Entity.mjs","names":[],"sources":["../../src/Entity.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport type { EntityId, URI } from '@dxos/keys';\n\nimport * as internal from './internal';\nimport * as objInternal from './internal/Obj';\nimport type * as Ref from './Ref';\nimport type * as Relation from './Relation';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\n// Re-export KindId and SnapshotKindId from internal.\nexport const KindId = internal.KindId;\nexport type KindId = typeof internal.KindId;\nexport const SnapshotKindId = internal.SnapshotKindId;\nexport type SnapshotKindId = typeof internal.SnapshotKindId;\n\n// NOTE: Relation does not extend Obj so that, for example, we can prevent Relations from being used as source and target objects.\n// However, we generally refer to Obj and Relation instances as \"objects\",\n// and many API methods accept both Obj.Unknown and Relation.Unknown (i.e., Entity.Unknown) instances.\n\nexport const Kind = internal.EntityKind;\nexport type Kind = internal.EntityKind;\nexport const KindSchema = internal.EntityKindSchema;\n\n/**\n * Assigns a kind to an Object or Relation instance.\n * NOTE: Needed to make `isRelation` and `isObject` checks work.\n */\nexport interface OfKind<K extends Kind> {\n readonly [KindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Assigns a snapshot kind to an Object or Relation snapshot.\n */\nexport interface SnapshotOfKind<K extends Kind> {\n readonly [SnapshotKindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Obj or Relation with a specific set of properties.\n */\nexport type Entity<Props> = OfKind<Kind> & Props;\n\n/**\n * Unknown Obj or Relation (reactive).\n */\nexport interface Unknown extends OfKind<Kind> {}\n\n/**\n * Effect Schema for any ECHO entity (object or relation).\n *\n * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates\n * the structural shape (id + properties) without constraining `[KindId]`. Used\n * in operation input schemas that accept any entity flavour (e.g.\n * `Schema.Array(Entity.Unknown)`).\n *\n * The cast bridges the runtime structural schema to the branded `Unknown` type:\n * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,\n * so the entity guarantee is carried at the type level only (same approach as\n * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it\n * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no\n * `TypeAnnotation`.\n */\nexport const Unknown: Schema.Codec<Unknown> = Schema.StructWithRest(Schema.Struct({ id: Schema.String }), [\n Schema.Record(Schema.String, Schema.Unknown),\n]) as unknown as Schema.Codec<Unknown>;\n\n/**\n * Snapshot of an Obj or Relation.\n * Branded with SnapshotKindId instead of KindId.\n */\nexport interface Snapshot extends SnapshotOfKind<Kind> {}\n\n/**\n * Object with arbitrary properties.\n *\n * NOTE: Due to how typescript works, this type is not assignable to a specific schema type.\n * In that case, use `Obj.instanceOf` to check if an object is of a specific type.\n *\n * This type is very permissive and allows accessing any property on the object.\n * We should move to Obj.Unknown that is not permissive and requires explicit instanceof checks..\n */\nexport interface Any extends OfKind<Kind> {\n [key: string]: unknown;\n}\n\n/**\n * Returns all properties of an object or relation except for the id and kind.\n */\nexport type Properties<T> = Omit<T, 'id' | KindId | Relation.Source | Relation.Target>;\n\n/**\n * Check if a value is an ECHO entity (object or relation).\n * Returns `false` for snapshots.\n */\nexport const isEntity: (value: unknown) => value is Unknown = internal.isEntity;\n\n/**\n * Test if a value is an instance of a given object or relation type.\n *\n * Kind-agnostic counterpart to `Obj.instanceOf` / `Relation.instanceOf` —\n * use this when the caller's input type is `Type.AnyObj | Type.AnyRelation`.\n *\n * @example\n * ```ts\n * // Caller doesn't know whether `type` is object- or relation-kind.\n * const matches = <T extends Type.AnyObj | Type.AnyRelation>(type: T, value: unknown) =>\n * Entity.instanceOf(type, value);\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyEntity>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyEntity>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyEntity, value?: unknown]) => {\n if (args.length === 1) {\n return (entity: unknown) => internal.isInstanceOf(args[0], entity);\n }\n return internal.isInstanceOf(args[0], args[1]);\n}) as any;\n\n/**\n * Check if a value is an ECHO entity snapshot.\n * Returns `false` for entities.\n */\nexport const isSnapshot = (value: unknown): value is Snapshot => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[SnapshotKindId] !== undefined;\n};\n\n// TODO(dmaretskyi): Type introspection -- move to kind.\nexport const getKind = internal.getEntityKind;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport const Meta: unique symbol = internal.MetaId as any;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport type Meta = typeof Meta;\n\n//\n// Entity-level functions that work on any entity (object or relation).\n// Use these when you don't know or care about the specific entity kind.\n// For kind-specific functions, use Obj.* or Relation.*.\n//\n\n/**\n * JSON representation of an entity.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Whether the entity is a type-kind entity (a `Type.Type` produced by\n * `Type.makeObject` / `Type.makeRelation`, or a persisted schema). Type entities\n * carry their identity (typename/version) on themselves rather than referencing a\n * separate type, so the accessors below route them through the `Type.*` module.\n */\nconst isTypeEntity = (entity: unknown): boolean => internal.getEntityKindBrand(entity) === internal.EntityKind.Type;\n\n/**\n * Any value the read accessors operate on: a reactive entity or a snapshot.\n * Type entities (`Type.AnyEntity`) are also accepted — they're first-class\n * entities, and `Unknown`'s kind-agnostic brand already subsumes them.\n */\nexport type AnyInput = Unknown | Snapshot;\n\n/**\n * Get the canonical URI of an entity (object, relation, or type). Returns `URI.URI` —\n * an `EID` for object/relation instances and persisted types, or a typename\n * `DXN` for static type entities; narrow with `EID.parse(uri)` or\n * `DXN.tryMake(uri)` at the point of use.\n *\n * @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).\n */\nexport const getURI = (entity: AnyInput, options?: internal.GetURIOptions): URI.URI =>\n isTypeEntity(entity) ? Type.getURI(entity as Type.AnyEntity, options) : internal.getUri(entity as Unknown, options);\n\n/**\n * Get the DXN of an entity's type. For object/relation instances this is the URI\n * of the type they were created from; for a type entity it is the URI of the\n * meta-type ({@link Type.Type}, `dxn:org.dxos.type.schema:0.1.0`).\n */\nexport const getTypeURI = (entity: AnyInput): URI.URI | undefined =>\n isTypeEntity(entity) ? Type.getURI(Type.Type) : internal.getTypeURI(entity as Unknown);\n\n/**\n * Get the type entity (`Type.AnyEntity`) the instance was created from.\n *\n * Returns `undefined` when the entity's type isn't registered in this runtime\n * (e.g. a freshly deserialized snapshot whose type entity hasn't been wired\n * up yet, or an entity loaded from storage before its schema is known). To\n * get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n *\n * For a type entity, returns the meta-type {@link Type.Type} (a type entity's\n * type is \"Type\").\n */\nexport const getType = (entity: AnyInput): Type.AnyEntity | undefined =>\n isTypeEntity(entity) ? Type.Type : (internal.getType(entity) as Type.AnyEntity | undefined);\n\n/**\n * Get the typename of an entity's type. For object/relation instances this is the\n * typename of the type they were created from; for a type entity it is the type's\n * own typename (e.g. `com.example.type.person`).\n */\nexport const getTypename = (entity: AnyInput): string | undefined =>\n isTypeEntity(entity) ? Type.getTypename(entity as Type.AnyEntity) : internal.getTypename(entity as Unknown);\n\n/**\n * Get the database an entity belongs to.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): any | undefined => internal.getDatabase(entity);\n\n/**\n * Get the metadata for an entity.\n * Returns mutable meta when passed a mutable entity (inside change callback).\n * Returns read-only meta when passed a regular entity or snapshot.\n */\n// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\nexport function getMeta(entity: Mutable<Unknown>): internal.EntityMeta;\nexport function getMeta(entity: Unknown | Snapshot): internal.ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.EntityMeta | internal.ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * Get foreign keys for an entity from the specified source.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Check if an entity is deleted.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n/**\n * Get the label of an entity.\n *\n * @param options.fallback `'typename'` returns the entity's typename when no\n * label is set (e.g. `org.dxos.type.table`).\n */\nexport const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>\n internal.getLabel(entity, options);\n\n/**\n * Set the label of an entity.\n * Must be called within an `Entity.update` / `Obj.update` / `Relation.update` callback.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of an entity.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Get the icon annotation for an entity (object or relation), resolved via its type-level\n * `IconAnnotation`. Returns the full `{ icon, hue }` annotation so callers can use both\n * the phosphor icon name and the suggested colour.\n */\nexport const getIcon = (entity: Unknown | Snapshot): internal.IconAnnotation | undefined => internal.getIcon(entity);\n\n/**\n * Convert an entity to its JSON representation.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n/**\n * Subscribe to changes on an entity (object or relation).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (entity: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(entity, callback);\n};\n\n//\n// Change\n//\n\n/**\n * Used to provide a mutable view of an entity within `Entity.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an entity (object or relation) within a change context.\n *\n * Entities are read-only by default. Mutations are batched and notifications fire\n * when the callback completes. Direct mutations outside of `Entity.update` will throw\n * at runtime.\n *\n * @param entity - The echo entity (object or relation) to mutate.\n * @param callback - Receives a mutable view of the entity. All mutations must occur here.\n *\n * @example\n * ```typescript\n * // Mutate within Entity.update\n * Entity.update(entity, (obj) => {\n * obj.name = 'Updated';\n * obj.count = 42;\n * });\n *\n * // Direct mutation throws\n * entity.name = 'Bob'; // Error: Cannot modify outside Entity.update()\n * ```\n *\n * Note: For type-specific operations, prefer `Obj.update` or `Relation.update`.\n */\nexport const update = <T extends Unknown>(entity: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(entity, callback);\n};\n\n/**\n * Add a tag to an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n//\n// Atoms\n//\n\nexport const atom = objInternal.makeEntity;\nexport const labelAtom = objInternal.makeLabelAtom;\nexport const labelProperty = internal.getLabelProperty;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,SAAS;AAEtB,IAAa,iBAAiB;AAO9B,IAAa,OAAO;AAEpB,IAAa,aAAa;;;;;;;;;;;;;;;;AA4C1B,IAAa,UAAiC,OAAO,eAAe,OAAO,OAAO,EAAE,IAAI,OAAO,OAAO,CAAC,GAAG,CACxG,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAC7C,CAAC;;;;;AA8BD,IAAa,WAAiD;;;;;;;;;;;;;;AAe9D,IAAa,eAGP,GAAG,SAAoD;CAC3D,IAAI,KAAK,WAAW,GAClB,QAAQ,WAAoB,aAAsB,KAAK,IAAI,MAAM;CAEnE,OAAO,aAAsB,KAAK,IAAI,KAAK,EAAE;AAC/C;;;;;AAMA,IAAa,cAAc,UAAsC;CAC/D,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAET,OAAQ,MAAc,oBAAoB,KAAA;AAC5C;AAGA,IAAa,UAAU;;;;AAKvB,IAAa,OAAsB;;;;;;;AAwBnC,IAAM,gBAAgB,WAA6B,mBAA4B,MAAM,MAAA,WAA0B;;;;;;;;;AAiB/G,IAAa,UAAU,QAAkB,YACvC,aAAa,MAAM,IAAI,SAAY,QAA0B,OAAO,IAAI,OAAgB,QAAmB,OAAO;;;;;;AAOpH,IAAa,cAAc,WACzB,aAAa,MAAM,IAAI,SAAY,IAAS,IAAI,aAAoB,MAAiB;;;;;;;;;;;;AAavF,IAAa,WAAW,WACtB,aAAa,MAAM,IAAI,OAAa,UAAiB,MAAM;;;;;;AAO7D,IAAa,eAAe,WAC1B,aAAa,MAAM,IAAI,cAAiB,MAAwB,IAAI,cAAqB,MAAiB;;;;AAK5G,IAAa,eAAe,WAAgD,cAAqB,MAAM;AAUvG,SAAgB,QAAQ,QAA4F;CAClH,OAAO,eAAwB,MAAM;AACvC;;;;AAKA,IAAa,WAAW,QAA4B,WAAiC,UAAiB,QAAQ,MAAM;;;;AAKpH,IAAa,aAAa,WAAwC,YAAmB,MAAM;;;;;;;AAQ3F,IAAa,YAAY,QAA4B,YACnD,WAAkB,QAAQ,OAAO;;;;;AAMnC,IAAa,YAAY,QAA0B,UAAwB,WAAkB,QAAQ,KAAK;;;;AAK1G,IAAa,kBAAkB,WAAmD,iBAAwB,MAAM;;;;;;AAOhH,IAAa,WAAW,WAAoE,UAAiB,MAAM;;;;AAKnH,IAAa,UAAU,WAAqC,aAAsB,MAAM;;;;;AAMxF,IAAa,aAAa,QAAiB,aAAuC;CAChF,OAAO,YAAmB,QAAQ,QAAQ;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa,UAA6B,QAAW,aAA+C;CAClG,OAAgB,QAAQ,QAAQ;AAClC;;;;;AAMA,IAAa,UAAU,QAA0B,QAAgC,SAAgB,QAAQ,GAAG;;;;;AAM5G,IAAa,aAAa,QAA0B,QAAgC,YAAmB,QAAQ,GAAG;AAMlH,IAAa,OAAO;AACpB,IAAa,YAAY;AACzB,IAAa,gBAAgB"}
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
2
  import { BaseError } from "@dxos/errors";
3
- //#region src/Err.ts
4
- var Err_exports = /* @__PURE__ */ __exportAll({
3
+ //#region src/Error.ts
4
+ var Error_exports = /* @__PURE__ */ __exportAll({
5
5
  BlobNotAvailableError: () => BlobNotAvailableError,
6
6
  BlobTooLargeError: () => BlobTooLargeError,
7
7
  BlobWriteError: () => BlobWriteError,
@@ -100,6 +100,6 @@ var GetReactiveError = class extends BaseError.extend("GetReactiveError", "Faile
100
100
  }
101
101
  };
102
102
  //#endregion
103
- export { BlobNotAvailableError, BlobTooLargeError, BlobWriteError, EntityNotFoundError, GetReactiveError, SchemaNotFoundError, TextEditNotFoundError, TextNotSupportedError, Err_exports as t };
103
+ export { BlobNotAvailableError, BlobTooLargeError, BlobWriteError, EntityNotFoundError, GetReactiveError, SchemaNotFoundError, TextEditNotFoundError, TextNotSupportedError, Error_exports as t };
104
104
 
105
- //# sourceMappingURL=Err.mjs.map
105
+ //# sourceMappingURL=Error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Error.mjs","names":[],"sources":["../../src/Error.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { type URI } from '@dxos/keys';\n\nexport class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {\n constructor(schema: string, options?: BaseErrorOptions) {\n super({ context: { schema }, ...options });\n }\n}\n\nexport class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {\n constructor(uri: URI.URI, options?: BaseErrorOptions) {\n super({ context: { uri }, ...options });\n }\n}\n\n/**\n * Thrown when a `Text` mutation is attempted on an object whose reactive handler does not implement\n * string CRDT editing (e.g. a snapshot or a non-reactive value).\n */\nexport class TextNotSupportedError extends BaseError.extend(\n 'TextNotSupportedError',\n 'Text operation is not supported for this object',\n) {\n constructor(operation: string, options?: BaseErrorOptions) {\n super({ context: { operation }, ...options });\n }\n}\n\n/**\n * Thrown by `Text.apply` when a non-`replaceAll` edit's `oldString` is not found in the text.\n */\nexport class TextEditNotFoundError extends BaseError.extend('TextEditNotFoundError', 'Edit text not found') {\n constructor(oldString: string, options?: BaseErrorOptions) {\n super({ context: { oldString }, ...options });\n }\n}\n\n/**\n * Thrown when a blob's bytes exceed the size limit of the storage backend writing them (inline\n * storage's fixed cap, or a registered backend's own `maxSize`).\n */\nexport class BlobTooLargeError extends BaseError.extend('BlobTooLargeError', 'Blob is too large for its backend') {\n constructor(context: { size: number; limit: number }, options?: BaseErrorOptions) {\n super({ context, ...options });\n }\n}\n\n/**\n * Reason why a blob's bytes could not be read.\n * - `offline`: The backend's transport failed (e.g. network unavailable).\n * - `not-found`: The backend could not locate the bytes for the given URI.\n * - `backend-not-registered`: No backend is registered for the URI's scheme.\n */\nexport type BlobNotAvailableReason = 'offline' | 'not-found' | 'backend-not-registered';\n\n/**\n * Thrown when a blob's bytes cannot be read from its backend.\n */\nexport class BlobNotAvailableError extends BaseError.extend('BlobNotAvailableError', 'Blob is not available') {\n constructor(context: { backend: string; key: string; reason: BlobNotAvailableReason }, options?: BaseErrorOptions) {\n super({ context, ...options });\n }\n}\n\n/**\n * Thrown when a blob's bytes fail to upload to its backend.\n */\nexport class BlobWriteError extends BaseError.extend('BlobWriteError', 'Failed to write blob') {\n constructor(context: { backend: string }, options?: BaseErrorOptions) {\n super({ context, ...options });\n }\n}\n\n/**\n * Reason why getting a reactive object from a snapshot failed.\n * - `no-database`: The snapshot is not associated with a database.\n * - `object-not-found`: The object was removed or does not exist in the database.\n */\nexport type GetReactiveErrorReason = 'no-database' | 'object-not-found';\n\n/**\n * Error thrown when a reactive object cannot be resolved from a snapshot.\n * Extends `BaseError` with a `reason` and optional `snapshotId` in its context.\n */\nexport class GetReactiveError extends BaseError.extend(\n 'GetReactiveError',\n 'Failed to get reactive object from snapshot',\n) {\n constructor(options: { reason: GetReactiveErrorReason; snapshotId?: string } & BaseErrorOptions) {\n super({ context: { reason: options.reason, snapshotId: options.snapshotId }, ...options });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AASA,IAAa,sBAAb,cAAyC,UAAU,OAAO,uBAAuB,kBAAkB,CAAC,CAAC;CACnG,YAAY,QAAgB,SAA4B;EACtD,MAAM;GAAE,SAAS,EAAE,OAAO;GAAG,GAAG;EAAQ,CAAC;CAC3C;AACF;AAEA,IAAa,sBAAb,cAAyC,UAAU,OAAO,uBAAuB,kBAAkB,CAAC,CAAC;CACnG,YAAY,KAAc,SAA4B;EACpD,MAAM;GAAE,SAAS,EAAE,IAAI;GAAG,GAAG;EAAQ,CAAC;CACxC;AACF;;;;;AAMA,IAAa,wBAAb,cAA2C,UAAU,OACnD,yBACA,iDACF,CAAC,CAAC;CACA,YAAY,WAAmB,SAA4B;EACzD,MAAM;GAAE,SAAS,EAAE,UAAU;GAAG,GAAG;EAAQ,CAAC;CAC9C;AACF;;;;AAKA,IAAa,wBAAb,cAA2C,UAAU,OAAO,yBAAyB,qBAAqB,CAAC,CAAC;CAC1G,YAAY,WAAmB,SAA4B;EACzD,MAAM;GAAE,SAAS,EAAE,UAAU;GAAG,GAAG;EAAQ,CAAC;CAC9C;AACF;;;;;AAMA,IAAa,oBAAb,cAAuC,UAAU,OAAO,qBAAqB,mCAAmC,CAAC,CAAC;CAChH,YAAY,SAA0C,SAA4B;EAChF,MAAM;GAAE;GAAS,GAAG;EAAQ,CAAC;CAC/B;AACF;;;;AAaA,IAAa,wBAAb,cAA2C,UAAU,OAAO,yBAAyB,uBAAuB,CAAC,CAAC;CAC5G,YAAY,SAA2E,SAA4B;EACjH,MAAM;GAAE;GAAS,GAAG;EAAQ,CAAC;CAC/B;AACF;;;;AAKA,IAAa,iBAAb,cAAoC,UAAU,OAAO,kBAAkB,sBAAsB,CAAC,CAAC;CAC7F,YAAY,SAA8B,SAA4B;EACpE,MAAM;GAAE;GAAS,GAAG;EAAQ,CAAC;CAC/B;AACF;;;;;AAaA,IAAa,mBAAb,cAAsC,UAAU,OAC9C,oBACA,6CACF,CAAC,CAAC;CACA,YAAY,SAAqF;EAC/F,MAAM;GAAE,SAAS;IAAE,QAAQ,QAAQ;IAAQ,YAAY,QAAQ;GAAW;GAAG,GAAG;EAAQ,CAAC;CAC3F;AACF"}
package/dist/lib/Feed.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { c as getKeys, l as getMetaChecked, m as foreignKey, s as deleteKeys } from "./chunk-atom-snapshot.mjs";
3
- import { G as HiddenAnnotation, L as FormInputAnnotation, g as query$1, q as IconAnnotation, r as Service } from "./chunk-Database.mjs";
4
- import { h as change } from "./chunk-ref.mjs";
2
+ import { c as deleteKeys, h as foreignKey, l as getKeys, u as getMetaChecked } from "./chunk-atom-snapshot.mjs";
3
+ import { B as FormInputAnnotation, J as HiddenAnnotation, X as IconAnnotation, g as query$1, r as Service } from "./chunk-Database.mjs";
4
+ import { g as change } from "./chunk-ref.mjs";
5
+ import { d as make$1 } from "./chunk-Annotation.mjs";
5
6
  import { makeObject } from "./Type.mjs";
6
- import { ID, getURI, make as make$1 } from "./Obj.mjs";
7
+ import { ID, getURI, make as make$2 } from "./Obj.mjs";
7
8
  import { is, select } from "./Query.mjs";
8
9
  import { feed } from "./Scope.mjs";
9
10
  import { KEY_QUEUE_POSITION } from "@dxos/echo-protocol";
@@ -17,19 +18,20 @@ import * as Layer from "effect/Layer";
17
18
  //#region src/Feed.ts
18
19
  var Feed_exports = /* @__PURE__ */ __exportAll({
19
20
  ContextFeedService: () => ContextFeedService,
21
+ Cursor: () => Cursor,
22
+ CursorAnnotation: () => CursorAnnotation,
20
23
  Feed: () => Feed,
21
24
  PARENT_KEY: () => PARENT_KEY,
22
25
  POSITION_KEY: () => POSITION_KEY,
26
+ START: () => START,
23
27
  append: () => append,
24
- cursor: () => cursor,
28
+ getCursor: () => getCursor,
25
29
  getFeedUri: () => getFeedUri,
26
30
  getParent: () => getParent,
27
31
  getPosition: () => getPosition,
28
32
  getSyncState: () => getSyncState,
29
33
  history: () => history,
30
34
  make: () => make,
31
- next: () => next,
32
- nextOption: () => nextOption,
33
35
  query: () => query,
34
36
  remove: () => remove,
35
37
  setParent: () => setParent,
@@ -56,7 +58,7 @@ var Feed = class extends makeObject(DXN.make("org.dxos.type.feed", "0.1.0"))(Sch
56
58
  * - `data`: Data feed (default).
57
59
  * - `trace`: Trace feed.
58
60
  */
59
- namespace: Schema.optional(Schema.Literal("data", "trace")),
61
+ namespace: Schema.optional(Schema.Literals(["data", "trace"])),
60
62
  /**
61
63
  * Earliest item a pending rewind discards — set when a soft fork is decided but not yet expressed,
62
64
  * because the writer may be a different process than the one that decided it.
@@ -75,11 +77,40 @@ var Feed = class extends makeObject(DXN.make("org.dxos.type.feed", "0.1.0"))(Sch
75
77
  hue: "yellow"
76
78
  }))) {};
77
79
  /**
80
+ * Opaque position of a feed item — the insertion id the position authority assigned its block,
81
+ * as read from an item with {@link getCursor}. Ordering is the feed's append order; a reader
82
+ * resumes by passing the last cursor it processed to {@link query}.
83
+ */
84
+ var Cursor = Schema.String.pipe(Schema.brand("@dxos/echo/Feed/Cursor"));
85
+ /**
86
+ * Annotation holding a reader's position in a feed — the cursor it has consumed up to.
87
+ *
88
+ * An annotation rather than a `@meta` foreign key: a key identifies the same entity in another
89
+ * system, which a checkpoint is not.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * const cursor = Annotation.get(reader, Feed.CursorAnnotation).pipe(Option.getOrElse(() => Feed.START));
94
+ * Obj.update(reader, (reader) => Annotation.set(reader, Feed.CursorAnnotation, Feed.getCursor(item)!));
95
+ * ```
96
+ */
97
+ var CursorAnnotation = make$1({
98
+ id: "org.dxos.annotation.feed-cursor",
99
+ schema: Cursor
100
+ });
101
+ /**
102
+ * Sentinel cursor preceding every item — "read from the beginning".
103
+ *
104
+ * A sentinel rather than `undefined` so a stored checkpoint is always a `Cursor`: a reader that has
105
+ * processed nothing yet holds this, and the same code path resumes it as resumes a live cursor.
106
+ */
107
+ var START = Cursor.make("");
108
+ /**
78
109
  * Effect service tag for injecting a Feed into effect operations.
79
110
  * Used to provide a specific feed to operations that operate on it without threading
80
111
  * the feed as an explicit parameter through every call site.
81
112
  */
82
- var ContextFeedService = class ContextFeedService extends Context.Tag("@dxos/echo/Feed/ContextFeedService")() {
113
+ var ContextFeedService = class ContextFeedService extends Context.Service()("@dxos/echo/Feed/ContextFeedService") {
83
114
  static layer = (feed) => Layer.succeed(ContextFeedService, { feed });
84
115
  };
85
116
  /**
@@ -90,7 +121,7 @@ var ContextFeedService = class ContextFeedService extends Context.Tag("@dxos/ech
90
121
  * const feed = Feed.make({ name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' });
91
122
  * ```
92
123
  */
93
- var make = (props = {}) => make$1(Feed, props);
124
+ var make = (props = {}) => make$2(Feed, props);
94
125
  /**
95
126
  * Returns the feed object's EID when the feed is stored in a space.
96
127
  *
@@ -172,6 +203,14 @@ var getPosition = (item) => {
172
203
  return Number.isNaN(position) ? Number.POSITIVE_INFINITY : position;
173
204
  };
174
205
  /**
206
+ * The item's {@link Cursor}, or `undefined` when it has none — a block written locally and not yet
207
+ * acknowledged by the position authority. Pass it to {@link query} to resume after this item.
208
+ */
209
+ var getCursor = (item) => {
210
+ const key = getKeys(item, KEY_QUEUE_POSITION).at(0)?.id;
211
+ return key !== void 0 ? Cursor.make(key) : void 0;
212
+ };
213
+ /**
175
214
  * Returns an item's explicit lineage parent, or `undefined` when it continues from the item that
176
215
  * precedes it in append order (the default for every feed).
177
216
  *
@@ -269,6 +308,9 @@ var history = (items, options) => {
269
308
  *
270
309
  * // Data-last (curried) form composes with `pipe`:
271
310
  * const objects = yield* pipe(feed, Feed.query(Filter.type(Person))).run;
311
+ *
312
+ * // Resume after a cursor, reading a bounded page of what is new:
313
+ * const objects = yield* Feed.query(feed, Query.select(Filter.feedCursor(cursor)).limit(10)).run;
272
314
  * ```
273
315
  */
274
316
  var query = Function.dual(2, (feed$1, queryOrFilter) => {
@@ -276,11 +318,12 @@ var query = Function.dual(2, (feed$1, queryOrFilter) => {
276
318
  invariant(feedUri, "Feed must be stored in the database before accessing its contents", {
277
319
  "~LogMeta": "~LogMeta",
278
320
  F: __dxlog_file,
279
- L: 432,
321
+ L: 468,
280
322
  S: void 0,
281
323
  A: ["feedUri", "'Feed must be stored in the database before accessing its contents'"]
282
324
  });
283
- return query$1((is(queryOrFilter) ? queryOrFilter : select(queryOrFilter)).from(feed(feedUri.toString())));
325
+ const query = is(queryOrFilter) ? queryOrFilter : select(queryOrFilter);
326
+ return query$1(query.from(feed(feedUri.toString())));
284
327
  });
285
328
  /**
286
329
  * Syncs the feed with the server.
@@ -302,27 +345,6 @@ var sync = (feed, options) => Service.pipe(Effect.flatMap(({ db }) => Effect.pro
302
345
  */
303
346
  var getSyncState = (feed) => Service.pipe(Effect.flatMap(({ db }) => Effect.promise(() => db.getFeedSyncState(feed)))).pipe(Effect.withSpan("Feed.getSyncState"));
304
347
  /**
305
- * Creates a cursor for iterating over feed items.
306
- * Currently stubbed — cursor operations are not yet implemented.
307
- *
308
- * @example
309
- * ```ts
310
- * const cursor = yield* Feed.cursor<Person>(feed);
311
- * const item = yield* Feed.next(cursor);
312
- * ```
313
- */
314
- var cursor = (_feed) => Effect.succeed({ _tag: "Cursor" });
315
- /**
316
- * Returns the next item from a feed cursor.
317
- * Currently stubbed — cursor operations are not yet implemented.
318
- */
319
- var next = (_cursor) => Effect.die("Feed.next is not yet implemented");
320
- /**
321
- * Returns the next item from a feed cursor as an Option.
322
- * Currently stubbed — cursor operations are not yet implemented.
323
- */
324
- var nextOption = (_cursor) => Effect.die("Feed.nextOption is not yet implemented");
325
- /**
326
348
  * Sets the local retention policy for a feed.
327
349
  * Currently stubbed — feeds do not yet support retention.
328
350
  *
@@ -333,6 +355,6 @@ var nextOption = (_cursor) => Effect.die("Feed.nextOption is not yet implemented
333
355
  */
334
356
  var setRetention = (_feed, _options) => Effect.void;
335
357
  //#endregion
336
- export { ContextFeedService, Feed, PARENT_KEY, POSITION_KEY, append, cursor, getFeedUri, getParent, getPosition, getSyncState, history, make, next, nextOption, query, remove, setParent, setRetention, sync, Feed_exports as t };
358
+ export { ContextFeedService, Cursor, CursorAnnotation, Feed, PARENT_KEY, POSITION_KEY, START, append, getCursor, getFeedUri, getParent, getPosition, getSyncState, history, make, query, remove, setParent, setRetention, sync, Feed_exports as t };
337
359
 
338
360
  //# sourceMappingURL=Feed.mjs.map