@fluidframework/tree 2.92.0 → 2.93.0

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 (292) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +1 -1
  3. package/api-report/tree.alpha.api.md +57 -29
  4. package/api-report/tree.beta.api.md +41 -12
  5. package/api-report/tree.legacy.beta.api.md +41 -12
  6. package/dist/api.d.ts +6 -1
  7. package/dist/api.d.ts.map +1 -1
  8. package/dist/api.js.map +1 -1
  9. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  10. package/dist/core/tree/anchorSet.js +21 -0
  11. package/dist/core/tree/anchorSet.js.map +1 -1
  12. package/dist/entrypoints/alpha.d.ts +1 -1
  13. package/dist/entrypoints/alpha.d.ts.map +1 -1
  14. package/dist/entrypoints/alpha.js +4 -4
  15. package/dist/entrypoints/alpha.js.map +1 -1
  16. package/dist/entrypoints/beta.d.ts +1 -1
  17. package/dist/entrypoints/beta.d.ts.map +1 -1
  18. package/dist/entrypoints/beta.js +3 -1
  19. package/dist/entrypoints/beta.js.map +1 -1
  20. package/dist/entrypoints/legacy.d.ts +1 -1
  21. package/dist/entrypoints/legacy.d.ts.map +1 -1
  22. package/dist/entrypoints/legacy.js +3 -1
  23. package/dist/entrypoints/legacy.js.map +1 -1
  24. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
  25. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  26. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -1
  27. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
  29. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/uniformChunk.js +22 -18
  31. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  32. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +1 -0
  33. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  34. package/dist/feature-libraries/indexing/anchorTreeIndex.js +3 -1
  35. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  36. package/dist/feature-libraries/indexing/types.d.ts +4 -3
  37. package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
  38. package/dist/feature-libraries/indexing/types.js.map +1 -1
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/serializableDomainSchema.d.ts +5 -5
  46. package/dist/serializableDomainSchema.d.ts.map +1 -1
  47. package/dist/serializableDomainSchema.js.map +1 -1
  48. package/dist/shared-tree/treeAlpha.d.ts +6 -2
  49. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  50. package/dist/shared-tree/treeAlpha.js.map +1 -1
  51. package/dist/simple-tree/api/discrepancies.js +4 -1
  52. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  53. package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
  54. package/dist/simple-tree/api/identifierIndex.js +1 -1
  55. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  56. package/dist/simple-tree/api/index.d.ts +2 -2
  57. package/dist/simple-tree/api/index.d.ts.map +1 -1
  58. package/dist/simple-tree/api/index.js +3 -2
  59. package/dist/simple-tree/api/index.js.map +1 -1
  60. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +31 -2
  61. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  62. package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
  63. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  64. package/dist/simple-tree/api/simpleTreeIndex.d.ts +5 -5
  65. package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
  66. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  67. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  68. package/dist/simple-tree/api/storedSchema.js +4 -1
  69. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  70. package/dist/simple-tree/api/treeAlpha.d.ts +70 -13
  71. package/dist/simple-tree/api/treeAlpha.d.ts.map +1 -1
  72. package/dist/simple-tree/api/treeAlpha.js.map +1 -1
  73. package/dist/simple-tree/api/treeChangeEvents.d.ts +1 -1
  74. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  75. package/dist/simple-tree/api/treeNodeApi.d.ts +60 -1
  76. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  77. package/dist/simple-tree/api/treeNodeApi.js +68 -6
  78. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  79. package/dist/simple-tree/core/toStored.d.ts +7 -0
  80. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  81. package/dist/simple-tree/core/toStored.js.map +1 -1
  82. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
  83. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  84. package/dist/simple-tree/core/unhydratedFlexTree.js +114 -12
  85. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  86. package/dist/simple-tree/fieldSchema.d.ts +6 -1
  87. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  88. package/dist/simple-tree/fieldSchema.js +3 -0
  89. package/dist/simple-tree/fieldSchema.js.map +1 -1
  90. package/dist/simple-tree/index.d.ts +2 -2
  91. package/dist/simple-tree/index.d.ts.map +1 -1
  92. package/dist/simple-tree/index.js +4 -3
  93. package/dist/simple-tree/index.js.map +1 -1
  94. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  95. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  96. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  97. package/dist/simple-tree/node-kinds/map/index.d.ts +1 -1
  98. package/dist/simple-tree/node-kinds/map/index.d.ts.map +1 -1
  99. package/dist/simple-tree/node-kinds/map/index.js.map +1 -1
  100. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  101. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  102. package/dist/simple-tree/node-kinds/map/mapNode.js +6 -1
  103. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  104. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
  105. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  106. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  107. package/dist/simple-tree/simpleSchema.d.ts +17 -0
  108. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  109. package/dist/simple-tree/simpleSchema.js.map +1 -1
  110. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  111. package/dist/simple-tree/toStoredSchema.js +23 -1
  112. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  113. package/dist/tableSchema.d.ts +4 -5
  114. package/dist/tableSchema.d.ts.map +1 -1
  115. package/dist/tableSchema.js +12 -23
  116. package/dist/tableSchema.js.map +1 -1
  117. package/dist/text/textDomain.d.ts.map +1 -1
  118. package/dist/text/textDomain.js +27 -0
  119. package/dist/text/textDomain.js.map +1 -1
  120. package/dist/text/textDomainFormatted.d.ts +4 -4
  121. package/dist/util/index.d.ts +1 -1
  122. package/dist/util/index.d.ts.map +1 -1
  123. package/dist/util/index.js +2 -3
  124. package/dist/util/index.js.map +1 -1
  125. package/dist/util/utils.d.ts +0 -1
  126. package/dist/util/utils.d.ts.map +1 -1
  127. package/dist/util/utils.js +1 -6
  128. package/dist/util/utils.js.map +1 -1
  129. package/eslint.config.mts +1 -1
  130. package/lib/api.d.ts +6 -1
  131. package/lib/api.d.ts.map +1 -1
  132. package/lib/api.js.map +1 -1
  133. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  134. package/lib/core/tree/anchorSet.js +21 -0
  135. package/lib/core/tree/anchorSet.js.map +1 -1
  136. package/lib/entrypoints/alpha.d.ts +1 -1
  137. package/lib/entrypoints/alpha.d.ts.map +1 -1
  138. package/lib/entrypoints/alpha.js +1 -1
  139. package/lib/entrypoints/alpha.js.map +1 -1
  140. package/lib/entrypoints/beta.d.ts +1 -1
  141. package/lib/entrypoints/beta.d.ts.map +1 -1
  142. package/lib/entrypoints/beta.js +1 -1
  143. package/lib/entrypoints/beta.js.map +1 -1
  144. package/lib/entrypoints/legacy.d.ts +1 -1
  145. package/lib/entrypoints/legacy.d.ts.map +1 -1
  146. package/lib/entrypoints/legacy.js +1 -1
  147. package/lib/entrypoints/legacy.js.map +1 -1
  148. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +2 -2
  149. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  150. package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -1
  151. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  152. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +13 -5
  153. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  154. package/lib/feature-libraries/chunked-forest/uniformChunk.js +22 -18
  155. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  156. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +1 -0
  157. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  158. package/lib/feature-libraries/indexing/anchorTreeIndex.js +3 -1
  159. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  160. package/lib/feature-libraries/indexing/types.d.ts +4 -3
  161. package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
  162. package/lib/feature-libraries/indexing/types.js.map +1 -1
  163. package/lib/index.d.ts +1 -1
  164. package/lib/index.d.ts.map +1 -1
  165. package/lib/index.js.map +1 -1
  166. package/lib/packageVersion.d.ts +1 -1
  167. package/lib/packageVersion.js +1 -1
  168. package/lib/packageVersion.js.map +1 -1
  169. package/lib/serializableDomainSchema.d.ts +5 -5
  170. package/lib/serializableDomainSchema.d.ts.map +1 -1
  171. package/lib/serializableDomainSchema.js +4 -1
  172. package/lib/serializableDomainSchema.js.map +1 -1
  173. package/lib/shared-tree/treeAlpha.d.ts +6 -2
  174. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  175. package/lib/shared-tree/treeAlpha.js.map +1 -1
  176. package/lib/simple-tree/api/discrepancies.js +4 -1
  177. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  178. package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
  179. package/lib/simple-tree/api/identifierIndex.js +1 -1
  180. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  181. package/lib/simple-tree/api/index.d.ts +2 -2
  182. package/lib/simple-tree/api/index.d.ts.map +1 -1
  183. package/lib/simple-tree/api/index.js +1 -1
  184. package/lib/simple-tree/api/index.js.map +1 -1
  185. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +31 -2
  186. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  187. package/lib/simple-tree/api/schemaFactoryAlpha.js +19 -3
  188. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  189. package/lib/simple-tree/api/simpleTreeIndex.d.ts +5 -5
  190. package/lib/simple-tree/api/simpleTreeIndex.js +1 -1
  191. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  192. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  193. package/lib/simple-tree/api/storedSchema.js +4 -1
  194. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  195. package/lib/simple-tree/api/treeAlpha.d.ts +70 -13
  196. package/lib/simple-tree/api/treeAlpha.d.ts.map +1 -1
  197. package/lib/simple-tree/api/treeAlpha.js.map +1 -1
  198. package/lib/simple-tree/api/treeChangeEvents.d.ts +1 -1
  199. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  200. package/lib/simple-tree/api/treeNodeApi.d.ts +60 -1
  201. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  202. package/lib/simple-tree/api/treeNodeApi.js +66 -6
  203. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  204. package/lib/simple-tree/core/toStored.d.ts +7 -0
  205. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  206. package/lib/simple-tree/core/toStored.js.map +1 -1
  207. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +17 -3
  208. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  209. package/lib/simple-tree/core/unhydratedFlexTree.js +115 -13
  210. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  211. package/lib/simple-tree/fieldSchema.d.ts +6 -1
  212. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  213. package/lib/simple-tree/fieldSchema.js +3 -0
  214. package/lib/simple-tree/fieldSchema.js.map +1 -1
  215. package/lib/simple-tree/index.d.ts +2 -2
  216. package/lib/simple-tree/index.d.ts.map +1 -1
  217. package/lib/simple-tree/index.js +1 -1
  218. package/lib/simple-tree/index.js.map +1 -1
  219. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  220. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  221. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  222. package/lib/simple-tree/node-kinds/map/index.d.ts +1 -1
  223. package/lib/simple-tree/node-kinds/map/index.d.ts.map +1 -1
  224. package/lib/simple-tree/node-kinds/map/index.js.map +1 -1
  225. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  226. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  227. package/lib/simple-tree/node-kinds/map/mapNode.js +6 -1
  228. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  229. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +6 -6
  230. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  231. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  232. package/lib/simple-tree/simpleSchema.d.ts +17 -0
  233. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  234. package/lib/simple-tree/simpleSchema.js.map +1 -1
  235. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  236. package/lib/simple-tree/toStoredSchema.js +24 -2
  237. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  238. package/lib/tableSchema.d.ts +4 -5
  239. package/lib/tableSchema.d.ts.map +1 -1
  240. package/lib/tableSchema.js +12 -23
  241. package/lib/tableSchema.js.map +1 -1
  242. package/lib/text/textDomain.d.ts.map +1 -1
  243. package/lib/text/textDomain.js +29 -0
  244. package/lib/text/textDomain.js.map +1 -1
  245. package/lib/text/textDomainFormatted.d.ts +4 -4
  246. package/lib/tsdoc-metadata.json +1 -1
  247. package/lib/util/index.d.ts +1 -1
  248. package/lib/util/index.d.ts.map +1 -1
  249. package/lib/util/index.js +1 -1
  250. package/lib/util/index.js.map +1 -1
  251. package/lib/util/utils.d.ts +0 -1
  252. package/lib/util/utils.d.ts.map +1 -1
  253. package/lib/util/utils.js +0 -1
  254. package/lib/util/utils.js.map +1 -1
  255. package/package.json +30 -35
  256. package/src/api.ts +10 -0
  257. package/src/core/tree/anchorSet.ts +25 -0
  258. package/src/entrypoints/alpha.ts +20 -16
  259. package/src/entrypoints/beta.ts +7 -1
  260. package/src/entrypoints/legacy.ts +8 -10
  261. package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -2
  262. package/src/feature-libraries/chunked-forest/uniformChunk.ts +42 -20
  263. package/src/feature-libraries/indexing/anchorTreeIndex.ts +1 -0
  264. package/src/feature-libraries/indexing/types.ts +5 -3
  265. package/src/index.ts +4 -0
  266. package/src/packageVersion.ts +1 -1
  267. package/src/serializableDomainSchema.ts +6 -0
  268. package/src/shared-tree/treeAlpha.ts +6 -2
  269. package/src/simple-tree/api/discrepancies.ts +6 -1
  270. package/src/simple-tree/api/identifierIndex.ts +2 -2
  271. package/src/simple-tree/api/index.ts +4 -0
  272. package/src/simple-tree/api/schemaFactoryAlpha.ts +67 -2
  273. package/src/simple-tree/api/simpleTreeIndex.ts +6 -6
  274. package/src/simple-tree/api/storedSchema.ts +4 -1
  275. package/src/simple-tree/api/treeAlpha.ts +75 -12
  276. package/src/simple-tree/api/treeChangeEvents.ts +1 -1
  277. package/src/simple-tree/api/treeNodeApi.ts +101 -7
  278. package/src/simple-tree/core/toStored.ts +8 -0
  279. package/src/simple-tree/core/unhydratedFlexTree.ts +134 -10
  280. package/src/simple-tree/fieldSchema.ts +10 -0
  281. package/src/simple-tree/index.ts +5 -0
  282. package/src/simple-tree/node-kinds/index.ts +1 -0
  283. package/src/simple-tree/node-kinds/map/index.ts +1 -0
  284. package/src/simple-tree/node-kinds/map/mapNode.ts +20 -3
  285. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +6 -6
  286. package/src/simple-tree/simpleSchema.ts +20 -0
  287. package/src/simple-tree/toStoredSchema.ts +28 -1
  288. package/src/tableSchema.ts +16 -28
  289. package/src/text/textDomain.ts +68 -1
  290. package/src/util/index.ts +0 -1
  291. package/src/util/utils.ts +0 -2
  292. package/.mocharc.customBenchmarks.cjs +0 -25
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { RestrictiveStringRecord } from "../../util/index.js";
6
6
  import { type NodeKind, type TreeNodeSchemaClass, type ImplicitAllowedTypes, type WithType } from "../core/index.js";
7
- import { type FieldProps, type FieldSchemaAlpha, type FieldPropsAlpha, type FieldKind, type ImplicitFieldSchema, type InsertableTreeFieldFromImplicitField, type FieldSchema, type DefaultProvider } from "../fieldSchema.js";
7
+ import { type FieldProps, type FieldSchemaAlpha, type FieldPropsAlpha, FieldKind, type ImplicitFieldSchema, type InsertableTreeFieldFromImplicitField, type FieldSchema, type DefaultProvider } from "../fieldSchema.js";
8
8
  import type { LeafSchema } from "../leafNodeSchema.js";
9
9
  import { type ArrayNodeCustomizableSchemaAlpha, type MapNodeCustomizableSchema, type ObjectNodeSchema, type ObjectNodeSchemaWorkaround, type RecordNodeCustomizableSchema } from "../node-kinds/index.js";
10
10
  import type { SchemaType, SimpleObjectNodeSchema } from "../simpleSchema.js";
@@ -80,6 +80,27 @@ export interface SchemaStaticsAlpha {
80
80
  readonly withDefault: <Kind extends FieldKind, Types extends ImplicitAllowedTypes, TCustomMetadata = unknown>(fieldSchema: FieldSchema<Kind, Types, TCustomMetadata>, defaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>) => FieldSchemaAlpha<Kind, Types, TCustomMetadata, FieldPropsAlpha<TCustomMetadata> & {
81
81
  defaultProvider: DefaultProvider;
82
82
  }>;
83
+ /**
84
+ * Creates a field schema that is Optional in the view but behaves as Required in the stored schema
85
+ * during the rollout period of an optional-field migration.
86
+ *
87
+ * @remarks
88
+ * Use this to incrementally migrate a required field to optional without a coordinated deployment.
89
+ * The migration path is:
90
+ *
91
+ * 1. Start with `sf.required(T)` — all clients require the field.
92
+ * 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected). Writing `undefined` is blocked at runtime.
93
+ * 3. Deploy `sf.optional(T)` once all clients support the staged optional field — the stored schema becomes Optional and the field can be cleared.
94
+ *
95
+ * Analogous to {@link SchemaStaticsBeta.staged} for allowed types, but for field optionality.
96
+ *
97
+ * @param t - The types allowed under the field.
98
+ * @param props - Optional properties to associate with the field.
99
+ *
100
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
101
+ * See {@link FieldSchemaMetadata.custom}.
102
+ */
103
+ readonly stagedOptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider" | "stagedOptionalUpgrade">) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
83
104
  /**
84
105
  * {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.
85
106
  * Use with {@link ValidateRecursiveSchema} for improved type safety.
@@ -190,7 +211,15 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
190
211
  defaultProvider: DefaultProvider;
191
212
  }>;
192
213
  /**
193
- * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
214
+ * {@inheritdoc SchemaStaticsAlpha.stagedOptional}
215
+ */
216
+ readonly stagedOptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "stagedOptionalUpgrade" | "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
217
+ /**
218
+ * {@inheritdoc SchemaStaticsAlpha.stagedOptional}
219
+ */
220
+ static readonly stagedOptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "stagedOptionalUpgrade" | "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
221
+ /**
222
+ * Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.
194
223
  *
195
224
  * @param name - Unique identifier for this schema within this factory's scope.
196
225
  * @param allowedTypes - The types that may appear as values in the map.
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EAGb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,oCAAoC,E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AC9B,CAAC,EACD,IAAI,EACJ,eAAe,CACf;IAeD;;OAEG;IAEa,cAAc,CAC7B,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,0BAA0B,EACxD,KAAK,CAAC,eAAe,GAAG,OAAO,EAC9B,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC;IAYhF;;;;;;;;;;;OAWG;IACI,WAAW,CACjB,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,oBAAoB,EACpC,KAAK,CAAC,eAAe,GAAG,OAAO,EAE/B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,EACf,OAAO,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAC/C,4BAA4B,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC;IAUzF;;;;;;OAMG;IAEa,eAAe,CAC9B,IAAI,SAAS,KAAK,EAClB,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,0BAA0B,EACxD,KAAK,CAAC,eAAe,GAAG,OAAO,EAC9B,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC;;;IA8BhF;;OAEG;IACI,kBAAkB,CACxB,KAAK,CAAC,CAAC,SAAS,KAAK,EACrB,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAC1C,IAAI,EAAE,CAAC,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;CAGvE"}
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { normalizeAllowedTypes, isTreeNode, } from "../core/index.js";
5
+ import { normalizeAllowedTypes, isTreeNode, createSchemaUpgrade, } from "../core/index.js";
6
6
  // These imports prevent a large number of type references in the API reports from showing up as *_2.
7
7
  /* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */
8
- import { getDefaultProvider, createFieldSchema, } from "../fieldSchema.js";
8
+ import { FieldKind, getDefaultProvider, createFieldSchema, } from "../fieldSchema.js";
9
9
  import { arraySchema, mapSchema, objectSchema, recordSchema, } from "../node-kinds/index.js";
10
10
  import { unhydratedFlexTreeFromInsertableNode } from "../unhydratedFlexTreeFromInsertable.js";
11
11
  import { defaultSchemaFactoryObjectOptions, scoped, } from "./schemaFactory.js";
@@ -42,9 +42,17 @@ const withDefault = (fieldSchema, defaultValue) => {
42
42
  };
43
43
  return createFieldSchema(typedFieldSchema.kind, typedFieldSchema.allowedTypes, propsWithDefault);
44
44
  };
45
+ const stagedOptional = (t, props) => {
46
+ return createFieldSchema(FieldKind.Optional, t, {
47
+ defaultProvider: getDefaultProvider(() => []),
48
+ ...props,
49
+ stagedOptionalUpgrade: createSchemaUpgrade(),
50
+ });
51
+ };
45
52
  const schemaStaticsAlpha = {
46
53
  withDefault,
47
54
  withDefaultRecursive: withDefault,
55
+ stagedOptional,
48
56
  };
49
57
  /**
50
58
  * {@link SchemaFactory} with additional alpha APIs.
@@ -86,6 +94,10 @@ export class SchemaFactoryAlpha extends SchemaFactoryBeta {
86
94
  * {@inheritdoc SchemaStaticsAlpha.withDefault}
87
95
  */
88
96
  this.withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;
97
+ /**
98
+ * {@inheritdoc SchemaStaticsAlpha.stagedOptional}
99
+ */
100
+ this.stagedOptional = schemaStaticsAlpha.stagedOptional;
89
101
  }
90
102
  /**
91
103
  * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
@@ -117,7 +129,7 @@ export class SchemaFactoryAlpha extends SchemaFactoryBeta {
117
129
  return this.objectAlpha(name, t, options);
118
130
  }
119
131
  /**
120
- * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
132
+ * Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.
121
133
  *
122
134
  * @param name - Unique identifier for this schema within this factory's scope.
123
135
  * @param allowedTypes - The types that may appear as values in the map.
@@ -242,4 +254,8 @@ SchemaFactoryAlpha.withDefault = schemaStaticsAlpha.withDefault;
242
254
  * {@inheritdoc SchemaStaticsAlpha.withDefault}
243
255
  */
244
256
  SchemaFactoryAlpha.withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;
257
+ /**
258
+ * {@inheritdoc SchemaStaticsAlpha.stagedOptional}
259
+ */
260
+ SchemaFactoryAlpha.stagedOptional = schemaStaticsAlpha.stagedOptional;
245
261
  //# sourceMappingURL=schemaFactoryAlpha.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKN,qBAAqB,EACrB,UAAU,GACV,MAAM,kBAAkB,CAAC;AAC1B,qGAAqG;AACrG,gHAAgH;AAChH,OAAO,EAQN,kBAAkB,EAClB,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAGN,WAAW,EAEX,SAAS,EAGT,YAAY,EAEZ,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAE9F,OAAO,EACN,iCAAiC,EACjC,MAAM,GAIN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAuHzC,MAAM,WAAW,GAAG,CAKnB,WAAsD,EACtD,YAA0F,EAMzF,EAAE;IACH,MAA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Q,GAAG,aAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,aAAa,CAAC,UAAU,AAA3B,CAA4B;AAgC7D;;GAEG;AACoB,8BAAW,GAAG,kBAAkB,CAAC,WAAW,AAAjC,CAAkC;AAOpE;;GAEG;AACoB,uCAAoB,GAAG,kBAAkB,CAAC,oBAAoB,AAA1C,CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport {\n\ttype NodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype ImplicitAllowedTypes,\n\ttype WithType,\n\tnormalizeAllowedTypes,\n\tisTreeNode,\n} from \"../core/index.js\";\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\nimport {\n\ttype FieldProps,\n\ttype FieldSchemaAlpha,\n\ttype FieldPropsAlpha,\n\ttype FieldKind,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tgetDefaultProvider,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodeCustomizableSchemaAlpha,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaWorkaround,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport type { SchemaType, SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport { unhydratedFlexTreeFromInsertableNode } from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport { TreeBeta } from \"./treeBeta.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tInsertableObjectFromSchemaRecordAlphaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\n\n/**\n * A provider for values in tree nodes.\n *\n * @remarks\n * This type represents two ways to provide node values:\n *\n * 1. **A value**: Provide any value directly (number, string, object, array, etc.). When a value is provided,\n * the data is copied for each use to ensure independence between instances. The value must be of an allowed type for the field.\n *\n * 2. **A generator function**: A function that returns a value. The function is called each time a default is needed,\n * allowing for dynamic defaults or explicit control over value creation. The return value must be of an allowed type for the field.\n *\n * Values should be preferred over generator functions when possible, as they are simpler and more efficient.\n * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.\n *\n * @example\n * ```typescript\n * // Provide a value directly\n * factory.withDefault(factory.required(factory.string), \"default\")\n * factory.withDefault(factory.optional(Person), new Person({ name: \"Guest\" }))\n *\n * // Use a generator function\n * factory.withDefault(factory.required(factory.string), () => crypto.randomUUID())\n * factory.withDefault(factory.optional(Person), () => new Person({ name: \"Guest\" }))\n * ```\n *\n * @alpha @sealed\n */\nexport type NodeProvider<T> = T | (() => T);\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryBeta} as both instance properties and as statics.\n * @see {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,\n\t * allowing them to be omitted when creating new nodes.\n\t *\n\t * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)\n\t * @param defaultValue - A {@link NodeProvider} specifying the default value.\n\t *\n\t * @example\n\t * ```typescript\n\t * const MySchema = factory.objectAlpha(\"MyObject\", {\n\t * // Provide values directly\n\t * name: factory.withDefault(factory.required(factory.string), \"untitled\"),\n\t * count: factory.withDefault(factory.required(factory.number), 0),\n\t * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),\n\t *\n\t * // Use generator functions for dynamic values\n\t * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),\n\t * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),\n\t * });\n\t *\n\t * const obj1 = new MySchema({}); // All defaults applied\n\t * const obj2 = new MySchema({ name: \"custom\" }); // name=\"custom\", other defaults applied\n\t * ```\n\t *\n\t * @privateRemarks\n\t * This function wraps an existing field schema and adds a default value provider to it.\n\t * The default value will be used when constructing nodes if the field is not explicitly provided or set to `undefined`.\n\t *\n\t * Defaults are evaluated eagerly during node construction, unlike identifier defaults which require context.\n\t */\n\treadonly withDefault: <\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n\t) => FieldSchemaAlpha<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n\t/**\n\t * {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\twithDefaultRecursive: <\n\t\tKind extends FieldKind,\n\t\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: Unenforced<\n\t\t\tNodeProvider<\n\t\t\t\tSystem_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\t\t\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types>\n\t\t\t\t>\n\t\t\t>\n\t\t>,\n\t) => FieldSchemaAlphaUnsafe<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n}\n\nconst withDefault = <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n): FieldSchemaAlpha<\n\tKind,\n\tTypes,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n> => {\n\tconst typedFieldSchema = fieldSchema as FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n\t// create the default provider function, it is called eagerly during node construction\n\tconst defaultProvider = getDefaultProvider(() => {\n\t\t// Resolve the value: if it's a function, call it; otherwise use it directly\n\t\tlet insertableValue =\n\t\t\ttypeof defaultValue === \"function\" ? (defaultValue as () => unknown)() : defaultValue;\n\n\t\t// If the value is an already-constructed TreeNode (e.g., from a generator function that\n\t\t// returns the same instance repeatedly), clone it to ensure each use gets a fresh instance.\n\t\t// This prevents multi-parenting errors.\n\t\tif (isTreeNode(insertableValue)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tinsertableValue = TreeBeta.clone(insertableValue as any);\n\t\t}\n\n\t\t// For optional fields with an undefined default, return an empty array (no value).\n\t\tif (insertableValue === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Convert the insertable value to an unhydrated flex tree.\n\t\t// For insertable data, this creates a fresh tree structure.\n\t\tconst allowedTypeSet = normalizeAllowedTypes(typedFieldSchema.allowedTypes).evaluateSet();\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn [unhydratedFlexTreeFromInsertableNode(insertableValue as any, allowedTypeSet)];\n\t});\n\n\t// create a new field schema with the default provider\n\tconst propsWithDefault = {\n\t\t...typedFieldSchema.props,\n\t\tdefaultProvider,\n\t};\n\n\treturn createFieldSchema(\n\t\ttypedFieldSchema.kind,\n\t\ttypedFieldSchema.allowedTypes,\n\t\tpropsWithDefault,\n\t);\n};\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\twithDefault,\n\n\twithDefaultRecursive: withDefault as SchemaStaticsAlpha[\"withDefaultRecursive\"],\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchemaWorkaround<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...options,\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * Alpha version of {@link SchemaFactory.objectRecursive} that supports field defaults via {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * Use this instead of {@link SchemaFactory.objectRecursive} when fields use {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic objectRecursiveAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchemaAlpha<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tT,\n\t\ttrue,\n\t\tTCustomMetadata\n\t> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions ?? {},\n\t\t) as unknown as ArrayNodeCustomizableSchemaAlpha<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\ttrue,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tnodeOptions: options,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKN,qBAAqB,EACrB,UAAU,EACV,mBAAmB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,qGAAqG;AACrG,gHAAgH;AAChH,OAAO,EAIN,SAAS,EAIT,kBAAkB,EAClB,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAGN,WAAW,EAEX,SAAS,EAGT,YAAY,EAEZ,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAE9F,OAAO,EACN,iCAAiC,EACjC,MAAM,GAIN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AA2JzC,MAAM,WAAW,GAAG,CAKnB,WAAsD,EACtD,YAA0F,EAMzF,EAAE;IACH,MAAM,gBAAgB,GAAG,WAA6D,CAAC;IAEvF,sFAAsF;IACtF,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,EAAE;QAC/C,4EAA4E;QAC5E,IAAI,eAAe,GAClB,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAE,YAA8B,EAAE,CAAC,C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AAmB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;;AArRD;;GAEG;AAC6B,yBAAM,GAAG,aAAa,CAAC,MAAM,AAAvB,CAAwB;AAE9D;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,aAAa,CAAC,UAAU,AAA3B,CAA4B;AAgC7D;;GAEG;AACoB,8BAAW,GAAG,kBAAkB,CAAC,WAAW,AAAjC,CAAkC;AAOpE;;GAEG;AACoB,uCAAoB,GAAG,kBAAkB,CAAC,oBAAoB,AAA1C,CAA2C;AAOtF;;GAEG;AACoB,iCAAc,GAAG,kBAAkB,CAAC,cAAc,AAApC,CAAqC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport {\n\ttype NodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype ImplicitAllowedTypes,\n\ttype WithType,\n\tnormalizeAllowedTypes,\n\tisTreeNode,\n\tcreateSchemaUpgrade,\n} from \"../core/index.js\";\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\nimport {\n\ttype FieldProps,\n\ttype FieldSchemaAlpha,\n\ttype FieldPropsAlpha,\n\tFieldKind,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tgetDefaultProvider,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodeCustomizableSchemaAlpha,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaWorkaround,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport type { SchemaType, SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport { unhydratedFlexTreeFromInsertableNode } from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport { TreeBeta } from \"./treeBeta.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tInsertableObjectFromSchemaRecordAlphaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\n\n/**\n * A provider for values in tree nodes.\n *\n * @remarks\n * This type represents two ways to provide node values:\n *\n * 1. **A value**: Provide any value directly (number, string, object, array, etc.). When a value is provided,\n * the data is copied for each use to ensure independence between instances. The value must be of an allowed type for the field.\n *\n * 2. **A generator function**: A function that returns a value. The function is called each time a default is needed,\n * allowing for dynamic defaults or explicit control over value creation. The return value must be of an allowed type for the field.\n *\n * Values should be preferred over generator functions when possible, as they are simpler and more efficient.\n * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.\n *\n * @example\n * ```typescript\n * // Provide a value directly\n * factory.withDefault(factory.required(factory.string), \"default\")\n * factory.withDefault(factory.optional(Person), new Person({ name: \"Guest\" }))\n *\n * // Use a generator function\n * factory.withDefault(factory.required(factory.string), () => crypto.randomUUID())\n * factory.withDefault(factory.optional(Person), () => new Person({ name: \"Guest\" }))\n * ```\n *\n * @alpha @sealed\n */\nexport type NodeProvider<T> = T | (() => T);\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryBeta} as both instance properties and as statics.\n * @see {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,\n\t * allowing them to be omitted when creating new nodes.\n\t *\n\t * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)\n\t * @param defaultValue - A {@link NodeProvider} specifying the default value.\n\t *\n\t * @example\n\t * ```typescript\n\t * const MySchema = factory.objectAlpha(\"MyObject\", {\n\t * // Provide values directly\n\t * name: factory.withDefault(factory.required(factory.string), \"untitled\"),\n\t * count: factory.withDefault(factory.required(factory.number), 0),\n\t * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),\n\t *\n\t * // Use generator functions for dynamic values\n\t * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),\n\t * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),\n\t * });\n\t *\n\t * const obj1 = new MySchema({}); // All defaults applied\n\t * const obj2 = new MySchema({ name: \"custom\" }); // name=\"custom\", other defaults applied\n\t * ```\n\t *\n\t * @privateRemarks\n\t * This function wraps an existing field schema and adds a default value provider to it.\n\t * The default value will be used when constructing nodes if the field is not explicitly provided or set to `undefined`.\n\t *\n\t * Defaults are evaluated eagerly during node construction, unlike identifier defaults which require context.\n\t */\n\treadonly withDefault: <\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n\t) => FieldSchemaAlpha<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n\t/**\n\t * Creates a field schema that is Optional in the view but behaves as Required in the stored schema\n\t * during the rollout period of an optional-field migration.\n\t *\n\t * @remarks\n\t * Use this to incrementally migrate a required field to optional without a coordinated deployment.\n\t * The migration path is:\n\t *\n\t * 1. Start with `sf.required(T)` — all clients require the field.\n\t * 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected). Writing `undefined` is blocked at runtime.\n\t * 3. Deploy `sf.optional(T)` once all clients support the staged optional field — the stored schema becomes Optional and the field can be cleared.\n\t *\n\t * Analogous to {@link SchemaStaticsBeta.staged} for allowed types, but for field optionality.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly stagedOptional: <\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<\n\t\t\tFieldPropsAlpha<TCustomMetadata>,\n\t\t\t\"defaultProvider\" | \"stagedOptionalUpgrade\"\n\t\t>,\n\t) => FieldSchemaAlpha<\n\t\tFieldKind.Optional,\n\t\tT,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata>\n\t>;\n\n\t/**\n\t * {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\twithDefaultRecursive: <\n\t\tKind extends FieldKind,\n\t\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: Unenforced<\n\t\t\tNodeProvider<\n\t\t\t\tSystem_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\t\t\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types>\n\t\t\t\t>\n\t\t\t>\n\t\t>,\n\t) => FieldSchemaAlphaUnsafe<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n}\n\nconst withDefault = <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n): FieldSchemaAlpha<\n\tKind,\n\tTypes,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n> => {\n\tconst typedFieldSchema = fieldSchema as FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n\t// create the default provider function, it is called eagerly during node construction\n\tconst defaultProvider = getDefaultProvider(() => {\n\t\t// Resolve the value: if it's a function, call it; otherwise use it directly\n\t\tlet insertableValue =\n\t\t\ttypeof defaultValue === \"function\" ? (defaultValue as () => unknown)() : defaultValue;\n\n\t\t// If the value is an already-constructed TreeNode (e.g., from a generator function that\n\t\t// returns the same instance repeatedly), clone it to ensure each use gets a fresh instance.\n\t\t// This prevents multi-parenting errors.\n\t\tif (isTreeNode(insertableValue)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tinsertableValue = TreeBeta.clone(insertableValue as any);\n\t\t}\n\n\t\t// For optional fields with an undefined default, return an empty array (no value).\n\t\tif (insertableValue === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Convert the insertable value to an unhydrated flex tree.\n\t\t// For insertable data, this creates a fresh tree structure.\n\t\tconst allowedTypeSet = normalizeAllowedTypes(typedFieldSchema.allowedTypes).evaluateSet();\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn [unhydratedFlexTreeFromInsertableNode(insertableValue as any, allowedTypeSet)];\n\t});\n\n\t// create a new field schema with the default provider\n\tconst propsWithDefault = {\n\t\t...typedFieldSchema.props,\n\t\tdefaultProvider,\n\t};\n\n\treturn createFieldSchema(\n\t\ttypedFieldSchema.kind,\n\t\ttypedFieldSchema.allowedTypes,\n\t\tpropsWithDefault,\n\t);\n};\n\nconst stagedOptional = <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\" | \"stagedOptionalUpgrade\">,\n): FieldSchemaAlpha<\n\tFieldKind.Optional,\n\tT,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata>\n> => {\n\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\tdefaultProvider: getDefaultProvider(() => []),\n\t\t...props,\n\t\tstagedOptionalUpgrade: createSchemaUpgrade(),\n\t});\n};\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\twithDefault,\n\n\twithDefaultRecursive: withDefault as SchemaStaticsAlpha[\"withDefaultRecursive\"],\n\n\tstagedOptional,\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchemaWorkaround<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...options,\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * Alpha version of {@link SchemaFactory.objectRecursive} that supports field defaults via {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * Use this instead of {@link SchemaFactory.objectRecursive} when fields use {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic objectRecursiveAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic static readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchemaAlpha<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tT,\n\t\ttrue,\n\t\tTCustomMetadata\n\t> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions ?? {},\n\t\t) as unknown as ArrayNodeCustomizableSchemaAlpha<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\ttrue,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tnodeOptions: options,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
@@ -11,7 +11,7 @@ import type { TreeView } from "./tree.js";
11
11
  * @remarks
12
12
  * This supports values which have value semantics and are compared by value, just like {@link TreeLeafValue}.
13
13
  * This allows using any tree value as a key (for example in an index tracking where those values occur in the tree).
14
- * @alpha
14
+ * @beta
15
15
  */
16
16
  export type TreeIndexKey = TreeLeafValue;
17
17
  /**
@@ -23,7 +23,7 @@ export type TreeIndexKey = TreeLeafValue;
23
23
  * @param getValue - given at least one {@link TreeNode}, returns an associated value
24
24
  * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer
25
25
  *
26
- * @alpha
26
+ * @beta
27
27
  */
28
28
  export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: (schema: TreeNodeSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): TreeIndex<TKey, TValue>;
29
29
  /**
@@ -36,7 +36,7 @@ export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema
36
36
  * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer
37
37
  * @param indexableSchema - a list of all the schema types that can be indexed
38
38
  *
39
- * @alpha
39
+ * @beta
40
40
  */
41
41
  export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: (schema: TSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): TreeIndex<TKey, TValue>;
42
42
  /**
@@ -48,7 +48,7 @@ export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema
48
48
  * @param getValue - given at least one {@link TreeNode}, returns an associated value
49
49
  * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer
50
50
  *
51
- * @alpha
51
+ * @beta
52
52
  */
53
53
  export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): TreeIndex<TKey, TValue>;
54
54
  /**
@@ -61,7 +61,7 @@ export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema
61
61
  * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer
62
62
  * @param indexableSchema - a list of all the schema types that can be indexed
63
63
  *
64
- * @alpha
64
+ * @beta
65
65
  */
66
66
  export declare function createTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): TreeIndex<TKey, TValue>;
67
67
  //# sourceMappingURL=simpleTreeIndex.d.ts.map
@@ -11,7 +11,7 @@ import { treeNodeApi } from "./treeNodeApi.js";
11
11
  /**
12
12
  * Creates a {@link TreeIndex} with a specified indexer.
13
13
  *
14
- * @alpha
14
+ * @beta
15
15
  */
16
16
  export function createTreeIndex(view, indexer, getValue, isKeyValid, indexableSchema) {
17
17
  const indexableSchemaMap = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"simpleTreeIndex.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAQ3D,OAAO,EACN,eAAe,EACf,WAAW,EAEX,UAAU,GAGV,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,kBAAkB,GAKlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyG/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAK9B,IAA4B,EAC5B,OAAuF,EACvF,QAEsE,EACtE,UAA8C,EAC9C,eAA2C;IAE3C,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC7D,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QACnC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC;SACtE,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACP,KAA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K,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type {\n\tAnchorNode,\n\tFieldKey,\n\tITreeSubscriptionCursor,\n\tTreeNodeSchemaIdentifier,\n} from \"../../core/index.js\";\nimport {\n\tAnchorTreeIndex,\n\tisTreeValue,\n\ttype TreeIndexNodes,\n\thasElement,\n\ttype TreeIndex,\n\ttype KeyFinder,\n} from \"../../feature-libraries/index.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\ttreeNodeFromAnchor,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n\ttype TreeLeafValue,\n} from \"../core/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\n\nimport type { TreeView } from \"./tree.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\n\n/**\n * Value that may be used as keys in a {@link TreeIndex}.\n * @remarks\n * This supports values which have value semantics and are compared by value, just like {@link TreeLeafValue}.\n * This allows using any tree value as a key (for example in an index tracking where those values occur in the tree).\n * @alpha\n */\nexport type TreeIndexKey = TreeLeafValue;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TreeNodeSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @alpha\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: ((schema: TreeNodeSchema) => string | undefined) | Map<TreeNodeSchema, string>,\n\tgetValue:\n\t\t| ((nodes: TreeIndexNodes<TreeNode>) => TValue)\n\t\t| ((nodes: TreeIndexNodes<NodeFromSchema<TreeNodeSchema>>) => TValue),\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema?: readonly TreeNodeSchema[],\n): TreeIndex<TKey, TValue> {\n\tconst indexableSchemaMap = new Map<string, TreeNodeSchema>();\n\tif (indexableSchema === undefined) {\n\t\twalkFieldSchema(view.schema, {\n\t\t\tnode: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),\n\t\t});\n\t} else {\n\t\tfor (const schemus of indexableSchema) {\n\t\t\tindexableSchemaMap.set(schemus.identifier, schemus);\n\t\t}\n\t}\n\n\tconst schemaIndexer =\n\t\tindexableSchema === undefined\n\t\t\t? (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\t// if indexable schema isn't provided, we check if the node is in schema\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus === undefined) {\n\t\t\t\t\t\tfail(0xb32 /* node is out of schema */);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t: (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus !== undefined) {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\tconst index = new AnchorTreeIndex<TKey, TValue>(\n\t\t(view as SchematizingSimpleTreeView<TFieldSchema>).checkout.forest,\n\t\tschemaIndexer,\n\t\t(anchorNodes) => {\n\t\t\tconst simpleTreeNodes: TreeNode[] = [];\n\t\t\tfor (const anchorNode of anchorNodes) {\n\t\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\t\tsimpleTreeNodes.push(simpleTree);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasElement(simpleTreeNodes)) {\n\t\t\t\treturn getValue(simpleTreeNodes);\n\t\t\t}\n\t\t},\n\t\t(anchorNode: AnchorNode) => {\n\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\treturn treeNodeApi.status(simpleTree);\n\t\t\t}\n\t\t},\n\t\t// simple tree indexes are shallow indexes, indicating so allows for a performance optimization\n\t\ttrue,\n\t);\n\n\t// all the type checking guarantees that we put nodes of the correct type in the index\n\t// but it's not captured in the type system\n\treturn index as TreeIndex<TKey, TValue>;\n}\n\nfunction makeGenericKeyFinder<TKey extends TreeIndexKey>(\n\tkeyField: FieldKey,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): KeyFinder<TKey> {\n\treturn (cursor: ITreeSubscriptionCursor) => {\n\t\tcursor.enterField(keyField);\n\t\tcursor.firstNode();\n\t\tconst value = cursor.value;\n\t\tcursor.exitNode();\n\t\tcursor.exitField();\n\n\t\tif (value === undefined) {\n\t\t\tfail(0xb33 /* a value for the key does not exist */);\n\t\t}\n\n\t\tif (!isKeyValid(value)) {\n\t\t\tfail(0xb34 /* the key is an unexpected type */);\n\t\t}\n\n\t\treturn value;\n\t};\n}\n"]}
1
+ {"version":3,"file":"simpleTreeIndex.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAQ3D,OAAO,EACN,eAAe,EACf,WAAW,EAEX,UAAU,GAGV,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACN,kBAAkB,GAKlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyG/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAK9B,IAA4B,EAC5B,OAAuF,EACvF,QAEsE,EACtE,UAA8C,EAC9C,eAA2C;IAE3C,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA0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,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,SAAS,EAAE,CAAC;QAEnB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type {\n\tAnchorNode,\n\tFieldKey,\n\tITreeSubscriptionCursor,\n\tTreeNodeSchemaIdentifier,\n} from \"../../core/index.js\";\nimport {\n\tAnchorTreeIndex,\n\tisTreeValue,\n\ttype TreeIndexNodes,\n\thasElement,\n\ttype TreeIndex,\n\ttype KeyFinder,\n} from \"../../feature-libraries/index.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\ttreeNodeFromAnchor,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n\ttype TreeLeafValue,\n} from \"../core/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\n\nimport type { TreeView } from \"./tree.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\n\n/**\n * Value that may be used as keys in a {@link TreeIndex}.\n * @remarks\n * This supports values which have value semantics and are compared by value, just like {@link TreeLeafValue}.\n * This allows using any tree value as a key (for example in an index tracking where those values occur in the tree).\n * @beta\n */\nexport type TreeIndexKey = TreeLeafValue;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @beta\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TreeNodeSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @beta\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @beta\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @beta\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link TreeIndex} with a specified indexer.\n *\n * @beta\n */\nexport function createTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: ((schema: TreeNodeSchema) => string | undefined) | Map<TreeNodeSchema, string>,\n\tgetValue:\n\t\t| ((nodes: TreeIndexNodes<TreeNode>) => TValue)\n\t\t| ((nodes: TreeIndexNodes<NodeFromSchema<TreeNodeSchema>>) => TValue),\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema?: readonly TreeNodeSchema[],\n): TreeIndex<TKey, TValue> {\n\tconst indexableSchemaMap = new Map<string, TreeNodeSchema>();\n\tif (indexableSchema === undefined) {\n\t\twalkFieldSchema(view.schema, {\n\t\t\tnode: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),\n\t\t});\n\t} else {\n\t\tfor (const schemus of indexableSchema) {\n\t\t\tindexableSchemaMap.set(schemus.identifier, schemus);\n\t\t}\n\t}\n\n\tconst schemaIndexer =\n\t\tindexableSchema === undefined\n\t\t\t? (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\t// if indexable schema isn't provided, we check if the node is in schema\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus === undefined) {\n\t\t\t\t\t\tfail(0xb32 /* node is out of schema */);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t: (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus !== undefined) {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\tconst index = new AnchorTreeIndex<TKey, TValue>(\n\t\t(view as SchematizingSimpleTreeView<TFieldSchema>).checkout.forest,\n\t\tschemaIndexer,\n\t\t(anchorNodes) => {\n\t\t\tconst simpleTreeNodes: TreeNode[] = [];\n\t\t\tfor (const anchorNode of anchorNodes) {\n\t\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\t\tsimpleTreeNodes.push(simpleTree);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasElement(simpleTreeNodes)) {\n\t\t\t\treturn getValue(simpleTreeNodes);\n\t\t\t}\n\t\t},\n\t\t(anchorNode: AnchorNode) => {\n\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\treturn treeNodeApi.status(simpleTree);\n\t\t\t}\n\t\t},\n\t\t// simple tree indexes are shallow indexes, indicating so allows for a performance optimization\n\t\ttrue,\n\t);\n\n\t// all the type checking guarantees that we put nodes of the correct type in the index\n\t// but it's not captured in the type system\n\treturn index as TreeIndex<TKey, TValue>;\n}\n\nfunction makeGenericKeyFinder<TKey extends TreeIndexKey>(\n\tkeyField: FieldKey,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): KeyFinder<TKey> {\n\treturn (cursor: ITreeSubscriptionCursor) => {\n\t\tcursor.enterField(keyField);\n\t\tcursor.firstNode();\n\t\tconst value = cursor.value;\n\t\tcursor.exitNode();\n\t\tcursor.exitField();\n\n\t\tif (value === undefined) {\n\t\t\tfail(0xb33 /* a value for the key does not exist */);\n\t\t}\n\n\t\tif (!isKeyValid(value)) {\n\t\t\tfail(0xb34 /* the key is an unexpected type */);\n\t\t}\n\n\t\treturn value;\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;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sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAQlD"}
@@ -41,7 +41,10 @@ import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
41
41
  * @alpha
42
42
  */
43
43
  export function extractPersistedSchema(schema, minVersionForCollab, includeStaged) {
44
- const stored = toStoredSchema(schema, { includeStaged });
44
+ const stored = toStoredSchema(schema, {
45
+ includeStaged,
46
+ includeStagedOptional: includeStaged,
47
+ });
45
48
  const codec = schemaCodecBuilder.build({
46
49
  minVersionForCollab,
47
50
  jsonValidator: FormatValidatorNoOp,
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAsB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,mBAA4C,EAC5C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;QACtC,mBAAmB;QACnB,aAAa,EAAE,mBAAmB;KAClC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAmB,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,MAAM,WAAW,GAAG,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { FormatValidatorNoOp, type ICodecOptions } from \"../../codec/index.js\";\nimport { schemaCodecBuilder } from \"../../feature-libraries/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\n\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst codec = schemaCodecBuilder.build({\n\t\tminVersionForCollab,\n\t\tjsonValidator: FormatValidatorNoOp,\n\t});\n\treturn codec.encode(stored) as JsonCompatible;\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\tconst stored = schemaCodec.decode(persisted);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
1
+ {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAsB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,mBAA4C,EAC5C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE;QACrC,aAAa;QACb,qBAAqB,EAAE,aAAa;KACpC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;QACtC,mBAAmB;QACnB,aAAa,EAAE,mBAAmB;KAClC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAmB,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,MAAM,WAAW,GAAG,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { FormatValidatorNoOp, type ICodecOptions } from \"../../codec/index.js\";\nimport { schemaCodecBuilder } from \"../../feature-libraries/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\n\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, {\n\t\tincludeStaged,\n\t\tincludeStagedOptional: includeStaged,\n\t});\n\tconst codec = schemaCodecBuilder.build({\n\t\tminVersionForCollab,\n\t\tjsonValidator: FormatValidatorNoOp,\n\t});\n\treturn codec.encode(stored) as JsonCompatible;\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\tconst stored = schemaCodec.decode(persisted);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
@@ -3,9 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { NodeKind, TreeNode, WithType } from "../core/index.js";
6
+ import type { TreeChangeEventsBeta } from "./treeBeta.js";
6
7
  import type { TreeChangeEvents } from "./treeChangeEvents.js";
7
- export type { ArrayNodeDeltaOp, ArrayNodeInsertOp, ArrayNodeRemoveOp, ArrayNodeRetainOp, } from "./treeNodeApi.js";
8
- import type { ArrayNodeDeltaOp } from "./treeNodeApi.js";
8
+ import type { ArrayNodeDeltaOp, ArrayNodeTreeChangedDeltaOp } from "./treeNodeApi.js";
9
+ export type { ArrayNodeDeltaOp, ArrayNodeInsertOp, ArrayNodeRemoveOp, ArrayNodeRetainOp, ArrayNodeTreeChangedDeltaOp, ArrayNodeTreeChangedRetainOp, } from "./treeNodeApi.js";
9
10
  /**
10
11
  * Data included for {@link TreeChangeEventsAlpha.nodeChanged} when the node is an object, map, or record node.
11
12
  * @sealed @alpha
@@ -21,25 +22,45 @@ export interface NodeChangedDataProperties<TNode extends TreeNode = TreeNode> {
21
22
  readonly changedProperties: ReadonlySet<TNode extends WithType<string, NodeKind.Object, infer TInfo> ? string & keyof TInfo : string>;
22
23
  }
23
24
  /**
24
- * Data included for {@link TreeChangeEventsAlpha.nodeChanged} when the node is an array node.
25
+ * Data carried by the {@link TreeChangeEventsAlpha.nodeChanged} event for array nodes.
25
26
  * @sealed @alpha
26
27
  */
27
28
  export interface NodeChangedDataDelta {
28
29
  /**
29
30
  * The sequential operations describing what changed in the array node.
30
31
  * @remarks
31
- * The value may be `undefined` in two cases:
32
- * - The node was created locally and has not yet been inserted into a document tree (a known
33
- * temporary limitation, tracked in AB#63261).
34
- * - The document was updated in a way that required multiple internal change passes in a single
35
- * operation (for example, a data change combined with a schema upgrade).
32
+ * The value may be `undefined` when the document was updated in a way that required multiple
33
+ * internal change passes in a single operation (for example, a data change combined with a
34
+ * schema upgrade).
36
35
  *
37
36
  * See {@link ArrayNodeDeltaOp} for op semantics.
38
37
  */
39
38
  readonly delta: readonly ArrayNodeDeltaOp[] | undefined;
40
39
  }
41
40
  /**
42
- * The data passed to {@link TreeChangeEventsAlpha.nodeChanged}.
41
+ * Data carried by the {@link TreeChangeEventsAlpha.treeChanged} event for array nodes.
42
+ * @remarks
43
+ * Extends {@link NodeChangedDataDelta}: the retain ops in the delta additionally carry a
44
+ * {@link ArrayNodeTreeChangedRetainOp.subtreeChanged} flag indicating whether any descendant
45
+ * of the retained element changed.
46
+ * @sealed @alpha
47
+ */
48
+ export interface NodeChangedDataTreeDelta {
49
+ /**
50
+ * The sequential operations describing what changed in the array node,
51
+ * including subtree-change information on retain ops.
52
+ * @remarks
53
+ * The value may be `undefined` when the document was updated in a way that required multiple
54
+ * internal change passes in a single operation (for example, a data change combined with a
55
+ * schema upgrade).
56
+ *
57
+ * See {@link ArrayNodeTreeChangedDeltaOp} for op semantics.
58
+ */
59
+ readonly delta: readonly ArrayNodeTreeChangedDeltaOp[] | undefined;
60
+ }
61
+ /**
62
+ * The data passed to {@link TreeChangeEventsAlpha.nodeChanged} and, for array nodes,
63
+ * to {@link TreeChangeEventsAlpha.treeChanged}.
43
64
  * @remarks
44
65
  * - For array nodes: {@link NodeChangedDataDelta} (includes a {@link NodeChangedDataDelta.delta | delta} payload).
45
66
  * - For object, map, and record nodes: {@link NodeChangedDataProperties} (includes {@link NodeChangedDataProperties.changedProperties | changedProperties}).
@@ -48,22 +69,58 @@ export interface NodeChangedDataDelta {
48
69
  */
49
70
  export type NodeChangedDataAlpha<TNode extends TreeNode = TreeNode> = TNode extends WithType<string, NodeKind.Array> ? NodeChangedDataDelta : TNode extends WithType<string, NodeKind.Map | NodeKind.Object | NodeKind.Record> ? NodeChangedDataProperties<TNode> : NodeChangedDataProperties<TNode> | NodeChangedDataDelta;
50
71
  /**
51
- * Extension of {@link TreeChangeEvents} with a richer `nodeChanged` event.
72
+ * Extension of {@link TreeChangeEvents} with a richer `nodeChanged` event and a
73
+ * delta-carrying `treeChanged` event for array nodes.
52
74
  * @remarks
53
75
  * Provides a `nodeChanged` event that includes a delta payload for array nodes and
54
76
  * requires `changedProperties` for object, map, and record nodes.
77
+ * Also provides a `treeChanged` event that, for array nodes, carries a {@link NodeChangedDataDelta}
78
+ * payload describing both shallow and deep changes.
79
+ * For non-array nodes, the `treeChanged` signature is the same as the base event.
80
+ *
55
81
  * Use via `TreeAlpha.on`.
56
82
  * @sealed @alpha
57
83
  */
58
84
  export interface TreeChangeEventsAlpha<TNode extends TreeNode = TreeNode> extends TreeChangeEvents {
59
85
  /**
60
- * Like `TreeChangeEventsBeta.nodeChanged`, but for array nodes the event data includes
61
- * a {@link NodeChangedDataDelta.delta | delta} payload describing the changes as a sequence
62
- * of {@link ArrayNodeDeltaOp} values.
86
+ * Emitted when a shallow change occurs on this node, i.e., when the node's direct children change.
63
87
  *
64
88
  * @remarks
89
+ * For array nodes: the event data includes a {@link NodeChangedDataDelta.delta | delta} payload
90
+ * as a sequence of {@link ArrayNodeDeltaOp} values. Does not fire for deep changes (e.g. a
91
+ * property of an array element changed without any shallow array change). Subscribe to
92
+ * {@link TreeChangeEventsAlpha.treeChanged} on the array to receive a delta for those cases as well.
93
+ *
94
+ * For object, map, and record nodes: the event data includes
95
+ * {@link NodeChangedDataProperties.changedProperties | changedProperties}.
96
+ * @privateRemarks
65
97
  * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.
66
98
  */
67
99
  nodeChanged: (data: NodeChangedDataAlpha<TNode>) => void;
100
+ /**
101
+ * Emitted when something in the subtree rooted at this node changes.
102
+ *
103
+ * @remarks
104
+ * For array nodes: emitted when any change occurred within the array, including both
105
+ * shallow changes (insert, remove, move) and deep changes (e.g. a property of an element
106
+ * changed). The event data carries a {@link NodeChangedDataTreeDelta.delta | delta} payload
107
+ * describing what changed. The delta uses {@link ArrayNodeTreeChangedRetainOp.subtreeChanged}
108
+ * to flag elements that have deep changes, without describing the details of those deep changes.
109
+ * To inspect deep changes, subscribe to `nodeChanged` or `treeChanged` on the individual
110
+ * element nodes.
111
+ *
112
+ * When this array is nested inside another array, the outer array's `treeChanged` still
113
+ * fires with a delta, but that delta only shows `subtreeChanged: true` for the element
114
+ * position containing this inner array — it does not include the inner array's detailed
115
+ * insert/remove/retain ops. To receive those detailed ops, subscribe to `treeChanged`
116
+ * directly on the inner array.
117
+ * Ancestor non-array nodes still receive the base (no-payload) `treeChanged` via normal
118
+ * subtree propagation.
119
+ *
120
+ * For non-array nodes: same as the base {@link TreeChangeEvents.treeChanged}.
121
+ * @privateRemarks
122
+ * This defines a property which is a function instead of using the method syntax to avoid function bi-variance issues with the input data to the callback.
123
+ */
124
+ treeChanged: TNode extends WithType<string, NodeKind.Array> ? (data: NodeChangedDataTreeDelta) => void : TreeChangeEventsBeta<TNode>["treeChanged"];
68
125
  }
69
126
  //# sourceMappingURL=treeAlpha.d.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