@dxos/echo 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/dist/lib/Annotation.mjs +3 -0
  2. package/dist/lib/Blob.mjs +160 -0
  3. package/dist/lib/Blob.mjs.map +1 -0
  4. package/dist/lib/Database.mjs +2 -0
  5. package/dist/lib/Entity.mjs +231 -0
  6. package/dist/lib/Entity.mjs.map +1 -0
  7. package/dist/lib/Err.mjs +105 -0
  8. package/dist/lib/Err.mjs.map +1 -0
  9. package/dist/lib/Feed.mjs +338 -0
  10. package/dist/lib/Feed.mjs.map +1 -0
  11. package/dist/lib/Filter.mjs +380 -0
  12. package/dist/lib/Filter.mjs.map +1 -0
  13. package/dist/lib/Format.mjs +47 -0
  14. package/dist/lib/Format.mjs.map +1 -0
  15. package/dist/lib/JsonSchema.mjs +21 -0
  16. package/dist/lib/JsonSchema.mjs.map +1 -0
  17. package/dist/lib/Key.mjs +15 -0
  18. package/dist/lib/Key.mjs.map +1 -0
  19. package/dist/lib/Migration.mjs +38 -0
  20. package/dist/lib/Migration.mjs.map +1 -0
  21. package/dist/lib/Obj.mjs +660 -0
  22. package/dist/lib/Obj.mjs.map +1 -0
  23. package/dist/lib/Order.mjs +65 -0
  24. package/dist/lib/Order.mjs.map +1 -0
  25. package/dist/lib/Query.mjs +336 -0
  26. package/dist/lib/Query.mjs.map +1 -0
  27. package/dist/lib/QueryResult.mjs +7 -0
  28. package/dist/lib/QueryResult.mjs.map +1 -0
  29. package/dist/lib/Ref.mjs +44 -0
  30. package/dist/lib/Ref.mjs.map +1 -0
  31. package/dist/lib/Registry.mjs +35 -0
  32. package/dist/lib/Registry.mjs.map +1 -0
  33. package/dist/lib/Relation.mjs +397 -0
  34. package/dist/lib/Relation.mjs.map +1 -0
  35. package/dist/lib/Scope.mjs +51 -0
  36. package/dist/lib/Scope.mjs.map +1 -0
  37. package/dist/lib/Tag.mjs +70 -0
  38. package/dist/lib/Tag.mjs.map +1 -0
  39. package/dist/lib/Text.mjs +82 -0
  40. package/dist/lib/Text.mjs.map +1 -0
  41. package/dist/lib/Type.mjs +371 -0
  42. package/dist/lib/Type.mjs.map +1 -0
  43. package/dist/lib/chunk-Annotation.mjs +221 -0
  44. package/dist/lib/chunk-Annotation.mjs.map +1 -0
  45. package/dist/lib/chunk-Database.mjs +918 -0
  46. package/dist/lib/chunk-Database.mjs.map +1 -0
  47. package/dist/lib/chunk-atom-snapshot.mjs +249 -0
  48. package/dist/lib/chunk-atom-snapshot.mjs.map +1 -0
  49. package/dist/lib/chunk-internal.mjs +2775 -0
  50. package/dist/lib/chunk-internal.mjs.map +1 -0
  51. package/dist/lib/chunk-json-schema.mjs +660 -0
  52. package/dist/lib/chunk-json-schema.mjs.map +1 -0
  53. package/dist/lib/chunk-number.mjs +164 -0
  54. package/dist/lib/chunk-number.mjs.map +1 -0
  55. package/dist/lib/chunk-ref-array.mjs +31 -0
  56. package/dist/lib/chunk-ref-array.mjs.map +1 -0
  57. package/dist/lib/chunk-ref.mjs +590 -0
  58. package/dist/lib/chunk-ref.mjs.map +1 -0
  59. package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
  60. package/dist/lib/chunk-select.mjs +186 -0
  61. package/dist/lib/chunk-select.mjs.map +1 -0
  62. package/dist/lib/chunk-src.mjs +234 -0
  63. package/dist/lib/chunk-src.mjs.map +1 -0
  64. package/dist/lib/chunk-util.mjs +140 -0
  65. package/dist/lib/chunk-util.mjs.map +1 -0
  66. package/dist/lib/index.mjs +24 -0
  67. package/dist/lib/internal.mjs +10 -0
  68. package/dist/lib/testing.mjs +346 -0
  69. package/dist/lib/testing.mjs.map +1 -0
  70. package/dist/types/src/Aggregate.d.ts +86 -0
  71. package/dist/types/src/Aggregate.d.ts.map +1 -0
  72. package/dist/types/src/Blob.d.ts +153 -0
  73. package/dist/types/src/Blob.d.ts.map +1 -0
  74. package/dist/types/src/Blob.test.d.ts +2 -0
  75. package/dist/types/src/Blob.test.d.ts.map +1 -0
  76. package/dist/types/src/Database.d.ts +153 -4
  77. package/dist/types/src/Database.d.ts.map +1 -1
  78. package/dist/types/src/Err.d.ts +116 -0
  79. package/dist/types/src/Err.d.ts.map +1 -1
  80. package/dist/types/src/Feed.d.ts +116 -28
  81. package/dist/types/src/Feed.d.ts.map +1 -1
  82. package/dist/types/src/Feed.test.d.ts +2 -0
  83. package/dist/types/src/Feed.test.d.ts.map +1 -0
  84. package/dist/types/src/Filter.d.ts +14 -6
  85. package/dist/types/src/Filter.d.ts.map +1 -1
  86. package/dist/types/src/Hypergraph.d.ts +18 -0
  87. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  88. package/dist/types/src/Json.d.ts.map +1 -1
  89. package/dist/types/src/Obj.d.ts +14 -1
  90. package/dist/types/src/Obj.d.ts.map +1 -1
  91. package/dist/types/src/Order.d.ts +9 -3
  92. package/dist/types/src/Order.d.ts.map +1 -1
  93. package/dist/types/src/Query.d.ts +107 -26
  94. package/dist/types/src/Query.d.ts.map +1 -1
  95. package/dist/types/src/Relation.d.ts +6 -0
  96. package/dist/types/src/Relation.d.ts.map +1 -1
  97. package/dist/types/src/Type.d.ts.map +1 -1
  98. package/dist/types/src/View.d.ts +1 -1
  99. package/dist/types/src/index.d.ts +2 -0
  100. package/dist/types/src/index.d.ts.map +1 -1
  101. package/dist/types/src/internal/Entity/api.d.ts +6 -0
  102. package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
  103. package/dist/types/src/internal/Entity/model.d.ts +3 -2
  104. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  105. package/dist/types/src/internal/Filter/match.d.ts.map +1 -1
  106. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +34 -8
  107. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
  108. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  109. package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
  110. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  111. package/dist/types/src/internal/Query/pretty.d.ts.map +1 -1
  112. package/dist/types/src/internal/Query/query-result-effect.d.ts.map +1 -1
  113. package/dist/types/src/internal/common/proxy/make-object.d.ts +13 -0
  114. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  115. package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
  116. package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -1
  117. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +12 -0
  118. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  119. package/dist/types/src/internal/common/types/index.d.ts +1 -0
  120. package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
  121. package/dist/types/src/internal/common/types/model-symbols.d.ts +5 -0
  122. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
  123. package/dist/types/src/internal/common/types/projection.d.ts +32 -0
  124. package/dist/types/src/internal/common/types/projection.d.ts.map +1 -0
  125. package/dist/types/tsconfig.tsbuildinfo +1 -1
  126. package/package.json +40 -35
  127. package/src/Aggregate.ts +105 -0
  128. package/src/Blob.test.ts +45 -0
  129. package/src/Blob.ts +205 -0
  130. package/src/Database.ts +207 -17
  131. package/src/Err.ts +36 -0
  132. package/src/Feed.test.ts +188 -0
  133. package/src/Feed.ts +238 -62
  134. package/src/Filter.ts +28 -10
  135. package/src/Hypergraph.ts +18 -0
  136. package/src/Json.ts +1 -0
  137. package/src/Obj.test.ts +2 -2
  138. package/src/Obj.ts +21 -1
  139. package/src/Order.ts +16 -9
  140. package/src/Query.test.ts +319 -2
  141. package/src/Query.ts +165 -51
  142. package/src/Relation.ts +14 -0
  143. package/src/Type.ts +5 -6
  144. package/src/index.ts +2 -0
  145. package/src/internal/Entity/api.ts +11 -1
  146. package/src/internal/Entity/model.ts +3 -0
  147. package/src/internal/Filter/match.ts +30 -1
  148. package/src/internal/JsonSchema/json-schema-type.ts +14 -2
  149. package/src/internal/JsonSchema/json-schema.test.ts +28 -1
  150. package/src/internal/JsonSchema/json-schema.ts +33 -6
  151. package/src/internal/Obj/atoms.ts +4 -2
  152. package/src/internal/Obj/json-serializer.test.ts +162 -2
  153. package/src/internal/Obj/json-serializer.ts +6 -0
  154. package/src/internal/Query/pretty.ts +19 -1
  155. package/src/internal/Query/query-result-effect.ts +2 -4
  156. package/src/internal/Ref/atoms.ts +1 -1
  157. package/src/internal/common/proxy/change-context.ts +1 -1
  158. package/src/internal/common/proxy/make-object.ts +42 -3
  159. package/src/internal/common/proxy/reactive.ts +5 -0
  160. package/src/internal/common/proxy/symbols.ts +1 -0
  161. package/src/internal/common/proxy/typed-handler.ts +71 -29
  162. package/src/internal/common/types/index.ts +1 -0
  163. package/src/internal/common/types/model-symbols.ts +6 -0
  164. package/src/internal/common/types/projection.ts +45 -0
  165. package/src/testing/test-data.ts +14 -14
  166. package/dist/lib/neutral/Annotation.mjs +0 -90
  167. package/dist/lib/neutral/Annotation.mjs.map +0 -7
  168. package/dist/lib/neutral/Database.mjs +0 -42
  169. package/dist/lib/neutral/Database.mjs.map +0 -7
  170. package/dist/lib/neutral/Entity.mjs +0 -76
  171. package/dist/lib/neutral/Entity.mjs.map +0 -7
  172. package/dist/lib/neutral/Err.mjs +0 -16
  173. package/dist/lib/neutral/Err.mjs.map +0 -7
  174. package/dist/lib/neutral/Feed.mjs +0 -50
  175. package/dist/lib/neutral/Feed.mjs.map +0 -7
  176. package/dist/lib/neutral/Filter.mjs +0 -72
  177. package/dist/lib/neutral/Filter.mjs.map +0 -7
  178. package/dist/lib/neutral/Format.mjs +0 -82
  179. package/dist/lib/neutral/Format.mjs.map +0 -7
  180. package/dist/lib/neutral/JsonSchema.mjs +0 -18
  181. package/dist/lib/neutral/JsonSchema.mjs.map +0 -7
  182. package/dist/lib/neutral/Key.mjs +0 -16
  183. package/dist/lib/neutral/Key.mjs.map +0 -7
  184. package/dist/lib/neutral/Migration.mjs +0 -18
  185. package/dist/lib/neutral/Migration.mjs.map +0 -7
  186. package/dist/lib/neutral/Obj.mjs +0 -128
  187. package/dist/lib/neutral/Obj.mjs.map +0 -7
  188. package/dist/lib/neutral/Order.mjs +0 -16
  189. package/dist/lib/neutral/Order.mjs.map +0 -7
  190. package/dist/lib/neutral/Query.mjs +0 -38
  191. package/dist/lib/neutral/Query.mjs.map +0 -7
  192. package/dist/lib/neutral/QueryResult.mjs +0 -2
  193. package/dist/lib/neutral/QueryResult.mjs.map +0 -7
  194. package/dist/lib/neutral/Ref.mjs +0 -25
  195. package/dist/lib/neutral/Ref.mjs.map +0 -7
  196. package/dist/lib/neutral/Registry.mjs +0 -14
  197. package/dist/lib/neutral/Registry.mjs.map +0 -7
  198. package/dist/lib/neutral/Relation.mjs +0 -97
  199. package/dist/lib/neutral/Relation.mjs.map +0 -7
  200. package/dist/lib/neutral/Scope.mjs +0 -12
  201. package/dist/lib/neutral/Scope.mjs.map +0 -7
  202. package/dist/lib/neutral/Tag.mjs +0 -32
  203. package/dist/lib/neutral/Tag.mjs.map +0 -7
  204. package/dist/lib/neutral/Text.mjs +0 -25
  205. package/dist/lib/neutral/Text.mjs.map +0 -7
  206. package/dist/lib/neutral/Type.mjs +0 -65
  207. package/dist/lib/neutral/Type.mjs.map +0 -7
  208. package/dist/lib/neutral/chunk-2HKGAQM4.mjs +0 -1394
  209. package/dist/lib/neutral/chunk-2HKGAQM4.mjs.map +0 -7
  210. package/dist/lib/neutral/chunk-2ZHECXUR.mjs +0 -95
  211. package/dist/lib/neutral/chunk-2ZHECXUR.mjs.map +0 -7
  212. package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs +0 -336
  213. package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs.map +0 -7
  214. package/dist/lib/neutral/chunk-3TN2VMI4.mjs +0 -714
  215. package/dist/lib/neutral/chunk-3TN2VMI4.mjs.map +0 -7
  216. package/dist/lib/neutral/chunk-42L4HJ3Z.mjs +0 -104
  217. package/dist/lib/neutral/chunk-42L4HJ3Z.mjs.map +0 -7
  218. package/dist/lib/neutral/chunk-4A2NWKRJ.mjs +0 -747
  219. package/dist/lib/neutral/chunk-4A2NWKRJ.mjs.map +0 -7
  220. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +0 -25
  221. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +0 -7
  222. package/dist/lib/neutral/chunk-ACFAOTKJ.mjs +0 -1531
  223. package/dist/lib/neutral/chunk-ACFAOTKJ.mjs.map +0 -7
  224. package/dist/lib/neutral/chunk-BEFR7LEA.mjs +0 -170
  225. package/dist/lib/neutral/chunk-BEFR7LEA.mjs.map +0 -7
  226. package/dist/lib/neutral/chunk-BXIKXT7Q.mjs +0 -89
  227. package/dist/lib/neutral/chunk-BXIKXT7Q.mjs.map +0 -7
  228. package/dist/lib/neutral/chunk-C57XMMBY.mjs +0 -206
  229. package/dist/lib/neutral/chunk-C57XMMBY.mjs.map +0 -7
  230. package/dist/lib/neutral/chunk-C62JYFAD.mjs +0 -183
  231. package/dist/lib/neutral/chunk-C62JYFAD.mjs.map +0 -7
  232. package/dist/lib/neutral/chunk-FSGX2R62.mjs +0 -48
  233. package/dist/lib/neutral/chunk-FSGX2R62.mjs.map +0 -7
  234. package/dist/lib/neutral/chunk-HBXT3GSB.mjs +0 -459
  235. package/dist/lib/neutral/chunk-HBXT3GSB.mjs.map +0 -7
  236. package/dist/lib/neutral/chunk-IQR45HAD.mjs +0 -31
  237. package/dist/lib/neutral/chunk-IQR45HAD.mjs.map +0 -7
  238. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
  239. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
  240. package/dist/lib/neutral/chunk-KCBW4BR6.mjs +0 -424
  241. package/dist/lib/neutral/chunk-KCBW4BR6.mjs.map +0 -7
  242. package/dist/lib/neutral/chunk-L3E5IXAE.mjs +0 -575
  243. package/dist/lib/neutral/chunk-L3E5IXAE.mjs.map +0 -7
  244. package/dist/lib/neutral/chunk-PRC4FEKJ.mjs +0 -56
  245. package/dist/lib/neutral/chunk-PRC4FEKJ.mjs.map +0 -7
  246. package/dist/lib/neutral/chunk-SCT6FFCR.mjs +0 -351
  247. package/dist/lib/neutral/chunk-SCT6FFCR.mjs.map +0 -7
  248. package/dist/lib/neutral/chunk-TOCVVFK2.mjs +0 -75
  249. package/dist/lib/neutral/chunk-TOCVVFK2.mjs.map +0 -7
  250. package/dist/lib/neutral/chunk-U53LSQQA.mjs +0 -41
  251. package/dist/lib/neutral/chunk-U53LSQQA.mjs.map +0 -7
  252. package/dist/lib/neutral/chunk-UGFFV2FR.mjs +0 -27
  253. package/dist/lib/neutral/chunk-UGFFV2FR.mjs.map +0 -7
  254. package/dist/lib/neutral/chunk-UWLP4RFM.mjs +0 -7
  255. package/dist/lib/neutral/chunk-UWLP4RFM.mjs.map +0 -7
  256. package/dist/lib/neutral/chunk-UZHCQ6NI.mjs +0 -283
  257. package/dist/lib/neutral/chunk-UZHCQ6NI.mjs.map +0 -7
  258. package/dist/lib/neutral/chunk-WISOH2XH.mjs +0 -36
  259. package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +0 -7
  260. package/dist/lib/neutral/chunk-WKIT2YY5.mjs +0 -34
  261. package/dist/lib/neutral/chunk-WKIT2YY5.mjs.map +0 -7
  262. package/dist/lib/neutral/chunk-XB6ISRAO.mjs +0 -271
  263. package/dist/lib/neutral/chunk-XB6ISRAO.mjs.map +0 -7
  264. package/dist/lib/neutral/chunk-XXL42WCB.mjs +0 -84
  265. package/dist/lib/neutral/chunk-XXL42WCB.mjs.map +0 -7
  266. package/dist/lib/neutral/chunk-XXWK4J53.mjs +0 -117
  267. package/dist/lib/neutral/chunk-XXWK4J53.mjs.map +0 -7
  268. package/dist/lib/neutral/index.mjs +0 -115
  269. package/dist/lib/neutral/index.mjs.map +0 -7
  270. package/dist/lib/neutral/internal/index.mjs +0 -581
  271. package/dist/lib/neutral/internal/index.mjs.map +0 -7
  272. package/dist/lib/neutral/meta.json +0 -1
  273. package/dist/lib/neutral/testing/index.mjs +0 -477
  274. package/dist/lib/neutral/testing/index.mjs.map +0 -7
@@ -0,0 +1,140 @@
1
+ import { DXN } from "@dxos/keys";
2
+ import * as Schema from "effect/Schema";
3
+ import * as SchemaAST from "effect/SchemaAST";
4
+ import { assertArgument } from "@dxos/invariant";
5
+ //#region src/internal/common/types/entity.ts
6
+ /**
7
+ * String key used to identify the kind of an entity instance (object or relation).
8
+ */
9
+ var KindId = "~@dxos/echo/Kind";
10
+ /**
11
+ * String key used to identify the kind of a schema (object schema or relation schema).
12
+ * Parallels KindId which identifies instance kinds.
13
+ */
14
+ var SchemaKindId = "~@dxos/echo/SchemaKind";
15
+ /**
16
+ * String key used to brand snapshot types.
17
+ * Snapshots have SnapshotKindId instead of KindId, making them
18
+ * distinguishable from reactive objects at the type level.
19
+ */
20
+ var SnapshotKindId = "~@dxos/echo/SnapshotKind";
21
+ /**
22
+ * Hidden slot on a static `Type.Type` entity that holds the source Effect
23
+ * Schema. `Type.getSchema(...)` reads this for static types; persisted types
24
+ * rebuild from `jsonSchema` instead. Stored as a string key for declaration
25
+ * portability (see KindId comment above).
26
+ */
27
+ var StaticTypeSchemaSlot = "~@dxos/echo/Type.StaticSchema";
28
+ /**
29
+ * Whether a value can carry an entity brand/slot. Class-declared types
30
+ * Class-declared types (`Type.makeObject`) are functions whose prototype chain reaches the entity,
31
+ * so brand/slot lookups must accept functions as well as plain objects.
32
+ */
33
+ var isBrandCarrier = (value) => value != null && (typeof value === "object" || typeof value === "function");
34
+ /**
35
+ * Read the hidden `StaticTypeSchemaSlot` off any value that may carry one.
36
+ * Returns `undefined` for raw schemas (no slot) and inputs that cannot carry a brand.
37
+ * Single point-of-cast for the slot lookup.
38
+ */
39
+ var getStaticTypeSchema = (value) => {
40
+ if (!isBrandCarrier(value)) return;
41
+ return value[StaticTypeSchemaSlot];
42
+ };
43
+ /**
44
+ * Read the `[SchemaKindId]` brand off a value. Returns `undefined` for raw
45
+ * schemas (which don't carry the brand on their static type) and inputs that
46
+ * cannot carry a brand. Single point-of-cast for the brand lookup.
47
+ */
48
+ var getSchemaKind = (value) => {
49
+ if (!isBrandCarrier(value)) return;
50
+ return value[SchemaKindId];
51
+ };
52
+ /**
53
+ * Read the `[KindId]` brand off a value. Returns `undefined` for raw schemas
54
+ * and inputs that cannot carry a brand. Companion to {@link getSchemaKind}.
55
+ */
56
+ var getEntityKindBrand = (value) => {
57
+ if (!isBrandCarrier(value)) return;
58
+ return value[KindId];
59
+ };
60
+ /**
61
+ * Phantom string key on `Type<A>` entities that carries the instance type `A`.
62
+ * Lets internal helpers (`makeObject`, `createObject`, etc.) pattern-match the
63
+ * instance type from an entity input without importing from the top-level
64
+ * `Type` module. Mirrors `Type.InstancePhantomId` (declared in `Type.ts`).
65
+ *
66
+ * Stored as a string key so declarations remain portable across packages
67
+ * (see KindId comment above).
68
+ */
69
+ var InstancePhantomId = "~@dxos/echo/Type.Instance";
70
+ /**
71
+ * Nominal brand carried by the well-known "any object" / "any relation"
72
+ * schemas (`Obj.Unknown`, `Relation.Unknown`). The brand lets `Ref.Ref`,
73
+ * `Filter.type`, and `Query.type` accept these schemas in addition to
74
+ * `Type.Type` entities, without opening the door to arbitrary raw schemas.
75
+ *
76
+ * Stored as a string key so declarations remain portable across packages
77
+ * (see KindId comment above).
78
+ */
79
+ var UnknownTypeSchemaBrandId = "~@dxos/echo/UnknownTypeSchemaBrand";
80
+ /**
81
+ * Kinds of entities stored in ECHO: objects, relations, and types.
82
+ */
83
+ var EntityKind = /* @__PURE__ */ function(EntityKind) {
84
+ EntityKind["Object"] = "object";
85
+ EntityKind["Relation"] = "relation";
86
+ EntityKind["Type"] = "type";
87
+ return EntityKind;
88
+ }({});
89
+ var EntityKindSchema = Schema.Enums(EntityKind);
90
+ /**
91
+ * Typename for generic object references (Type.Obj / Ref.Ref(Obj.Unknown)).
92
+ * Used when referencing any object without a specific schema.
93
+ */
94
+ var ANY_OBJECT_TYPENAME = "org.dxos.schema.anyObject";
95
+ /**
96
+ * Version for generic object references.
97
+ */
98
+ var ANY_OBJECT_VERSION = "0.0.0";
99
+ //#endregion
100
+ //#region src/internal/Annotation/util.ts
101
+ /**
102
+ * Note: only for system annotations.
103
+ */
104
+ var createAnnotationHelper = (id) => {
105
+ return {
106
+ get: (schema) => SchemaAST.getAnnotation(schema.ast, id),
107
+ getFromAst: (ast) => SchemaAST.getAnnotation(ast, id),
108
+ set: (value) => (schema) => schema.annotations({ [id]: value })
109
+ };
110
+ };
111
+ /**
112
+ * If property is optional returns the nested property, otherwise returns the property.
113
+ */
114
+ var unwrapOptional = (property) => {
115
+ if (!property.isOptional || !SchemaAST.isUnion(property.type)) return property;
116
+ return property.type.types[0];
117
+ };
118
+ /**
119
+ * @see JSONSchemaAnnotationId
120
+ * @returns JSON-schema annotation so that the schema can be serialized with correct parameters.
121
+ */
122
+ var makeTypeJsonSchemaAnnotation = (options) => {
123
+ assertArgument(!!options.relationSource === (options.kind === EntityKind.Relation), "relationSource");
124
+ assertArgument(!!options.relationTarget === (options.kind === EntityKind.Relation), "relationTarget");
125
+ const obj = {
126
+ $id: options.identifier ?? DXN.make(options.typename, options.version),
127
+ entityKind: options.kind,
128
+ version: options.version,
129
+ typename: options.typename
130
+ };
131
+ if (options.kind === EntityKind.Relation) {
132
+ obj.relationSource = { $ref: options.relationSource };
133
+ obj.relationTarget = { $ref: options.relationTarget };
134
+ }
135
+ return obj;
136
+ };
137
+ //#endregion
138
+ export { ANY_OBJECT_VERSION as a, InstancePhantomId as c, SnapshotKindId as d, StaticTypeSchemaSlot as f, getStaticTypeSchema as g, getSchemaKind as h, ANY_OBJECT_TYPENAME as i, KindId as l, getEntityKindBrand as m, makeTypeJsonSchemaAnnotation as n, EntityKind as o, UnknownTypeSchemaBrandId as p, unwrapOptional as r, EntityKindSchema as s, createAnnotationHelper as t, SchemaKindId as u };
139
+
140
+ //# sourceMappingURL=chunk-util.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-util.mjs","names":[],"sources":["../../src/internal/common/types/entity.ts","../../src/internal/Annotation/util.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\n// NOTE: String literals are used instead of unique symbols for both KindId and SchemaKindId.\n// Unique symbols cause TS4023 \"cannot be named\" errors when external packages\n// try to export types that reference this key (e.g., `export const Graph = ...`).\n// TypeScript cannot emit declaration files that reference unique symbols from\n// external modules. Using a string literal allows the type to be inlined in\n// declaration files, making the API portable across package boundaries.\n\n/**\n * String key used to identify the kind of an entity instance (object or relation).\n */\nexport const KindId = '~@dxos/echo/Kind' as const;\nexport type KindId = typeof KindId;\n\n/**\n * String key used to identify the kind of a schema (object schema or relation schema).\n * Parallels KindId which identifies instance kinds.\n */\nexport const SchemaKindId = '~@dxos/echo/SchemaKind' as const;\nexport type SchemaKindId = typeof SchemaKindId;\n\n/**\n * String key used to brand snapshot types.\n * Snapshots have SnapshotKindId instead of KindId, making them\n * distinguishable from reactive objects at the type level.\n */\nexport const SnapshotKindId = '~@dxos/echo/SnapshotKind' as const;\nexport type SnapshotKindId = typeof SnapshotKindId;\n\n/**\n * Hidden slot on a static `Type.Type` entity that holds the source Effect\n * Schema. `Type.getSchema(...)` reads this for static types; persisted types\n * rebuild from `jsonSchema` instead. Stored as a string key for declaration\n * portability (see KindId comment above).\n */\nexport const StaticTypeSchemaSlot = '~@dxos/echo/Type.StaticSchema' as const;\nexport type StaticTypeSchemaSlot = typeof StaticTypeSchemaSlot;\n\n/**\n * Whether a value can carry an entity brand/slot. Class-declared types\n * Class-declared types (`Type.makeObject`) are functions whose prototype chain reaches the entity,\n * so brand/slot lookups must accept functions as well as plain objects.\n */\nconst isBrandCarrier = (value: unknown): boolean =>\n value != null && (typeof value === 'object' || typeof value === 'function');\n\n/**\n * Read the hidden `StaticTypeSchemaSlot` off any value that may carry one.\n * Returns `undefined` for raw schemas (no slot) and inputs that cannot carry a brand.\n * Single point-of-cast for the slot lookup.\n */\nexport const getStaticTypeSchema = (value: unknown): Schema.Schema.AnyNoContext | undefined => {\n if (!isBrandCarrier(value)) {\n return undefined;\n }\n return (value as { [StaticTypeSchemaSlot]?: Schema.Schema.AnyNoContext })[StaticTypeSchemaSlot];\n};\n\n/**\n * Read the `[SchemaKindId]` brand off a value. Returns `undefined` for raw\n * schemas (which don't carry the brand on their static type) and inputs that\n * cannot carry a brand. Single point-of-cast for the brand lookup.\n */\nexport const getSchemaKind = (value: unknown): EntityKind | undefined => {\n if (!isBrandCarrier(value)) {\n return undefined;\n }\n return (value as { [SchemaKindId]?: EntityKind })[SchemaKindId];\n};\n\n/**\n * Read the `[KindId]` brand off a value. Returns `undefined` for raw schemas\n * and inputs that cannot carry a brand. Companion to {@link getSchemaKind}.\n */\nexport const getEntityKindBrand = (value: unknown): EntityKind | undefined => {\n if (!isBrandCarrier(value)) {\n return undefined;\n }\n return (value as { [KindId]?: EntityKind })[KindId];\n};\n\n/**\n * Phantom string key on `Type<A>` entities that carries the instance type `A`.\n * Lets internal helpers (`makeObject`, `createObject`, etc.) pattern-match the\n * instance type from an entity input without importing from the top-level\n * `Type` module. Mirrors `Type.InstancePhantomId` (declared in `Type.ts`).\n *\n * Stored as a string key so declarations remain portable across packages\n * (see KindId comment above).\n */\nexport const InstancePhantomId = '~@dxos/echo/Type.Instance' as const;\nexport type InstancePhantomId = typeof InstancePhantomId;\n\n/**\n * Nominal brand carried by the well-known \"any object\" / \"any relation\"\n * schemas (`Obj.Unknown`, `Relation.Unknown`). The brand lets `Ref.Ref`,\n * `Filter.type`, and `Query.type` accept these schemas in addition to\n * `Type.Type` entities, without opening the door to arbitrary raw schemas.\n *\n * Stored as a string key so declarations remain portable across packages\n * (see KindId comment above).\n */\nexport const UnknownTypeSchemaBrandId = '~@dxos/echo/UnknownTypeSchemaBrand' as const;\nexport type UnknownTypeSchemaBrandId = typeof UnknownTypeSchemaBrandId;\n\n/**\n * Schema-side companion to `Type.Type` entities for the \"any object\" /\n * \"any relation\" cases. Branded so `Ref.Ref` / `Filter.type` / `Query.type`\n * can pattern-match on it; arbitrary `Schema.Schema` values do not satisfy\n * this shape.\n */\nexport interface UnknownTypeSchema<A, K extends EntityKind> extends Schema.Schema<A, any, never> {\n readonly [UnknownTypeSchemaBrandId]: K;\n}\n\n/**\n * Kinds of entities stored in ECHO: objects, relations, and types.\n */\nexport enum EntityKind {\n Object = 'object',\n Relation = 'relation',\n Type = 'type',\n}\n\nexport const EntityKindSchema = Schema.Enums(EntityKind);\n\n/**\n * Typename for generic object references (Type.Obj / Ref.Ref(Obj.Unknown)).\n * Used when referencing any object without a specific schema.\n */\nexport const ANY_OBJECT_TYPENAME = 'org.dxos.schema.anyObject';\n\n/**\n * Version for generic object references.\n */\nexport const ANY_OBJECT_VERSION = '0.0.0';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN } from '@dxos/keys';\n\nimport { EntityKind } from '../common/types';\n\nexport interface AnnotationHelper<T> {\n /**\n * Get the annotation value from an Effect schema.\n *\n * Only accepts `Schema.Schema.Any` — to read an annotation off a `Type.Type`\n * entity, unwrap it first with `Type.getSchema(entity)`. This keeps the\n * annotation pipeline single-shaped and forces annotations to live on the\n * source schema, not on the post-construction Type entity.\n */\n get: (schema: Schema.Schema.Any) => Option.Option<T>;\n /**\n * Get the annotation value from the AST.\n */\n getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;\n /**\n * Set the annotation on an Effect schema.\n *\n * Only accepts `Schema.Schema.Any` — annotations must be applied to the\n * source schema BEFORE wrapping it with `Type.makeObject` / `Type.makeRelation`.\n * In a pipe, place every `Annotation.X.set(...)` before the `Type.make...` step.\n */\n set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;\n}\n\n/**\n * Note: only for system annotations.\n */\n// TODO(dmaretskyi): Rename to createSystemAnnotationHelper.\n// TODO(dmaretskyi): REconcile with Annotation.make.\nexport const createAnnotationHelper = <T>(id: symbol): AnnotationHelper<T> => {\n return {\n get: (schema) => SchemaAST.getAnnotation(schema.ast, id),\n getFromAst: (ast) => SchemaAST.getAnnotation(ast, id),\n set:\n (value) =>\n <S extends Schema.Schema.Any>(schema: S): S =>\n schema.annotations({ [id]: value }) as S,\n };\n};\n\n/**\n * If property is optional returns the nested property, otherwise returns the property.\n */\n// TODO(wittjosiah): Is there a way to do this as a generic?\nexport const unwrapOptional = (property: SchemaAST.PropertySignature) => {\n if (!property.isOptional || !SchemaAST.isUnion(property.type)) {\n return property;\n }\n\n return property.type.types[0];\n};\n\n/**\n * @see JSONSchemaAnnotationId\n * @returns JSON-schema annotation so that the schema can be serialized with correct parameters.\n */\n// TODO(burdon): Required type.\nexport const makeTypeJsonSchemaAnnotation = (options: {\n identifier?: string;\n kind: EntityKind;\n typename: string;\n version: string;\n relationSource?: string;\n relationTarget?: string;\n}) => {\n assertArgument(!!options.relationSource === (options.kind === EntityKind.Relation), 'relationSource');\n assertArgument(!!options.relationTarget === (options.kind === EntityKind.Relation), 'relationTarget');\n\n const obj: Record<string, unknown> = {\n $id: options.identifier ?? DXN.make(options.typename, options.version),\n entityKind: options.kind,\n version: options.version,\n typename: options.typename,\n };\n if (options.kind === EntityKind.Relation) {\n obj.relationSource = { $ref: options.relationSource };\n obj.relationTarget = { $ref: options.relationTarget };\n }\n\n return obj;\n};\n"],"mappings":";;;;;;;;AAgBA,IAAa,SAAS;;;;;AAOtB,IAAa,eAAe;;;;;;AAQ5B,IAAa,iBAAiB;;;;;;;AAS9B,IAAa,uBAAuB;;;;;;AAQpC,IAAM,kBAAkB,UACtB,SAAS,SAAS,OAAO,UAAU,YAAY,OAAO,UAAU;;;;;;AAOlE,IAAa,uBAAuB,UAA2D;CAC7F,IAAI,CAAC,eAAe,KAAK,GACvB;CAEF,OAAQ,MAAkE;AAC5E;;;;;;AAOA,IAAa,iBAAiB,UAA2C;CACvE,IAAI,CAAC,eAAe,KAA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@@ -0,0 +1,24 @@
1
+ import { a as Dataset_exports, c as Json_exports, i as URI, l as Hypergraph_exports, n as EID, o as View_exports, r as QueryAST, s as Collection_exports, t as DXN, u as Aggregate_exports } from "./chunk-src.mjs";
2
+ import { n as Database_exports } from "./chunk-Database.mjs";
3
+ import { t as Err_exports } from "./Err.mjs";
4
+ import { t as Annotation_exports } from "./chunk-Annotation.mjs";
5
+ import { t as Type_exports } from "./Type.mjs";
6
+ import { t as Entity_exports } from "./Entity.mjs";
7
+ import { t as Ref_exports } from "./Ref.mjs";
8
+ import { t as Obj_exports } from "./Obj.mjs";
9
+ import { t as Blob_exports } from "./Blob.mjs";
10
+ import { t as Filter_exports } from "./Filter.mjs";
11
+ import { t as Query_exports } from "./Query.mjs";
12
+ import { t as Scope_exports } from "./Scope.mjs";
13
+ import { t as Feed_exports } from "./Feed.mjs";
14
+ import { t as Format_exports } from "./Format.mjs";
15
+ import { t as JsonSchema_exports } from "./JsonSchema.mjs";
16
+ import { t as Key_exports } from "./Key.mjs";
17
+ import { t as Migration_exports } from "./Migration.mjs";
18
+ import { t as Order_exports } from "./Order.mjs";
19
+ import { t as QueryResult_exports } from "./QueryResult.mjs";
20
+ import { t as Registry_exports } from "./Registry.mjs";
21
+ import { t as Relation_exports } from "./Relation.mjs";
22
+ import { t as Tag_exports } from "./Tag.mjs";
23
+ import { t as Text_exports } from "./Text.mjs";
24
+ export { Aggregate_exports as Aggregate, Annotation_exports as Annotation, Blob_exports as Blob, Collection_exports as Collection, DXN, Database_exports as Database, Dataset_exports as Dataset, EID, Entity_exports as Entity, Err_exports as Err, Feed_exports as Feed, Filter_exports as Filter, Format_exports as Format, Hypergraph_exports as Hypergraph, Json_exports as Json, JsonSchema_exports as JsonSchema, Key_exports as Key, Migration_exports as Migration, Obj_exports as Obj, Order_exports as Order, Query_exports as Query, QueryAST, QueryResult_exports as QueryResult, Ref_exports as Ref, Registry_exports as Registry, Relation_exports as Relation, Scope_exports as Scope, Tag_exports as Tag, Text_exports as Text, Type_exports as Type, URI, View_exports as View };
@@ -0,0 +1,10 @@
1
+ import { _ as TagTypeDXN, a as isEntity, b as getDictionary, c as getKeys, d as ATTR_META, f as EntityMetaSchema, g as getMeta, h as foreignKeyEquals, i as update, l as getMetaChecked, m as foreignKey, n as get, o as addTag, p as compareForeignKeys, r as set, s as deleteKeys, u as removeTag, v as Dictionary, x as setDictionary, y as Key } from "./chunk-atom-snapshot.mjs";
2
+ import { $ as setMetaOwner, A as isVersion, B as TypeMetaSchemaDXN, C as objectFromJSON, Ct as sortByLabel, D as compareVersions, Dt as isProjection, E as setRefResolverOnData, Et as ProjectionTypeId, F as getDXNForRelationSchemaRef, G as prepareDecodedTypedTarget, H as makeDecodedEntityLive, I as makeRelationType, J as SchemaValidator, K as prepareTypedTarget, L as EchoObjectSchema, M as versionValid, N as EchoTypeKindSchema, O as decodeVersion, Ot as makeProjection, P as EchoRelationSchema, Q as getEchoRoot, R as makeObjectType, S as matchesTag, St as sort, T as objectToJSON, Tt as VersionTypeId, U as makeObject, V as makeEchoTypeSchema, W as TypedReactiveHandler, X as ReactiveArray, Y as checkIdNotPresentOnSchema, Z as objectData, _ as makeTypedEntityClass, _t as defineHiddenProperty, a as updateFieldsInSchema, at as enterChangeContext, b as filterMatchValue, bt as assertObjectModel, c as makeEntity, ct as isInChangeContext, d as makeRelation, dt as batchEvents, et as MutationOutsideChangeContextError, f as makeWithReactive, ft as emitEvent, g as createObject, gt as getStrongDependencyUris, h as isDeleted, ht as getStrongDependencies, i as updateFieldNameInSchema, it as clearPendingNotifications, j as version, k as encodeVersion, kt as RawObject, l as makeLabelAtom, lt as queueNotification, m as setValue, mt as typedJsonSerializer, n as addFieldsToSchema, nt as createPropertyDeleteError, o as clone, ot as executeChange, p as getSnapshot, pt as attachTypedJsonSerializer, q as validateAndReactifyTarget, r as removeFieldsFromSchema, rt as createPropertySetError, s as makeAtom, st as hasPendingNotifications, t as TypeSchema, tt as createArrayMethodError, u as makeProperty, ut as queueOwnerNotification, v as compareTypenameStrings, vt as prettyFilter, w as objectStructureToJson, wt as sortByTypename, x as matchMetaKey, xt as compare, y as filterMatchEntity, yt as prettyQuery, z as normalizeSchema } from "./chunk-internal.mjs";
3
+ import { a as ANY_OBJECT_VERSION, c as InstancePhantomId, d as SnapshotKindId, f as StaticTypeSchemaSlot, g as getStaticTypeSchema, h as getSchemaKind, i as ANY_OBJECT_TYPENAME, l as KindId, m as getEntityKindBrand, n as makeTypeJsonSchemaAnnotation, o as EntityKind, p as UnknownTypeSchemaBrandId, r as unwrapOptional, s as EntityKindSchema, t as createAnnotationHelper, u as SchemaKindId } from "./chunk-util.mjs";
4
+ import { $ as ReferenceAnnotation, $t as RelationTargetId, A as FIELD_PATH_ANNOTATION, At as ATTR_PARENT, B as FormLayoutAnnotationId, Bt as ATTR_DELETED, C as getBranch, Ct as getTypename, D as DEFAULT_LAYOUT_NAME, Dt as setLabel, E as getObjectEchoUri, Et as setDescriptionWithSchema, F as FormInlineAnnotation, Ft as TypeId, G as HiddenAnnotation, Gt as MetaId, H as FormOrderedAnnotationId, Ht as ATTR_RELATION_TARGET, I as FormInlineAnnotationId, It as getSchema, J as IconFromRefAnnotation, Jt as ObjectDeletedId, K as HiddenAnnotationId, Kt as ObjectBranchId, L as FormInputAnnotation, Lt as getType, M as FieldPath, Mt as ParentId, N as FormCreateAnnotation, Nt as SchemaId, O as DescriptionAnnotation, Ot as setLabelWithSchema, P as FormCreateAnnotationId, Pt as TypeEntityId, Q as PropertyMetaAnnotationId, Qt as RelationTargetDXNId, R as FormInputAnnotationId, Rt as setSchema, S as isInstanceOf, St as getTypeURI, T as getUri, Tt as setDescription, U as GeneratorAnnotation, Ut as ATTR_SELF_URI, V as FormOrderedAnnotation, Vt as ATTR_RELATION_SOURCE, W as GeneratorAnnotationId, Wt as ATTR_SELF_URI_LEGACY, X as LabelAnnotationId, Xt as RelationSourceDXNId, Y as LabelAnnotation, Yt as ObjectVersionId, Z as PropertyMeta, Zt as RelationSourceId, _t as getSchemaTypename, at as TypeMeta, bt as getTypeAnnotation, ct as getDescription, dt as getFromAst, en as SelfURIId, et as ReferenceAnnotationId, ft as getIcon, gt as getPropertyMetaAnnotation, ht as getLabelWithSchema, it as TypeIdentifierAnnotationId, j as FieldLookupAnnotationId, jt as ATTR_TYPE, k as DescriptionAnnotationId, kt as setTypename, lt as getDescriptionWithSchema, mt as getLabelProperty, nt as TypeAnnotation, ot as TypenameSchema, pt as getLabel, q as IconAnnotation, qt as ObjectDatabaseId, rt as TypeAnnotationId, st as VersionSchema, tt as SchemaMetaSymbol, ut as getEntityKind, vt as getSchemaURI, w as getDatabase, wt as makeUserAnnotation, x as getTypeURIFromSpecifier, xt as getTypeIdentifierAnnotation, yt as getSchemaVersion, z as FormLayoutAnnotation, zt as setType } from "./chunk-Database.mjs";
5
+ import { C as getProxyTarget, D as normalizeSpliceRange, E as isValidProxyTarget, O as symbolIsProxy, S as getProxySlot, T as isReactiveRecord, _ as ChangeId, a as StaticRefResolver, b as dangerouslySetProxyId, c as getRefSavedTarget, d as makeSettledRequest, f as refFromEncodedReference, g as subscribe, h as change, i as RefTypeId, k as symbolReactivePrototype, l as getReferenceAst, n as Ref, o as createEchoReferenceSchema, p as setRefResolver, r as RefImpl, s as createSchemaReference, t as JSON_SCHEMA_ECHO_REF_ID, u as getSchemaReference, v as EventId, w as isProxy, x as getProxyHandler, y as createProxy } from "./chunk-ref.mjs";
6
+ import { t as RefArray } from "./chunk-ref-array.mjs";
7
+ import { _ as getOptionsAnnotation, c as FormatAnnotationId, d as OptionsAnnotationId, f as PropertyKind, g as getFormatAnnotation, h as formatToType, l as FormatEnums, m as TypeFormat, n as CurrencyAnnotationId, p as TypeEnum, r as DecimalPrecision, s as FormatAnnotation, t as Currency, u as OptionsAnnotation, v as getTypeEnum, y as typeToFormat } from "./chunk-number.mjs";
8
+ import { _ as SimpleTime, a as Hostname, b as toSimpleDateTime, c as URL, d as GeoPoint, f as DateOnly, g as SimpleDateTime, h as SimpleDate, i as Formula, l as UUID, m as Duration, n as Format, o as Regex, p as DateTime, r as Email, s as Text, t as SelectOption, u as GeoLocation, v as TimeOnly, x as toSimpleTime, y as toSimpleDate } from "./chunk-select.mjs";
9
+ import { a as ECHO_ANNOTATIONS_NS_DEPRECATED_KEY, c as JsonSchemaFields, d as getSchemaProperty, f as setSchemaProperty, h as EchoAnnotations, i as toPropType, l as JsonSchemaType, m as DecodedAnnotations, n as toEffectSchema, o as ECHO_ANNOTATIONS_NS_KEY, p as CustomAnnotations, r as toJsonSchema, s as JsonSchemaEchoAnnotations, t as PropType, u as getNormalizedEchoAnnotations } from "./chunk-json-schema.mjs";
10
+ export { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, ATTR_DELETED, ATTR_META, ATTR_PARENT, ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, ATTR_SELF_URI, ATTR_SELF_URI_LEGACY, ATTR_TYPE, ChangeId, Currency, CurrencyAnnotationId, CustomAnnotations, DEFAULT_LAYOUT_NAME, DateOnly, DateTime, DecimalPrecision, DecodedAnnotations, DescriptionAnnotation, DescriptionAnnotationId, Dictionary, Duration, ECHO_ANNOTATIONS_NS_DEPRECATED_KEY, ECHO_ANNOTATIONS_NS_KEY, EchoAnnotations, EchoObjectSchema, EchoRelationSchema, EchoTypeKindSchema, Email, EntityKind, EntityKindSchema, EntityMetaSchema, EventId, FIELD_PATH_ANNOTATION, FieldLookupAnnotationId, FieldPath, FormCreateAnnotation, FormCreateAnnotationId, FormInlineAnnotation, FormInlineAnnotationId, FormInputAnnotation, FormInputAnnotationId, FormLayoutAnnotation, FormLayoutAnnotationId, FormOrderedAnnotation, FormOrderedAnnotationId, Format, FormatAnnotation, FormatAnnotationId, FormatEnums, Formula, GeneratorAnnotation, GeneratorAnnotationId, GeoLocation, GeoPoint, HiddenAnnotation, HiddenAnnotationId, Hostname, IconAnnotation, IconFromRefAnnotation, InstancePhantomId, JSON_SCHEMA_ECHO_REF_ID, JsonSchemaEchoAnnotations, JsonSchemaFields, JsonSchemaType, Key, KindId, LabelAnnotation, LabelAnnotationId, MetaId, MutationOutsideChangeContextError, ObjectBranchId, ObjectDatabaseId, ObjectDeletedId, ObjectVersionId, OptionsAnnotation, OptionsAnnotationId, ParentId, ProjectionTypeId, PropType, PropertyKind, PropertyMeta, PropertyMetaAnnotationId, RawObject, ReactiveArray, Ref, RefArray, RefImpl, RefTypeId, ReferenceAnnotation, ReferenceAnnotationId, Regex, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, SchemaId, SchemaKindId, SchemaMetaSymbol, SchemaValidator, SelectOption, SelfURIId, SimpleDate, SimpleDateTime, SimpleTime, SnapshotKindId, StaticRefResolver, StaticTypeSchemaSlot, TagTypeDXN, Text, TimeOnly, TypeAnnotation, TypeAnnotationId, TypeEntityId, TypeEnum, TypeFormat, TypeId, TypeIdentifierAnnotationId, TypeMeta, TypeMetaSchemaDXN, TypeSchema, TypedReactiveHandler, TypenameSchema, URL, UUID, UnknownTypeSchemaBrandId, VersionSchema, VersionTypeId, addFieldsToSchema, addTag, assertObjectModel, attachTypedJsonSerializer, batchEvents, change, checkIdNotPresentOnSchema, clearPendingNotifications, clone, compare, compareForeignKeys, compareTypenameStrings, compareVersions, createAnnotationHelper, createArrayMethodError, createEchoReferenceSchema, createObject, createPropertyDeleteError, createPropertySetError, createProxy, createSchemaReference, dangerouslySetProxyId, decodeVersion, defineHiddenProperty, deleteKeys, emitEvent, encodeVersion, enterChangeContext, executeChange, filterMatchEntity, filterMatchValue, foreignKey, foreignKeyEquals, formatToType, get, getBranch, getDXNForRelationSchemaRef, getDatabase, getDescription, getDescriptionWithSchema, getDictionary, getEchoRoot, getEntityKind, getEntityKindBrand, getFormatAnnotation, getFromAst, getIcon, getKeys, getLabel, getLabelProperty, getLabelWithSchema, getMeta, getMetaChecked, getNormalizedEchoAnnotations, getObjectEchoUri, getOptionsAnnotation, getPropertyMetaAnnotation, getProxyHandler, getProxySlot, getProxyTarget, getRefSavedTarget, getReferenceAst, getSchema, getSchemaKind, getSchemaProperty, getSchemaReference, getSchemaTypename, getSchemaURI, getSchemaVersion, getSnapshot, getStaticTypeSchema, getStrongDependencies, getStrongDependencyUris, getType, getTypeAnnotation, getTypeEnum, getTypeIdentifierAnnotation, getTypeURI, getTypeURIFromSpecifier, getTypename, getUri, hasPendingNotifications, isDeleted, isEntity, isInChangeContext, isInstanceOf, isProjection, isProxy, isReactiveRecord, isValidProxyTarget, isVersion, makeAtom, makeDecodedEntityLive, makeEchoTypeSchema, makeEntity, makeLabelAtom, makeObject, makeObjectType, makeProjection, makeProperty, makeRelation, makeRelationType, makeSettledRequest, makeTypeJsonSchemaAnnotation, makeTypedEntityClass, makeUserAnnotation, makeWithReactive, matchMetaKey, matchesTag, normalizeSchema, normalizeSpliceRange, objectData, objectFromJSON, objectStructureToJson, objectToJSON, prepareDecodedTypedTarget, prepareTypedTarget, prettyFilter, prettyQuery, queueNotification, queueOwnerNotification, refFromEncodedReference, removeFieldsFromSchema, removeTag, set, setDescription, setDescriptionWithSchema, setDictionary, setLabel, setLabelWithSchema, setMetaOwner, setRefResolver, setRefResolverOnData, setSchema, setSchemaProperty, setType, setTypename, setValue, sort, sortByLabel, sortByTypename, subscribe, symbolIsProxy, symbolReactivePrototype, toEffectSchema, toJsonSchema, toPropType, toSimpleDate, toSimpleDateTime, toSimpleTime, typeToFormat, typedJsonSerializer, unwrapOptional, update, updateFieldNameInSchema, updateFieldsInSchema, validateAndReactifyTarget, version, versionValid };
@@ -0,0 +1,346 @@
1
+ import { U as makeObject, t as TypeSchema } from "./chunk-internal.mjs";
2
+ import { g as getStaticTypeSchema } from "./chunk-util.mjs";
3
+ import { _t as getSchemaTypename } from "./chunk-Database.mjs";
4
+ import { g as subscribe } from "./chunk-ref.mjs";
5
+ import { r as toJsonSchema } from "./chunk-json-schema.mjs";
6
+ import { getURI, makeObject as makeObject$1, makeRelation } from "./Type.mjs";
7
+ import { Ref } from "./Ref.mjs";
8
+ import { Unknown } from "./Obj.mjs";
9
+ import { Service, TypeId } from "./Registry.mjs";
10
+ import { DatabaseDirectory, EntityStructure } from "@dxos/echo-protocol";
11
+ import { DXN, EID, EntityId, SpaceId } from "@dxos/keys";
12
+ import * as Schema from "effect/Schema";
13
+ import { assertArgument } from "@dxos/invariant";
14
+ import { deepMapValues } from "@dxos/util";
15
+ import { Event } from "@dxos/async";
16
+ import * as Layer from "effect/Layer";
17
+ import * as Atom from "@effect-atom/atom/Atom";
18
+ //#region src/testing/registry.ts
19
+ /**
20
+ * Noop `Registry.Service` layer for testing — always returns empty query results.
21
+ * Use this in test layer stacks that require `Registry.Service` but don't need
22
+ * actual registry contents.
23
+ */
24
+ var registryLayerNoop = Layer.succeed(Service, {
25
+ [TypeId]: TypeId,
26
+ id: "noop-registry",
27
+ changed: new Event(),
28
+ local: [],
29
+ add: () => {},
30
+ remove: () => false,
31
+ clear: () => {},
32
+ get: () => void 0,
33
+ getByURI: () => void 0,
34
+ list: () => [],
35
+ query: ((_queryOrFilter) => ({
36
+ results: [],
37
+ entries: [],
38
+ run: async () => [],
39
+ runEntries: async () => [],
40
+ runSync: () => [],
41
+ runSyncEntries: () => [],
42
+ first: async () => {
43
+ throw new Error("registryLayerNoop: registry is empty");
44
+ },
45
+ firstOrUndefined: async () => void 0,
46
+ subscribe: () => () => {},
47
+ atom: Atom.make(() => [])
48
+ }))
49
+ });
50
+ //#endregion
51
+ //#region src/testing/test-schema.ts
52
+ var TestSchema;
53
+ (function(_TestSchema) {
54
+ class Expando extends makeObject$1(DXN.make("com.example.type.expando", "0.1.0"))(Schema.Struct({}, {
55
+ key: Schema.String,
56
+ value: Schema.Any
57
+ })) {}
58
+ _TestSchema.Expando = Expando;
59
+ const Nested = Schema.Struct({ field: Schema.String });
60
+ class TestClass {
61
+ field = "value";
62
+ toJSON() {
63
+ return { field: this.field };
64
+ }
65
+ }
66
+ _TestSchema.TestClass = TestClass;
67
+ const ExampleSchema = _TestSchema.ExampleSchema = Schema.Struct({
68
+ string: Schema.String,
69
+ number: Schema.Number,
70
+ boolean: Schema.Boolean,
71
+ null: Schema.Null,
72
+ undefined: Schema.Undefined,
73
+ stringArray: Schema.Array(Schema.String),
74
+ twoDimNumberArray: Schema.Array(Schema.Array(Schema.Number)),
75
+ nested: Nested,
76
+ nestedArray: Schema.Array(Nested),
77
+ nestedNullableArray: Schema.Array(Schema.Union(Nested, Schema.Null)),
78
+ reference: Schema.suspend(() => Ref(Example)),
79
+ referenceArray: Schema.Array(Schema.suspend(() => Ref(Example))),
80
+ classInstance: Schema.instanceOf(TestClass),
81
+ other: Schema.Any
82
+ }).pipe(Schema.partial);
83
+ class Example extends makeObject$1(DXN.make("com.example.type.example", "0.1.0"))(ExampleSchema) {}
84
+ _TestSchema.Example = Example;
85
+ const MessageStruct = _TestSchema.MessageStruct = Schema.Struct({ timestamp: Schema.String.pipe(Schema.propertySignature, Schema.withConstructorDefault(() => (/* @__PURE__ */ new Date()).toISOString())) });
86
+ class Message extends makeObject$1(DXN.make("com.example.type.message", "0.1.0"))(MessageStruct) {}
87
+ _TestSchema.Message = Message;
88
+ class Organization extends makeObject$1(DXN.make("com.example.type.organization", "0.1.0"))(Schema.Struct({
89
+ name: Schema.String,
90
+ properties: Schema.optional(Schema.Record({
91
+ key: Schema.String,
92
+ value: Schema.String
93
+ }))
94
+ })) {}
95
+ _TestSchema.Organization = Organization;
96
+ class Person extends makeObject$1(DXN.make("com.example.type.person", "0.1.0"))(Schema.Struct({
97
+ name: Schema.String,
98
+ username: Schema.String,
99
+ email: Schema.String,
100
+ age: Schema.Number.pipe(Schema.optional),
101
+ tasks: Schema.Array(Schema.suspend(() => Ref(Task))),
102
+ employer: Schema.optional(Ref(Organization)),
103
+ address: Schema.Struct({
104
+ city: Schema.optional(Schema.String),
105
+ state: Schema.optional(Schema.String),
106
+ zip: Schema.optional(Schema.String),
107
+ coordinates: Schema.Struct({
108
+ lat: Schema.optional(Schema.Number),
109
+ lng: Schema.optional(Schema.Number)
110
+ })
111
+ }),
112
+ fields: Schema.Struct({
113
+ label: Schema.String,
114
+ value: Schema.String
115
+ }).pipe(Schema.Array, Schema.optional)
116
+ }).pipe(Schema.partial)) {}
117
+ _TestSchema.Person = Person;
118
+ class Task extends makeObject$1(DXN.make("com.example.type.task", "0.1.0"))(Schema.Struct({
119
+ title: Schema.optional(Schema.String),
120
+ deadline: Schema.optional(Schema.String),
121
+ completed: Schema.optional(Schema.Boolean),
122
+ assignee: Schema.optional(Ref(Person)),
123
+ previous: Schema.optional(Schema.suspend(() => Ref(Task))),
124
+ subTasks: Schema.optional(Schema.Array(Schema.suspend(() => Ref(Task)))),
125
+ description: Schema.optional(Schema.String)
126
+ }).pipe(Schema.partial)) {}
127
+ _TestSchema.Task = Task;
128
+ class HasManager extends makeRelation(DXN.make("com.example.type.hasManager", "0.1.0"))({
129
+ source: Person,
130
+ target: Person
131
+ })(Schema.Struct({})) {}
132
+ _TestSchema.HasManager = HasManager;
133
+ class EmployedBy extends makeRelation(DXN.make("com.example.type.employedBy", "0.1.0"))({
134
+ source: Person,
135
+ target: Organization
136
+ })(Schema.Struct({
137
+ role: Schema.String,
138
+ since: Schema.optional(Schema.String)
139
+ })) {}
140
+ _TestSchema.EmployedBy = EmployedBy;
141
+ let RecordType = /* @__PURE__ */ function(RecordType) {
142
+ RecordType[RecordType["UNDEFINED"] = 0] = "UNDEFINED";
143
+ RecordType[RecordType["PERSONAL"] = 1] = "PERSONAL";
144
+ RecordType[RecordType["WORK"] = 2] = "WORK";
145
+ return RecordType;
146
+ }({});
147
+ _TestSchema.RecordType = RecordType;
148
+ class Container extends makeObject$1(DXN.make("com.example.type.container", "0.1.0"))(Schema.Struct({
149
+ objects: Schema.Array(Ref(Unknown)),
150
+ records: Schema.Array(Schema.partial(Schema.Struct({
151
+ title: Schema.String,
152
+ description: Schema.String,
153
+ contacts: Schema.Array(Ref(Person)),
154
+ type: Schema.Enums(RecordType)
155
+ })))
156
+ }).pipe(Schema.partial)) {}
157
+ _TestSchema.Container = Container;
158
+ })(TestSchema || (TestSchema = {}));
159
+ //#endregion
160
+ //#region src/testing/test-data.ts
161
+ var cachedSpaceId;
162
+ var getSpaceId = () => {
163
+ if (cachedSpaceId === void 0) cachedSpaceId = SpaceId.random();
164
+ return cachedSpaceId;
165
+ };
166
+ var cachedPeopleAlice;
167
+ var cachedPeopleBob;
168
+ var cachedOrgsDxos;
169
+ var cachedOrgsCyberdyne;
170
+ var cachedWorksFredCyberdyne;
171
+ var cachedWorksAliceAperture;
172
+ var cachedTasksTask1;
173
+ var cachedTasksTask2;
174
+ var PEOPLE = {
175
+ get alice() {
176
+ if (cachedPeopleAlice === void 0) cachedPeopleAlice = DatabaseDirectory.make({
177
+ spaceId: getSpaceId(),
178
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
179
+ type: getURI(TestSchema.Person),
180
+ data: { name: "Alice" }
181
+ }) }
182
+ });
183
+ return cachedPeopleAlice;
184
+ },
185
+ get bob() {
186
+ if (cachedPeopleBob === void 0) cachedPeopleBob = DatabaseDirectory.make({
187
+ spaceId: getSpaceId(),
188
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
189
+ type: getURI(TestSchema.Person),
190
+ data: { name: "Bob" }
191
+ }) }
192
+ });
193
+ return cachedPeopleBob;
194
+ }
195
+ };
196
+ var ORGS = {
197
+ get dxos() {
198
+ if (cachedOrgsDxos === void 0) cachedOrgsDxos = DatabaseDirectory.make({
199
+ spaceId: getSpaceId(),
200
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
201
+ type: getURI(TestSchema.Organization),
202
+ data: {
203
+ name: "DXOS",
204
+ founded: "2023"
205
+ }
206
+ }) }
207
+ });
208
+ return cachedOrgsDxos;
209
+ },
210
+ get cyberdyne() {
211
+ if (cachedOrgsCyberdyne === void 0) cachedOrgsCyberdyne = DatabaseDirectory.make({
212
+ spaceId: getSpaceId(),
213
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
214
+ type: getURI(TestSchema.Organization),
215
+ data: {
216
+ name: "Cyberdyne Systems",
217
+ founded: "1984"
218
+ }
219
+ }) }
220
+ });
221
+ return cachedOrgsCyberdyne;
222
+ }
223
+ };
224
+ var WORKS_FOR = {
225
+ get fredWorksForCyberdyne() {
226
+ if (cachedWorksFredCyberdyne === void 0) cachedWorksFredCyberdyne = DatabaseDirectory.make({
227
+ spaceId: getSpaceId(),
228
+ objects: { [EntityId.random()]: EntityStructure.makeRelation({
229
+ type: getURI(TestSchema.EmployedBy),
230
+ source: { "/": EID.make({ entityId: Object.keys(PEOPLE.bob.objects)[0] }) },
231
+ target: { "/": EID.make({ entityId: Object.keys(ORGS.cyberdyne.objects)[0] }) },
232
+ data: {
233
+ since: "2020",
234
+ position: "Engineer"
235
+ }
236
+ }) }
237
+ });
238
+ return cachedWorksFredCyberdyne;
239
+ },
240
+ get aliceWorksForAperture() {
241
+ if (cachedWorksAliceAperture === void 0) cachedWorksAliceAperture = DatabaseDirectory.make({
242
+ spaceId: getSpaceId(),
243
+ objects: { [EntityId.random()]: EntityStructure.makeRelation({
244
+ type: getURI(TestSchema.EmployedBy),
245
+ source: { "/": EID.make({ entityId: Object.keys(PEOPLE.alice.objects)[0] }) },
246
+ target: { "/": EID.make({ entityId: Object.keys(ORGS.dxos.objects)[0] }) },
247
+ data: {
248
+ since: "2018",
249
+ position: "Research Scientist"
250
+ }
251
+ }) }
252
+ });
253
+ return cachedWorksAliceAperture;
254
+ }
255
+ };
256
+ var TASKS = {
257
+ get task1() {
258
+ if (cachedTasksTask1 === void 0) cachedTasksTask1 = DatabaseDirectory.make({
259
+ spaceId: getSpaceId(),
260
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
261
+ type: getURI(TestSchema.Task),
262
+ data: {
263
+ title: "Complete project documentation",
264
+ description: "Write comprehensive documentation for the new system",
265
+ status: "in-progress",
266
+ dueDate: "2023-12-31",
267
+ assignee: { "/": EID.make({ entityId: Object.keys(PEOPLE.bob.objects)[0] }) }
268
+ }
269
+ }) }
270
+ });
271
+ return cachedTasksTask1;
272
+ },
273
+ get task2() {
274
+ if (cachedTasksTask2 === void 0) cachedTasksTask2 = DatabaseDirectory.make({
275
+ spaceId: getSpaceId(),
276
+ objects: { [EntityId.random()]: EntityStructure.makeObject({
277
+ type: getURI(TestSchema.Task),
278
+ data: {
279
+ title: "Run experiments",
280
+ description: "Conduct series of experiments on the portal device",
281
+ status: "pending",
282
+ dueDate: "2023-11-15",
283
+ assignee: { "/": EID.make({ entityId: Object.keys(PEOPLE.alice.objects)[0] }) }
284
+ }
285
+ }) }
286
+ });
287
+ return cachedTasksTask2;
288
+ }
289
+ };
290
+ //#endregion
291
+ //#region src/testing/util.ts
292
+ /**
293
+ * Create an in-memory `Type.Type` entity (a `TypeSchema` object) for tests.
294
+ * Accepts a raw Effect Schema. Pass `Type.getSchema(entity)` to convert a
295
+ * `Type.Type` entity to its underlying source schema first.
296
+ */
297
+ var createEchoSchema = (schema, version = "0.1.0") => {
298
+ const jsonSchema = toJsonSchema(schema);
299
+ const typename = getSchemaTypename(schema);
300
+ assertArgument(typename, "typename", "Schema does not have a typename.");
301
+ return makeObject(getStaticTypeSchema(TypeSchema), { jsonSchema }, {
302
+ keys: [],
303
+ key: typename,
304
+ version
305
+ }, TypeSchema);
306
+ };
307
+ /**
308
+ * Converts AST to a format that can be compared with test matchers.
309
+ */
310
+ var prepareAstForCompare = (obj) => deepMapValues(obj, (value, recurse) => {
311
+ if (typeof value === "function") return null;
312
+ if (value instanceof RegExp) return value;
313
+ if (typeof value === "object") {
314
+ const clone = { ...value };
315
+ for (const sym of Object.getOwnPropertySymbols(clone)) {
316
+ clone[sym.toString()] = clone[sym];
317
+ delete clone[sym];
318
+ }
319
+ return recurse(clone);
320
+ }
321
+ return recurse(value);
322
+ });
323
+ /**
324
+ * Creates an update counter that tracks changes to reactive objects.
325
+ * @param objects - Reactive objects to subscribe to.
326
+ * @returns An object with a count property and Symbol.dispose for cleanup.
327
+ */
328
+ var updateCounter = (...objects) => {
329
+ let updateCount = 0;
330
+ const unsubscribes = objects.map((obj) => subscribe(obj, () => {
331
+ updateCount++;
332
+ }));
333
+ const unsubscribeAll = () => {
334
+ for (const unsub of unsubscribes) unsub();
335
+ };
336
+ return {
337
+ [Symbol.dispose]: unsubscribeAll,
338
+ get count() {
339
+ return updateCount;
340
+ }
341
+ };
342
+ };
343
+ //#endregion
344
+ export { ORGS, PEOPLE, TASKS, TestSchema, WORKS_FOR, createEchoSchema, prepareAstForCompare, registryLayerNoop, updateCounter };
345
+
346
+ //# sourceMappingURL=testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing/registry.ts","../../src/testing/test-schema.ts","../../src/testing/test-data.ts","../../src/testing/util.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from '@effect-atom/atom/Atom';\nimport * as Layer from 'effect/Layer';\n\nimport { Event } from '@dxos/async';\n\nimport * as Registry from '../Registry';\n\n/**\n * Noop `Registry.Service` layer for testing — always returns empty query results.\n * Use this in test layer stacks that require `Registry.Service` but don't need\n * actual registry contents.\n */\nexport const registryLayerNoop: Layer.Layer<Registry.Service> = Layer.succeed(Registry.Service, {\n [Registry.TypeId]: Registry.TypeId,\n id: 'noop-registry',\n changed: new Event<void>(),\n local: [],\n add: () => {},\n remove: () => false,\n clear: () => {},\n get: () => undefined,\n getByURI: () => undefined,\n list: () => [],\n // QueryFn is an overloaded interface — a single generic function cannot satisfy both overload\n // signatures without a cast. This is the intentional type-system boundary.\n query: ((_queryOrFilter: unknown) => ({\n results: [],\n entries: [],\n run: async () => [],\n runEntries: async () => [],\n runSync: () => [],\n runSyncEntries: () => [],\n first: async (): Promise<never> => {\n throw new Error('registryLayerNoop: registry is empty');\n },\n firstOrUndefined: async () => undefined,\n subscribe: () => () => {},\n atom: Atom.make((): never[] => []),\n })) as Registry.Registry['query'],\n} satisfies Registry.Registry);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Obj from '../Obj';\nimport * as Ref from '../Ref';\nimport * as Type from '../Type';\n\nexport namespace TestSchema {\n //\n // Expando\n //\n\n /**\n * Expando object is an object with an arbitrary set of properties.\n * This is the test variant with example.com namespace.\n */\n export class Expando extends Type.makeObject<Expando>(DXN.make('com.example.type.expando', '0.1.0'))(\n Schema.Struct({}, { key: Schema.String, value: Schema.Any }),\n ) {}\n\n //\n // Example\n //\n\n const Nested = Schema.Struct({\n field: Schema.String,\n });\n\n export class TestClass {\n field = 'value';\n toJSON() {\n return { field: this.field };\n }\n }\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export const ExampleSchema = Schema.Struct({\n string: Schema.String,\n number: Schema.Number,\n boolean: Schema.Boolean,\n null: Schema.Null,\n undefined: Schema.Undefined,\n stringArray: Schema.Array(Schema.String),\n twoDimNumberArray: Schema.Array(Schema.Array(Schema.Number)),\n nested: Nested,\n nestedArray: Schema.Array(Nested),\n nestedNullableArray: Schema.Array(Schema.Union(Nested, Schema.Null)),\n reference: Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example)),\n referenceArray: Schema.Array(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))),\n classInstance: Schema.instanceOf(TestClass),\n other: Schema.Any,\n }).pipe(Schema.partial);\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export interface ExampleSchema extends Schema.Schema.Type<typeof ExampleSchema> {}\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export class Example extends Type.makeObject<Example>(DXN.make('com.example.type.example', '0.1.0'))(ExampleSchema) {}\n\n //\n // Message\n //\n\n // TODO(burdon): Support defaults directly on Type: `make` is erased by `pipe(Type.Obj)`.\n export const MessageStruct = Schema.Struct({\n // TODO(burdon): Support S.Date; Custom Timestamp (with defaults).\n // TODO(burdon): Support defaults (update create and create).\n timestamp: Schema.String.pipe(\n Schema.propertySignature,\n Schema.withConstructorDefault(() => new Date().toISOString()),\n ),\n });\n\n export class Message extends Type.makeObject<Message>(DXN.make('com.example.type.message', '0.1.0'))(MessageStruct) {}\n\n //\n // Organization\n //\n\n export class Organization extends Type.makeObject<Organization>(DXN.make('com.example.type.organization', '0.1.0'))(\n Schema.Struct({\n name: Schema.String,\n properties: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.String,\n }),\n ),\n }),\n ) {}\n\n //\n // Person\n //\n\n export class Person extends Type.makeObject<Person>(DXN.make('com.example.type.person', '0.1.0'))(\n Schema.Struct({\n name: Schema.String,\n username: Schema.String,\n email: Schema.String,\n age: Schema.Number.pipe(Schema.optional),\n tasks: Schema.Array(Schema.suspend((): Ref.RefSchema<Task> => Ref.Ref(Task))),\n employer: Schema.optional(Ref.Ref(Organization)),\n address: Schema.Struct({\n city: Schema.optional(Schema.String),\n state: Schema.optional(Schema.String),\n zip: Schema.optional(Schema.String),\n coordinates: Schema.Struct({\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }),\n }),\n fields: Schema.Struct({\n label: Schema.String,\n value: Schema.String,\n }).pipe(Schema.Array, Schema.optional),\n }).pipe(Schema.partial),\n ) {}\n\n //\n // Task\n //\n\n export class Task extends Type.makeObject<Task>(DXN.make('com.example.type.task', '0.1.0'))(\n Schema.Struct({\n title: Schema.optional(Schema.String),\n deadline: Schema.optional(Schema.String),\n completed: Schema.optional(Schema.Boolean),\n assignee: Schema.optional(Ref.Ref(Person)),\n previous: Schema.optional(Schema.suspend((): Ref.RefSchema<Task> => Ref.Ref(Task))),\n subTasks: Schema.optional(Schema.Array(Schema.suspend((): Ref.RefSchema<Task> => Ref.Ref(Task)))),\n description: Schema.optional(Schema.String),\n }).pipe(Schema.partial),\n ) {}\n\n //\n // HasManager\n //\n\n export class HasManager extends Type.makeRelation<HasManager>(DXN.make('com.example.type.hasManager', '0.1.0'))({\n source: Person,\n target: Person,\n })(Schema.Struct({})) {}\n\n //\n // EmployedBy\n //\n\n export class EmployedBy extends Type.makeRelation<EmployedBy>(DXN.make('com.example.type.employedBy', '0.1.0'))({\n source: Person,\n target: Organization,\n })(\n Schema.Struct({\n role: Schema.String,\n since: Schema.optional(Schema.String),\n }),\n ) {}\n\n //\n // RecordType\n //\n\n export enum RecordType {\n UNDEFINED = 0,\n PERSONAL = 1,\n WORK = 2,\n }\n\n export class Container extends Type.makeObject<Container>(DXN.make('com.example.type.container', '0.1.0'))(\n Schema.Struct({\n objects: Schema.Array(Ref.Ref(Obj.Unknown)),\n records: Schema.Array(\n Schema.partial(\n Schema.Struct({\n title: Schema.String,\n description: Schema.String,\n contacts: Schema.Array(Ref.Ref(Person)),\n type: Schema.Enums(RecordType),\n }),\n ),\n ),\n }).pipe(Schema.partial),\n ) {}\n}\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { DatabaseDirectory, EntityStructure } from '@dxos/echo-protocol';\nimport { EID, EntityId, SpaceId } from '@dxos/keys';\n\nimport { Type } from '../index';\nimport { TestSchema } from './test-schema';\n\n// Lazy init: Cloudflare workers disallow non-determinism at module scope (e.g. random keys).\nlet cachedSpaceId: SpaceId | undefined;\nconst getSpaceId = (): SpaceId => {\n if (cachedSpaceId === undefined) {\n cachedSpaceId = SpaceId.random();\n }\n return cachedSpaceId;\n};\n\nlet cachedPeopleAlice: DatabaseDirectory | undefined;\nlet cachedPeopleBob: DatabaseDirectory | undefined;\nlet cachedOrgsDxos: DatabaseDirectory | undefined;\nlet cachedOrgsCyberdyne: DatabaseDirectory | undefined;\nlet cachedWorksFredCyberdyne: DatabaseDirectory | undefined;\nlet cachedWorksAliceAperture: DatabaseDirectory | undefined;\nlet cachedTasksTask1: DatabaseDirectory | undefined;\nlet cachedTasksTask2: DatabaseDirectory | undefined;\n\n// TODO(burdon): Use Obj.make.\n\nexport const PEOPLE = {\n get alice(): DatabaseDirectory {\n if (cachedPeopleAlice === undefined) {\n cachedPeopleAlice = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Person)!,\n data: {\n name: 'Alice',\n },\n }),\n },\n });\n }\n return cachedPeopleAlice;\n },\n\n get bob(): DatabaseDirectory {\n if (cachedPeopleBob === undefined) {\n cachedPeopleBob = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Person)!,\n data: {\n name: 'Bob',\n },\n }),\n },\n });\n }\n return cachedPeopleBob;\n },\n};\n\nexport const ORGS = {\n get dxos(): DatabaseDirectory {\n if (cachedOrgsDxos === undefined) {\n cachedOrgsDxos = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Organization)!,\n data: {\n name: 'DXOS',\n founded: '2023',\n },\n }),\n },\n });\n }\n return cachedOrgsDxos;\n },\n\n get cyberdyne(): DatabaseDirectory {\n if (cachedOrgsCyberdyne === undefined) {\n cachedOrgsCyberdyne = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Organization)!,\n data: {\n name: 'Cyberdyne Systems',\n founded: '1984',\n },\n }),\n },\n });\n }\n return cachedOrgsCyberdyne;\n },\n};\n\nexport const WORKS_FOR = {\n get fredWorksForCyberdyne(): DatabaseDirectory {\n if (cachedWorksFredCyberdyne === undefined) {\n cachedWorksFredCyberdyne = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeRelation({\n type: Type.getURI(TestSchema.EmployedBy)!,\n source: { '/': EID.make({ entityId: Object.keys(PEOPLE.bob.objects!)[0] }) },\n target: { '/': EID.make({ entityId: Object.keys(ORGS.cyberdyne.objects!)[0] }) },\n data: {\n since: '2020',\n position: 'Engineer',\n },\n }),\n },\n });\n }\n return cachedWorksFredCyberdyne;\n },\n\n get aliceWorksForAperture(): DatabaseDirectory {\n if (cachedWorksAliceAperture === undefined) {\n cachedWorksAliceAperture = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeRelation({\n type: Type.getURI(TestSchema.EmployedBy)!,\n source: { '/': EID.make({ entityId: Object.keys(PEOPLE.alice.objects!)[0] }) },\n target: { '/': EID.make({ entityId: Object.keys(ORGS.dxos.objects!)[0] }) },\n data: {\n since: '2018',\n position: 'Research Scientist',\n },\n }),\n },\n });\n }\n return cachedWorksAliceAperture;\n },\n};\n\nexport const TASKS = {\n get task1(): DatabaseDirectory {\n if (cachedTasksTask1 === undefined) {\n cachedTasksTask1 = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Task)!,\n data: {\n title: 'Complete project documentation',\n description: 'Write comprehensive documentation for the new system',\n status: 'in-progress',\n dueDate: '2023-12-31',\n assignee: { '/': EID.make({ entityId: Object.keys(PEOPLE.bob.objects!)[0] }) },\n },\n }),\n },\n });\n }\n return cachedTasksTask1;\n },\n\n get task2(): DatabaseDirectory {\n if (cachedTasksTask2 === undefined) {\n cachedTasksTask2 = DatabaseDirectory.make({\n spaceId: getSpaceId(),\n objects: {\n [EntityId.random()]: EntityStructure.makeObject({\n type: Type.getURI(TestSchema.Task)!,\n data: {\n title: 'Run experiments',\n description: 'Conduct series of experiments on the portal device',\n status: 'pending',\n dueDate: '2023-11-15',\n assignee: { '/': EID.make({ entityId: Object.keys(PEOPLE.alice.objects!)[0] }) },\n },\n }),\n },\n });\n }\n return cachedTasksTask2;\n },\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { assertArgument } from '@dxos/invariant';\nimport { deepMapValues } from '@dxos/util';\n\nimport { TypeSchema, getSchemaTypename, getStaticTypeSchema, makeObject, subscribe, toJsonSchema } from '../internal';\nimport type * as Type from '../Type';\n\n/**\n * Create an in-memory `Type.Type` entity (a `TypeSchema` object) for tests.\n * Accepts a raw Effect Schema. Pass `Type.getSchema(entity)` to convert a\n * `Type.Type` entity to its underlying source schema first.\n */\n// TODO(dmaretskyi): Should be replaced by registration of typed object.\nexport const createEchoSchema = (schema: Schema.Schema.AnyNoContext, version = '0.1.0'): Type.Type => {\n const jsonSchema = toJsonSchema(schema);\n const typename = getSchemaTypename(schema);\n assertArgument(typename, 'typename', 'Schema does not have a typename.');\n // typename/version are routed via EntityMeta (the canonical registry-provenance\n // pair); they're no longer data fields on `TypeSchema`.\n return makeObject(\n getStaticTypeSchema(TypeSchema) as any,\n { jsonSchema },\n { keys: [], key: typename, version },\n TypeSchema,\n ) as unknown as Type.Type;\n};\n\n/**\n * Converts AST to a format that can be compared with test matchers.\n */\nexport const prepareAstForCompare = (obj: SchemaAST.AST): any =>\n deepMapValues(obj, (value: any, recurse: any) => {\n if (typeof value === 'function') {\n return null;\n }\n\n if (value instanceof RegExp) {\n return value;\n }\n\n // Convert symbols to strings.\n if (typeof value === 'object') {\n const clone = { ...value };\n for (const sym of Object.getOwnPropertySymbols(clone as any)) {\n clone[sym.toString()] = clone[sym];\n delete clone[sym];\n }\n\n return recurse(clone);\n }\n\n return recurse(value);\n });\n\n/**\n * Creates an update counter that tracks changes to reactive objects.\n * @param objects - Reactive objects to subscribe to.\n * @returns An object with a count property and Symbol.dispose for cleanup.\n */\nexport const updateCounter = (...objects: object[]) => {\n let updateCount = 0;\n\n const unsubscribes = objects.map((obj) =>\n subscribe(obj, () => {\n updateCount++;\n }),\n );\n\n const unsubscribeAll = () => {\n for (const unsub of unsubscribes) {\n unsub();\n }\n };\n\n return {\n // https://github.com/tc39/proposal-explicit-resource-management\n [Symbol.dispose]: unsubscribeAll,\n get count() {\n return updateCount;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAa,oBAAmD,MAAM,QAAQ,SAAkB;EAC7F,SAAkB;CACnB,IAAI;CACJ,SAAS,IAAI,MAAY;CACzB,OAAO,CAAC;CACR,WAAW,CA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