@fluidframework/tree 2.81.0 → 2.82.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 (579) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/api-report/tree.alpha.api.md +54 -22
  3. package/api-report/tree.beta.api.md +150 -1
  4. package/api-report/tree.legacy.beta.api.md +150 -1
  5. package/api-report/tree.legacy.public.api.md +1 -0
  6. package/api-report/tree.public.api.md +1 -0
  7. package/dist/alpha.d.ts +8 -2
  8. package/dist/beta.d.ts +3 -0
  9. package/dist/codec/codec.d.ts +17 -8
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +8 -1
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/codec/versioned/codec.d.ts +1 -1
  18. package/dist/codec/versioned/codec.d.ts.map +1 -1
  19. package/dist/codec/versioned/codec.js.map +1 -1
  20. package/dist/core/index.d.ts +1 -1
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +4 -2
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/rebase/changeRebaser.d.ts +3 -2
  25. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  26. package/dist/core/rebase/changeRebaser.js.map +1 -1
  27. package/dist/core/rebase/index.d.ts +1 -1
  28. package/dist/core/rebase/index.d.ts.map +1 -1
  29. package/dist/core/rebase/index.js +4 -2
  30. package/dist/core/rebase/index.js.map +1 -1
  31. package/dist/core/rebase/types.d.ts +23 -3
  32. package/dist/core/rebase/types.d.ts.map +1 -1
  33. package/dist/core/rebase/types.js +30 -16
  34. package/dist/core/rebase/types.js.map +1 -1
  35. package/dist/core/schema-stored/formatV1.d.ts +2 -2
  36. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  37. package/dist/core/schema-stored/formatV1.js +0 -5
  38. package/dist/core/schema-stored/formatV1.js.map +1 -1
  39. package/dist/core/schema-stored/formatV2.d.ts +11 -10
  40. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  41. package/dist/core/schema-stored/formatV2.js +1 -6
  42. package/dist/core/schema-stored/formatV2.js.map +1 -1
  43. package/dist/core/schema-stored/index.d.ts.map +1 -1
  44. package/dist/core/schema-stored/index.js.map +1 -1
  45. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  46. package/dist/core/schema-stored/schema.js.map +1 -1
  47. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  48. package/dist/core/tree/anchorSet.js.map +1 -1
  49. package/dist/core/tree/delta.d.ts +9 -7
  50. package/dist/core/tree/delta.d.ts.map +1 -1
  51. package/dist/core/tree/delta.js.map +1 -1
  52. package/dist/core/tree/deltaUtil.js +1 -1
  53. package/dist/core/tree/deltaUtil.js.map +1 -1
  54. package/dist/core/tree/visitDelta.js +2 -2
  55. package/dist/core/tree/visitDelta.js.map +1 -1
  56. package/dist/extensibleSchemaUnion.d.ts +72 -0
  57. package/dist/extensibleSchemaUnion.d.ts.map +1 -0
  58. package/dist/extensibleSchemaUnion.js +79 -0
  59. package/dist/extensibleSchemaUnion.js.map +1 -0
  60. package/dist/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  61. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  62. package/dist/feature-libraries/changeAtomIdBTree.js +9 -1
  63. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  64. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  65. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  66. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +20 -21
  67. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  68. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  69. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  71. package/dist/feature-libraries/forest-summary/codec.d.ts +2 -1
  72. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  73. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  74. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  75. package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -2
  76. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  77. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +1 -39
  78. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  79. package/dist/feature-libraries/forest-summary/formatCommon.js +1 -2
  80. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  81. package/dist/feature-libraries/forest-summary/formatV1.d.ts +1 -39
  82. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  83. package/dist/feature-libraries/forest-summary/formatV2.d.ts +1 -39
  84. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  85. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  86. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  87. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  88. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  89. package/dist/feature-libraries/index.d.ts +3 -3
  90. package/dist/feature-libraries/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/index.js +4 -3
  92. package/dist/feature-libraries/index.js.map +1 -1
  93. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  94. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  95. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +42 -22
  96. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  97. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  98. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  99. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  100. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  101. package/dist/feature-libraries/modular-schema/index.js +2 -1
  102. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  103. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  105. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -5
  106. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  107. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +30 -7
  110. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  111. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +38 -27
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  115. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  117. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  118. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  119. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  120. package/dist/feature-libraries/optional-field/optionalField.js +1 -1
  121. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  122. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  123. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  124. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  125. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  126. package/dist/feature-libraries/schema-index/formatV2.d.ts +4 -4
  127. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  128. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  129. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  130. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  131. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  132. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  133. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  134. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  135. package/dist/index.d.ts +5 -5
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +4 -1
  138. package/dist/index.js.map +1 -1
  139. package/dist/legacy.d.ts +3 -0
  140. package/dist/packageVersion.d.ts +1 -1
  141. package/dist/packageVersion.js +1 -1
  142. package/dist/packageVersion.js.map +1 -1
  143. package/dist/shared-tree/independentView.d.ts +36 -13
  144. package/dist/shared-tree/independentView.d.ts.map +1 -1
  145. package/dist/shared-tree/independentView.js +1 -0
  146. package/dist/shared-tree/independentView.js.map +1 -1
  147. package/dist/shared-tree/index.d.ts +1 -1
  148. package/dist/shared-tree/index.d.ts.map +1 -1
  149. package/dist/shared-tree/index.js.map +1 -1
  150. package/dist/shared-tree/schematizingTreeView.d.ts +10 -0
  151. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  152. package/dist/shared-tree/schematizingTreeView.js +25 -9
  153. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  154. package/dist/shared-tree/sharedTree.d.ts +3 -3
  155. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  156. package/dist/shared-tree/sharedTree.js +8 -32
  157. package/dist/shared-tree/sharedTree.js.map +1 -1
  158. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  159. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeCodecs.js +38 -4
  161. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  163. package/dist/shared-tree/tree.js +1 -1
  164. package/dist/shared-tree/tree.js.map +1 -1
  165. package/dist/shared-tree/treeCheckout.d.ts +20 -0
  166. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  167. package/dist/shared-tree/treeCheckout.js +39 -3
  168. package/dist/shared-tree/treeCheckout.js.map +1 -1
  169. package/dist/shared-tree-core/editManagerSummarizer.js +1 -1
  170. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  171. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  172. package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
  173. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  174. package/dist/shared-tree-core/transaction.d.ts +14 -3
  175. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  176. package/dist/shared-tree-core/transaction.js +59 -16
  177. package/dist/shared-tree-core/transaction.js.map +1 -1
  178. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  179. package/dist/shared-tree-core/versionedSummarizer.js +1 -1
  180. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  181. package/dist/simple-tree/api/index.d.ts +1 -1
  182. package/dist/simple-tree/api/index.d.ts.map +1 -1
  183. package/dist/simple-tree/api/index.js +3 -2
  184. package/dist/simple-tree/api/index.js.map +1 -1
  185. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  186. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  187. package/dist/simple-tree/api/schemaCreationUtilities.js +16 -1
  188. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  189. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  190. package/dist/simple-tree/api/transactionTypes.d.ts +10 -0
  191. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  192. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  193. package/dist/simple-tree/api/tree.d.ts +81 -6
  194. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  195. package/dist/simple-tree/api/tree.js.map +1 -1
  196. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  197. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  198. package/dist/simple-tree/index.d.ts +2 -2
  199. package/dist/simple-tree/index.d.ts.map +1 -1
  200. package/dist/simple-tree/index.js +4 -2
  201. package/dist/simple-tree/index.js.map +1 -1
  202. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  203. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  204. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  205. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  206. package/dist/simple-tree/node-kinds/array/arrayNode.js +43 -1
  207. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  208. package/dist/simple-tree/node-kinds/array/index.d.ts +1 -1
  209. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  210. package/dist/simple-tree/node-kinds/array/index.js +2 -1
  211. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  212. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  213. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  214. package/dist/simple-tree/node-kinds/index.js +2 -1
  215. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  216. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  217. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  218. package/dist/tableSchema.d.ts +71 -48
  219. package/dist/tableSchema.d.ts.map +1 -1
  220. package/dist/tableSchema.js +200 -98
  221. package/dist/tableSchema.js.map +1 -1
  222. package/dist/text/textDomainFormatted.js +1 -1
  223. package/dist/text/textDomainFormatted.js.map +1 -1
  224. package/dist/util/bTreeUtils.d.ts +30 -4
  225. package/dist/util/bTreeUtils.d.ts.map +1 -1
  226. package/dist/util/bTreeUtils.js +29 -17
  227. package/dist/util/bTreeUtils.js.map +1 -1
  228. package/dist/util/brand.d.ts.map +1 -1
  229. package/dist/util/brand.js.map +1 -1
  230. package/dist/util/brandedMap.d.ts.map +1 -1
  231. package/dist/util/brandedMap.js.map +1 -1
  232. package/dist/util/breakable.d.ts.map +1 -1
  233. package/dist/util/breakable.js +2 -1
  234. package/dist/util/breakable.js.map +1 -1
  235. package/dist/util/index.d.ts +2 -2
  236. package/dist/util/index.d.ts.map +1 -1
  237. package/dist/util/index.js +6 -3
  238. package/dist/util/index.js.map +1 -1
  239. package/dist/util/opaque.d.ts.map +1 -1
  240. package/dist/util/opaque.js.map +1 -1
  241. package/dist/util/rangeMap.d.ts +3 -2
  242. package/dist/util/rangeMap.d.ts.map +1 -1
  243. package/dist/util/rangeMap.js +7 -1
  244. package/dist/util/rangeMap.js.map +1 -1
  245. package/dist/util/readSnapshotBlob.d.ts +1 -1
  246. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  247. package/dist/util/readSnapshotBlob.js.map +1 -1
  248. package/dist/util/typeCheck.d.ts.map +1 -1
  249. package/dist/util/typeCheck.js.map +1 -1
  250. package/dist/util/utils.d.ts +20 -16
  251. package/dist/util/utils.d.ts.map +1 -1
  252. package/dist/util/utils.js +49 -17
  253. package/dist/util/utils.js.map +1 -1
  254. package/eslint.config.mts +0 -9
  255. package/lib/alpha.d.ts +8 -2
  256. package/lib/beta.d.ts +3 -0
  257. package/lib/codec/codec.d.ts +17 -8
  258. package/lib/codec/codec.d.ts.map +1 -1
  259. package/lib/codec/codec.js +6 -0
  260. package/lib/codec/codec.js.map +1 -1
  261. package/lib/codec/index.d.ts +1 -1
  262. package/lib/codec/index.d.ts.map +1 -1
  263. package/lib/codec/index.js +1 -1
  264. package/lib/codec/index.js.map +1 -1
  265. package/lib/codec/versioned/codec.d.ts +1 -1
  266. package/lib/codec/versioned/codec.d.ts.map +1 -1
  267. package/lib/codec/versioned/codec.js.map +1 -1
  268. package/lib/core/index.d.ts +1 -1
  269. package/lib/core/index.d.ts.map +1 -1
  270. package/lib/core/index.js +1 -1
  271. package/lib/core/index.js.map +1 -1
  272. package/lib/core/rebase/changeRebaser.d.ts +3 -2
  273. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  274. package/lib/core/rebase/changeRebaser.js.map +1 -1
  275. package/lib/core/rebase/index.d.ts +1 -1
  276. package/lib/core/rebase/index.d.ts.map +1 -1
  277. package/lib/core/rebase/index.js +1 -1
  278. package/lib/core/rebase/index.js.map +1 -1
  279. package/lib/core/rebase/types.d.ts +23 -3
  280. package/lib/core/rebase/types.d.ts.map +1 -1
  281. package/lib/core/rebase/types.js +27 -15
  282. package/lib/core/rebase/types.js.map +1 -1
  283. package/lib/core/schema-stored/formatV1.d.ts +2 -2
  284. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  285. package/lib/core/schema-stored/formatV1.js +0 -5
  286. package/lib/core/schema-stored/formatV1.js.map +1 -1
  287. package/lib/core/schema-stored/formatV2.d.ts +11 -10
  288. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  289. package/lib/core/schema-stored/formatV2.js +1 -6
  290. package/lib/core/schema-stored/formatV2.js.map +1 -1
  291. package/lib/core/schema-stored/index.d.ts.map +1 -1
  292. package/lib/core/schema-stored/index.js +2 -0
  293. package/lib/core/schema-stored/index.js.map +1 -1
  294. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  295. package/lib/core/schema-stored/schema.js.map +1 -1
  296. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  297. package/lib/core/tree/anchorSet.js.map +1 -1
  298. package/lib/core/tree/delta.d.ts +9 -7
  299. package/lib/core/tree/delta.d.ts.map +1 -1
  300. package/lib/core/tree/delta.js.map +1 -1
  301. package/lib/core/tree/deltaUtil.js +1 -1
  302. package/lib/core/tree/deltaUtil.js.map +1 -1
  303. package/lib/core/tree/visitDelta.js +2 -2
  304. package/lib/core/tree/visitDelta.js.map +1 -1
  305. package/lib/extensibleSchemaUnion.d.ts +72 -0
  306. package/lib/extensibleSchemaUnion.d.ts.map +1 -0
  307. package/lib/extensibleSchemaUnion.js +76 -0
  308. package/lib/extensibleSchemaUnion.js.map +1 -0
  309. package/lib/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  310. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  311. package/lib/feature-libraries/changeAtomIdBTree.js +7 -0
  312. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  313. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  314. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  315. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -5
  316. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  317. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  318. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  319. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  320. package/lib/feature-libraries/forest-summary/codec.d.ts +2 -1
  321. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  322. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  323. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  324. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -3
  325. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  326. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +1 -39
  327. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  328. package/lib/feature-libraries/forest-summary/formatCommon.js +2 -3
  329. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  330. package/lib/feature-libraries/forest-summary/formatV1.d.ts +1 -39
  331. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  332. package/lib/feature-libraries/forest-summary/formatV2.d.ts +1 -39
  333. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  334. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  335. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  336. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  337. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  338. package/lib/feature-libraries/index.d.ts +3 -3
  339. package/lib/feature-libraries/index.d.ts.map +1 -1
  340. package/lib/feature-libraries/index.js +3 -3
  341. package/lib/feature-libraries/index.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  343. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  344. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +41 -21
  345. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  346. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  347. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  348. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  349. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  350. package/lib/feature-libraries/modular-schema/index.js +1 -1
  351. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  352. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  353. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  354. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -6
  355. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  356. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  357. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  358. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +29 -6
  359. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  360. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  361. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +41 -30
  362. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  363. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  364. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  365. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  366. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  367. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  368. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  369. package/lib/feature-libraries/optional-field/optionalField.js +1 -1
  370. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  371. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  372. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  373. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  374. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  375. package/lib/feature-libraries/schema-index/formatV2.d.ts +4 -4
  376. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  377. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  378. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  379. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  380. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  381. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  382. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  383. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  384. package/lib/index.d.ts +5 -5
  385. package/lib/index.d.ts.map +1 -1
  386. package/lib/index.js +4 -3
  387. package/lib/index.js.map +1 -1
  388. package/lib/legacy.d.ts +3 -0
  389. package/lib/packageVersion.d.ts +1 -1
  390. package/lib/packageVersion.js +1 -1
  391. package/lib/packageVersion.js.map +1 -1
  392. package/lib/shared-tree/independentView.d.ts +36 -13
  393. package/lib/shared-tree/independentView.d.ts.map +1 -1
  394. package/lib/shared-tree/independentView.js +1 -0
  395. package/lib/shared-tree/independentView.js.map +1 -1
  396. package/lib/shared-tree/index.d.ts +1 -1
  397. package/lib/shared-tree/index.d.ts.map +1 -1
  398. package/lib/shared-tree/index.js.map +1 -1
  399. package/lib/shared-tree/schematizingTreeView.d.ts +10 -0
  400. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  401. package/lib/shared-tree/schematizingTreeView.js +25 -9
  402. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  403. package/lib/shared-tree/sharedTree.d.ts +3 -3
  404. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  405. package/lib/shared-tree/sharedTree.js +10 -34
  406. package/lib/shared-tree/sharedTree.js.map +1 -1
  407. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  408. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  409. package/lib/shared-tree/sharedTreeChangeCodecs.js +39 -5
  410. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  411. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  412. package/lib/shared-tree/tree.js +1 -1
  413. package/lib/shared-tree/tree.js.map +1 -1
  414. package/lib/shared-tree/treeCheckout.d.ts +20 -0
  415. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  416. package/lib/shared-tree/treeCheckout.js +39 -3
  417. package/lib/shared-tree/treeCheckout.js.map +1 -1
  418. package/lib/shared-tree-core/editManagerSummarizer.js +1 -1
  419. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  420. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  421. package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
  422. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  423. package/lib/shared-tree-core/transaction.d.ts +14 -3
  424. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  425. package/lib/shared-tree-core/transaction.js +61 -18
  426. package/lib/shared-tree-core/transaction.js.map +1 -1
  427. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  428. package/lib/shared-tree-core/versionedSummarizer.js +1 -1
  429. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  430. package/lib/simple-tree/api/index.d.ts +1 -1
  431. package/lib/simple-tree/api/index.d.ts.map +1 -1
  432. package/lib/simple-tree/api/index.js +1 -1
  433. package/lib/simple-tree/api/index.js.map +1 -1
  434. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  435. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  436. package/lib/simple-tree/api/schemaCreationUtilities.js +14 -0
  437. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  438. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  439. package/lib/simple-tree/api/transactionTypes.d.ts +10 -0
  440. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  441. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  442. package/lib/simple-tree/api/tree.d.ts +81 -6
  443. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  444. package/lib/simple-tree/api/tree.js.map +1 -1
  445. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  446. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  447. package/lib/simple-tree/index.d.ts +2 -2
  448. package/lib/simple-tree/index.d.ts.map +1 -1
  449. package/lib/simple-tree/index.js +2 -2
  450. package/lib/simple-tree/index.js.map +1 -1
  451. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  452. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  453. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  454. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  455. package/lib/simple-tree/node-kinds/array/arrayNode.js +41 -0
  456. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  457. package/lib/simple-tree/node-kinds/array/index.d.ts +1 -1
  458. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  459. package/lib/simple-tree/node-kinds/array/index.js +1 -1
  460. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  461. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  462. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  463. package/lib/simple-tree/node-kinds/index.js +1 -1
  464. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  465. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  466. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  467. package/lib/tableSchema.d.ts +71 -48
  468. package/lib/tableSchema.d.ts.map +1 -1
  469. package/lib/tableSchema.js +201 -99
  470. package/lib/tableSchema.js.map +1 -1
  471. package/lib/text/textDomainFormatted.js +1 -1
  472. package/lib/text/textDomainFormatted.js.map +1 -1
  473. package/lib/util/bTreeUtils.d.ts +30 -4
  474. package/lib/util/bTreeUtils.d.ts.map +1 -1
  475. package/lib/util/bTreeUtils.js +27 -16
  476. package/lib/util/bTreeUtils.js.map +1 -1
  477. package/lib/util/brand.d.ts.map +1 -1
  478. package/lib/util/brand.js.map +1 -1
  479. package/lib/util/brandedMap.d.ts.map +1 -1
  480. package/lib/util/brandedMap.js.map +1 -1
  481. package/lib/util/breakable.d.ts.map +1 -1
  482. package/lib/util/breakable.js +2 -1
  483. package/lib/util/breakable.js.map +1 -1
  484. package/lib/util/index.d.ts +2 -2
  485. package/lib/util/index.d.ts.map +1 -1
  486. package/lib/util/index.js +2 -2
  487. package/lib/util/index.js.map +1 -1
  488. package/lib/util/opaque.d.ts.map +1 -1
  489. package/lib/util/opaque.js.map +1 -1
  490. package/lib/util/rangeMap.d.ts +3 -2
  491. package/lib/util/rangeMap.d.ts.map +1 -1
  492. package/lib/util/rangeMap.js +7 -1
  493. package/lib/util/rangeMap.js.map +1 -1
  494. package/lib/util/readSnapshotBlob.d.ts +1 -1
  495. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  496. package/lib/util/readSnapshotBlob.js.map +1 -1
  497. package/lib/util/typeCheck.d.ts.map +1 -1
  498. package/lib/util/typeCheck.js.map +1 -1
  499. package/lib/util/utils.d.ts +20 -16
  500. package/lib/util/utils.d.ts.map +1 -1
  501. package/lib/util/utils.js +44 -15
  502. package/lib/util/utils.js.map +1 -1
  503. package/package.json +23 -23
  504. package/src/codec/codec.ts +30 -11
  505. package/src/codec/index.ts +2 -0
  506. package/src/codec/versioned/codec.ts +9 -13
  507. package/src/core/index.ts +3 -1
  508. package/src/core/rebase/changeRebaser.ts +3 -2
  509. package/src/core/rebase/index.ts +3 -1
  510. package/src/core/rebase/types.ts +51 -13
  511. package/src/core/schema-stored/formatV1.ts +2 -4
  512. package/src/core/schema-stored/formatV2.ts +9 -7
  513. package/src/core/schema-stored/index.ts +2 -0
  514. package/src/core/schema-stored/schema.ts +4 -1
  515. package/src/core/tree/anchorSet.ts +1 -3
  516. package/src/core/tree/delta.ts +9 -7
  517. package/src/core/tree/deltaUtil.ts +1 -1
  518. package/src/core/tree/visitDelta.ts +2 -2
  519. package/src/extensibleSchemaUnion.ts +135 -0
  520. package/src/feature-libraries/changeAtomIdBTree.ts +17 -2
  521. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +5 -6
  522. package/src/feature-libraries/default-schema/index.ts +0 -1
  523. package/src/feature-libraries/forest-summary/codec.ts +7 -2
  524. package/src/feature-libraries/forest-summary/forestSummarizer.ts +15 -3
  525. package/src/feature-libraries/forest-summary/formatCommon.ts +2 -3
  526. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +4 -5
  527. package/src/feature-libraries/index.ts +3 -2
  528. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +57 -31
  529. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  530. package/src/feature-libraries/modular-schema/index.ts +4 -1
  531. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +7 -6
  532. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +32 -7
  533. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +54 -33
  534. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -4
  535. package/src/feature-libraries/optional-field/optionalField.ts +1 -1
  536. package/src/feature-libraries/optional-field/requiredField.ts +2 -4
  537. package/src/feature-libraries/schema-index/codec.ts +1 -1
  538. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  539. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  540. package/src/feature-libraries/sequence-field/replaceRevisions.ts +17 -10
  541. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
  542. package/src/index.ts +12 -7
  543. package/src/packageVersion.ts +1 -1
  544. package/src/shared-tree/independentView.ts +42 -6
  545. package/src/shared-tree/index.ts +2 -0
  546. package/src/shared-tree/schematizingTreeView.ts +63 -18
  547. package/src/shared-tree/sharedTree.ts +19 -37
  548. package/src/shared-tree/sharedTreeChangeCodecs.ts +43 -9
  549. package/src/shared-tree/tree.ts +1 -1
  550. package/src/shared-tree/treeCheckout.ts +50 -3
  551. package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
  552. package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -3
  553. package/src/shared-tree-core/transaction.ts +125 -23
  554. package/src/shared-tree-core/versionedSummarizer.ts +3 -2
  555. package/src/simple-tree/api/index.ts +1 -0
  556. package/src/simple-tree/api/schemaCreationUtilities.ts +35 -5
  557. package/src/simple-tree/api/simpleTreeIndex.ts +1 -1
  558. package/src/simple-tree/api/transactionTypes.ts +10 -0
  559. package/src/simple-tree/api/tree.ts +88 -6
  560. package/src/simple-tree/core/treeNodeSchema.ts +5 -8
  561. package/src/simple-tree/index.ts +3 -0
  562. package/src/simple-tree/leafNodeSchema.ts +3 -2
  563. package/src/simple-tree/node-kinds/array/arrayNode.ts +86 -0
  564. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  565. package/src/simple-tree/node-kinds/index.ts +2 -0
  566. package/src/simple-tree/node-kinds/object/objectNode.ts +19 -18
  567. package/src/tableSchema.ts +280 -140
  568. package/src/text/textDomainFormatted.ts +1 -1
  569. package/src/util/bTreeUtils.ts +45 -26
  570. package/src/util/brand.ts +4 -12
  571. package/src/util/brandedMap.ts +2 -6
  572. package/src/util/breakable.ts +3 -2
  573. package/src/util/index.ts +9 -3
  574. package/src/util/opaque.ts +2 -6
  575. package/src/util/rangeMap.ts +11 -5
  576. package/src/util/readSnapshotBlob.ts +3 -3
  577. package/src/util/typeCheck.ts +11 -9
  578. package/src/util/utils.ts +57 -28
  579. package/biome.jsonc +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsF;AACtF,qEAAuE;AACvE,uEAAsE;AAEtE,qDAIgC;AAChC,kEAO6C;AAM7C,qDAA+C;AAE/C,kDAwB6B;AAC7B,6DAGgC;AAChC,yDAc8B;AAC9B,yEAAsE;AACtE,yEAAmE;AAEnE,+DAA2D;AAC3D,mGAMmD;AA4InD;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,IAAA,qCAAoB,EAAC,WAAW,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE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1C,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAQ,IAA0C,CAAC,GAAa,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,gBAAgB,CACxB,MAA+B,EAC/B,IAA0E,EAC1E,SAAuD,EACvD,KAAoC;IAEpC,MAAM,KAAK,GACV,IAAI,CAAC,IAAI,KAAK,OAAO;QACpB,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,IAAA,uBAAY,EAAC,KAAK,CAAC,CAAC;IAClC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,IAAA,iBAAM,EACL,YAAY,YAAY,iCAAsB,EAC9C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport type {\n\tRestrictiveStringRecord,\n\tFlattenKeys,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../../util/index.js\";\nimport { brand } from \"../../../util/index.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tunhydratedFlexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\n\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = RestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t? // {} case\n\t\t\tRecord<string, never>\n\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\tnever\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchemaPrivate,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's built in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tconst mapTree = prepareForInsertion(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context,\n\t\tdestinationSchema,\n\t);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t\t}\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata - Optional persisted metadata for the object node schema.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t}),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as Output);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue && getFieldProperty(data, fieldKey) === undefined) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\n\t);\n}\n"]}
1
+ {"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsF;AACtF,qEAAuE;AACvE,uEAAsE;AAEtE,qDAIgC;AAChC,kEAO6C;AAM7C,qDAA+C;AAE/C,kDAwB6B;AAC7B,6DAGgC;AAChC,yDAc8B;AAC9B,yEAAsE;AACtE,yEAAmE;AAEnE,+DAA2D;AAC3D,mGAMmD;AA6InD;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,IAAA,qCAAoB,EAAC,WAAW,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC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xB,IAA0B,EAC1B,GAAoB;IAEpB,0CAA0C;IAC1C,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAQ,IAA0C,CAAC,GAAa,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,gBAAgB,CACxB,MAA+B,EAC/B,IAA0E,EAC1E,SAAuD,EACvD,KAAoC;IAEpC,MAAM,KAAK,GACV,IAAI,CAAC,IAAI,KAAK,OAAO;QACpB,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,IAAA,uBAAY,EAAC,KAAK,CAAC,CAAC;IAClC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,IAAA,iBAAM,EACL,YAAY,YAAY,iCAAsB,EAC9C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport type {\n\tRestrictiveStringRecord,\n\tFlattenKeys,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../../util/index.js\";\nimport { brand } from \"../../../util/index.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tunhydratedFlexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\n\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t\t? // {} case\n\t\t\t\tRecord<string, never>\n\t\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\t\tnever\n\t\t: FlattenKeys<\n\t\t\t\t{\n\t\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\t\tT[Property & string]\n\t\t\t\t\t>;\n\t\t\t\t} & {\n\t\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t\t? Property\n\t\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t\t}\n\t\t\t>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchemaPrivate,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's built in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tconst mapTree = prepareForInsertion(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context,\n\t\tdestinationSchema,\n\t);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t\t}\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata - Optional persisted metadata for the object node schema.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t}),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as Output);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue && getFieldProperty(data, fieldKey) === undefined) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\n\t);\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type FieldHasDefault, type ImplicitAllowedTypes, type InsertableTreeNodeFromImplicitAllowedTypes, type NodeKind, SchemaFactoryBeta, type ScopedSchemaName, type TreeNode, type TreeNodeFromImplicitAllowedTypes, type TreeNodeSchemaClass, type WithType, type TreeFieldFromImplicitField, type InsertableTreeFieldFromImplicitField, type InternalTreeNode, SchemaFactory, type ImplicitFieldSchema, type TreeRecordNode, TreeNodeSchemaCore } from "./simple-tree/index.js";
5
+ import type { SchemaFactoryBeta } from "./simple-tree/index.js";
6
+ import { type FieldHasDefault, type ImplicitAllowedTypes, type InsertableTreeNodeFromImplicitAllowedTypes, type NodeKind, type ScopedSchemaName, type TreeNode, type TreeNodeFromImplicitAllowedTypes, type TreeNodeSchemaClass, type WithType, type TreeFieldFromImplicitField, type InsertableTreeFieldFromImplicitField, type InternalTreeNode, SchemaFactory, type ImplicitFieldSchema, type TreeRecordNode, TreeNodeSchemaCore } from "./simple-tree/index.js";
6
7
  /**
7
8
  * A row in a table.
8
9
  * @typeParam TCellSchema - The type of the cells in the {@link TableSchema.Table}.
@@ -29,7 +30,14 @@ export interface RowPrivate<TCellSchema extends ImplicitAllowedTypes, TPropsSche
29
30
  * This namespace should be strictly type-exported by the package.
30
31
  * All members should be tagged with `@system`.
31
32
  *
32
- * @system @alpha
33
+ * Orphaned Cells:
34
+ * Without safeguards, it is possible for cells to become "orphaned".
35
+ * An orphaned cell is a cell that does not correspond to a valid row and column.
36
+ * In order to preserve the invariant that all cells must have a valid row and column, table operations
37
+ * (eg, inserting/removing rows/columns, or setting/removing a cell) will automatically include constraints that
38
+ * guard transactions from producing orphaned cells.
39
+ *
40
+ * @system @beta
33
41
  */
34
42
  export declare namespace System_TableSchema {
35
43
  /**
@@ -40,7 +48,7 @@ export declare namespace System_TableSchema {
40
48
  * Note: this can't reasonably be implemented via `Pick<ArrayNode<...>>` because we only want to include the
41
49
  * subset of its method overloads which do not support moving items between lists.
42
50
  *
43
- * @alpha @system
51
+ * @beta @system
44
52
  */
45
53
  type RearrangeableList<TItemSchema extends ImplicitAllowedTypes> = TreeNode & readonly TreeNodeFromImplicitAllowedTypes<TItemSchema>[] & {
46
54
  /** {@inheritDoc (TreeArrayNode:interface).(moveToEnd:1)} */
@@ -62,14 +70,14 @@ export declare namespace System_TableSchema {
62
70
  * Longer term, it would be better to simply omit "props" altogether by default.
63
71
  * For now, this ensures that the user doesn't have to specify a "props" entry when initializing column/row nodes
64
72
  * and ensures that they cannot set anything that might conflict with future evolutions of the schema.
65
- * @system @alpha
73
+ * @system @beta
66
74
  */
67
75
  type DefaultPropsType = ReturnType<typeof SchemaFactory.optional<[]>>;
68
76
  /**
69
77
  * A base interface for factory input options which include an schema factory.
70
78
  * @remarks This interface should not be referenced directly.
71
79
  * @privateRemarks This interface primarily exists to provide a single home for property documentation.
72
- * @system @alpha
80
+ * @system @beta
73
81
  */
74
82
  interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryBeta> {
75
83
  /**
@@ -83,7 +91,7 @@ export declare namespace System_TableSchema {
83
91
  * A base interface for factory input options which include the table cell schema.
84
92
  * @remarks This interface should not be referenced directly.
85
93
  * @privateRemarks This interface primarily exists to provide a single home for property documentation.
86
- * @system @alpha
94
+ * @system @beta
87
95
  */
88
96
  interface OptionsWithCellSchema<TCellSchema extends ImplicitAllowedTypes> {
89
97
  /**
@@ -94,14 +102,14 @@ export declare namespace System_TableSchema {
94
102
  /**
95
103
  * Base options for creating table column schema.
96
104
  * @remarks Includes parameters common to all column factory overloads.
97
- * @system @alpha
105
+ * @system @beta
98
106
  */
99
107
  type CreateColumnOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
100
108
  /**
101
109
  * Factory for creating column schema.
102
- * @system @alpha
110
+ * @system @beta
103
111
  */
104
- function createColumnSchema<const TUserScope extends string, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Column">, NodeKind.Object, TreeNode & TableSchema.Column<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Column">, NodeKind, unknown>, object & {
112
+ function createColumnSchema<const TUserScope extends string, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Column">, NodeKind.Object, TreeNode & TableSchema.Column<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Column">, NodeKind, unknown>, object & {
105
113
  readonly id?: string | undefined;
106
114
  } & (FieldHasDefault<TPropsSchema> extends true ? {
107
115
  /**
@@ -121,22 +129,22 @@ export declare namespace System_TableSchema {
121
129
  }>;
122
130
  /**
123
131
  * Base column schema type.
124
- * @sealed @system @alpha
132
+ * @sealed @system @beta
125
133
  */
126
134
  type ColumnSchemaBase<TUserScope extends string = string, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createColumnSchema<TUserScope, TCellSchema, TPropsSchema>>;
127
135
  /**
128
136
  * Base options for creating table row schema.
129
137
  * @remarks Includes parameters common to all row factory overloads.
130
- * @system @alpha
138
+ * @system @beta
131
139
  */
132
140
  type CreateRowOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
133
141
  /**
134
142
  * Factory for creating row schema.
135
- * @sealed @alpha
143
+ * @system @beta
136
144
  */
137
- function createRowSchema<const TUserScope extends string, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, cellSchema: TCellSchema, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row">, NodeKind.Object, TreeNode & TableSchema.Row<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row">, NodeKind, unknown>, object & {
145
+ function createRowSchema<const TUserScope extends string, const TCellSchema extends ImplicitAllowedTypes, const TPropsSchema extends ImplicitFieldSchema>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, cellSchema: TCellSchema, propsSchema: TPropsSchema): TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row">, NodeKind.Object, TreeNode & TableSchema.Row<TCellSchema, TPropsSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row">, NodeKind, unknown>, object & {
138
146
  readonly id?: string | undefined;
139
- readonly cells: (import("./simple-tree/index.js").InsertableTypedNode<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>> | undefined) & import("./simple-tree/index.js").InsertableTypedNode<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>>;
147
+ readonly cells: (import("./simple-tree/index.js").InsertableTypedNode<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>> | undefined) & import("./simple-tree/index.js").InsertableTypedNode<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>>;
140
148
  } & (FieldHasDefault<TPropsSchema> extends true ? {
141
149
  /**
142
150
  * The row's properties.
@@ -159,22 +167,22 @@ export declare namespace System_TableSchema {
159
167
  * @remarks
160
168
  * The table row models its cells as a record, where each key is the ID of the column it belongs to. The choice of record (as opposed to a map) is intended to make interop with common table rendering libraries in TypeScript/JavaScript easier.
161
169
  */
162
- readonly cells: import("./simple-tree/fieldSchema.js").FieldSchema<import("./simple-tree/fieldSchema.js").FieldKind.Required, TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>, unknown>;
170
+ readonly cells: import("./simple-tree/fieldSchema.js").FieldSchema<import("./simple-tree/fieldSchema.js").FieldKind.Required, TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, import("./simple-tree/index.js").RecordNodeInsertableData<TCellSchema>, true, TCellSchema, undefined, unknown>, unknown>;
163
171
  }>;
164
172
  /**
165
173
  * Base row schema type.
166
- * @sealed @system @alpha
174
+ * @sealed @system @beta
167
175
  */
168
176
  type RowSchemaBase<TUserScope extends string = string, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createRowSchema<TUserScope, TCellSchema, TPropsSchema>>;
169
177
  /**
170
178
  * Base options for creating table schema.
171
179
  * @remarks Includes parameters common to all table factory overloads.
172
- * @system @alpha
180
+ * @system @beta
173
181
  */
174
182
  type TableFactoryOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
175
183
  /**
176
184
  * Factory for creating table schema.
177
- * @system @alpha
185
+ * @system @beta
178
186
  */
179
187
  function createTableSchema<const TUserScope extends string, const TCellSchema extends ImplicitAllowedTypes, const TColumnSchema extends ColumnSchemaBase<TUserScope, TCellSchema>, const TRowSchema extends RowSchemaBase<TUserScope, TCellSchema>>(inputSchemaFactory: SchemaFactoryBeta<TUserScope>, _cellSchema: TCellSchema, columnSchema: TColumnSchema, rowSchema: TRowSchema): {
180
188
  /**
@@ -185,11 +193,11 @@ export declare namespace System_TableSchema {
185
193
  * - Ensures that any cells specified in the initial rows correspond to existing columns in the initial columns.
186
194
  * - Ensures that all column and row IDs are unique.
187
195
  */
188
- create<TThis extends new (data?: InternalTreeNode | undefined) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "TableRoot">, NodeKind, unknown>>(this: TThis, initialContents?: TableSchema.TableFactoryMethodParameters<TUserScope, TCellSchema, TColumnSchema, TRowSchema> | undefined): InstanceType<TThis>;
189
- } & (new (data?: InternalTreeNode | undefined) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "TableRoot">, NodeKind, unknown>) & TreeNodeSchemaCore<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "TableRoot"> & string, NodeKind, false, unknown, never, unknown> & (new (data: InternalTreeNode) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "TableRoot">, NodeKind, unknown> & WithType<ScopedSchemaName<`com.fluidframework.table<${TUserScope}>`, "TableRoot"> & string, NodeKind, unknown>);
196
+ create<TThis extends new (data?: InternalTreeNode | undefined) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "TableRoot">, NodeKind, unknown>>(this: TThis, initialContents?: TableSchema.TableFactoryMethodParameters<TUserScope, TCellSchema, TColumnSchema, TRowSchema> | undefined): InstanceType<TThis>;
197
+ } & (new (data?: InternalTreeNode | undefined) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "TableRoot">, NodeKind, unknown>) & TreeNodeSchemaCore<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "TableRoot"> & string, NodeKind, false, unknown, never, unknown> & (new (data: InternalTreeNode) => TreeNode & TableSchema.Table<TUserScope, TCellSchema, TColumnSchema, TRowSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "TableRoot">, NodeKind, unknown> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "TableRoot"> & string, NodeKind, unknown>);
190
198
  /**
191
199
  * Base row schema type.
192
- * @sealed @system @alpha
200
+ * @sealed @system @beta
193
201
  */
194
202
  type TableSchemaBase<TUserScope extends string, TCellSchema extends ImplicitAllowedTypes, TColumnSchema extends ColumnSchemaBase<TUserScope, TCellSchema>, TRowSchema extends RowSchemaBase<TUserScope, TCellSchema>> = ReturnType<typeof createTableSchema<TUserScope, TCellSchema, TColumnSchema, TRowSchema>>;
195
203
  }
@@ -198,10 +206,16 @@ export declare namespace System_TableSchema {
198
206
  *
199
207
  * @remarks
200
208
  *
201
- * WARNING: These APIs are in preview and are subject to change.
202
- * Until these APIs have stabilized, it is not recommended to use them in production code.
203
- * There may be breaking changes to these APIs and their underlying data format.
204
- * Using these APIs in production code may result in data loss or corruption.
209
+ * Note: the APIs produced by this module ensure various tabular data invariants are maintained that the raw, underlying tree structures do not.
210
+ * For example, they ensure that cells always correspond to existing rows and columns (and do not become "orphaned" due to row/column deletion, etc.).
211
+ * For this reason, direct manipulation of the underlying tree structures is not supported.
212
+ * To modify the data, only the APIs provided here may be used.
213
+ *
214
+ * Also note: these APIs leverage `SharedTree` functionality that was added in version `2.80.0`,
215
+ * which is not compatible with previous versions of this library.
216
+ * To ensure safe collaboration, you will need to configure the {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}
217
+ * for the Fluid Runtime and/or `SharedTree` to at least `2.80.0`.
218
+ * To set this minimum version for `SharedTree`, use {@link configuredSharedTreeBeta}.
205
219
  *
206
220
  * The primary APIs for create tabular data schema are:
207
221
  *
@@ -224,12 +238,6 @@ export declare namespace System_TableSchema {
224
238
  * Column and Row schema created using these APIs are extensible via the `props` field.
225
239
  * This allows association of additional properties with column and row nodes.
226
240
  *
227
- * Cells in the table may become "orphaned."
228
- * That is, it is possible to enter a state where one or more rows contain cells with no corresponding column.
229
- * To reduce the likelihood of this, you can manually remove corresponding cells when removing columns.
230
- * Either way, it is possible to enter such a state via the merging of edits.
231
- * For example: one client might add a row while another concurrently removes a column, orphaning the cell where the column and row intersected.
232
- *
233
241
  * @example Defining a Table schema
234
242
  *
235
243
  * ```typescript
@@ -305,7 +313,7 @@ export declare namespace System_TableSchema {
305
313
  * The above examples are backed by tests in `tableSchema.spec.ts`.
306
314
  * Those tests and these examples should be kept in-sync to ensure that the examples are correct.
307
315
  *
308
- * @alpha
316
+ * @beta
309
317
  */
310
318
  export declare namespace TableSchema {
311
319
  /**
@@ -313,7 +321,7 @@ export declare namespace TableSchema {
313
321
  * @remarks Implemented by the schema class returned from {@link TableSchema.(column:2)}.
314
322
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
315
323
  * @typeParam TProps - Additional properties to associate with the column.
316
- * @sealed @alpha
324
+ * @sealed @beta
317
325
  */
318
326
  interface Column<TCell extends ImplicitAllowedTypes, TProps extends ImplicitFieldSchema = ImplicitFieldSchema> {
319
327
  /**
@@ -335,7 +343,7 @@ export declare namespace TableSchema {
335
343
  * Factory for creating new table column schema.
336
344
  * @typeParam TUserScope - The {@link SchemaFactory.scope | schema factory scope}.
337
345
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
338
- * @alpha
346
+ * @beta
339
347
  */
340
348
  function column<const TUserScope extends string, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateColumnOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell>): System_TableSchema.ColumnSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>;
341
349
  /**
@@ -343,7 +351,7 @@ export declare namespace TableSchema {
343
351
  * @typeParam TUserScope - The {@link SchemaFactory.scope | schema factory scope}.
344
352
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
345
353
  * @typeParam TProps - Additional properties to associate with the column.
346
- * @alpha
354
+ * @beta
347
355
  */
348
356
  function column<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateColumnOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
349
357
  /**
@@ -356,7 +364,7 @@ export declare namespace TableSchema {
356
364
  * @remarks Implemented by the schema class returned from {@link TableSchema.(row:2)}.
357
365
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
358
366
  * @typeParam TProps - Additional properties to associate with the row.
359
- * @sealed @alpha
367
+ * @sealed @beta
360
368
  */
361
369
  interface Row<TCell extends ImplicitAllowedTypes, TProps extends ImplicitFieldSchema = ImplicitFieldSchema> {
362
370
  /**
@@ -378,7 +386,7 @@ export declare namespace TableSchema {
378
386
  * Factory for creating new table column schema.
379
387
  * @typeParam TUserScope - The {@link SchemaFactory.scope | schema factory scope}.
380
388
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
381
- * @alpha
389
+ * @beta
382
390
  */
383
391
  function row<const TUserScope extends string, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.CreateRowOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell>): System_TableSchema.RowSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>;
384
392
  /**
@@ -386,7 +394,7 @@ export declare namespace TableSchema {
386
394
  * @typeParam TUserScope - The {@link SchemaFactory.scope | schema factory scope}.
387
395
  * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
388
396
  * @typeParam TProps - Additional properties to associate with the row.
389
- * @alpha
397
+ * @beta
390
398
  */
391
399
  function row<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateRowOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
392
400
  /**
@@ -396,7 +404,12 @@ export declare namespace TableSchema {
396
404
  }): System_TableSchema.RowSchemaBase<TUserScope, TCell, TProps>;
397
405
  /**
398
406
  * A key to uniquely identify a cell within a table.
399
- * @input @alpha
407
+ *
408
+ * @remarks
409
+ * Note that edits to the table structure (including edits by collaborators) can cause indexes to refer to different cells over time.
410
+ * Therefore, it is recommended to use IDs or node references whenever possible to identify cells.
411
+ *
412
+ * @input @beta
400
413
  */
401
414
  interface CellKey<TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
402
415
  /**
@@ -410,7 +423,7 @@ export declare namespace TableSchema {
410
423
  }
411
424
  /**
412
425
  * {@link TableSchema.Table.insertColumns} parameters.
413
- * @input @alpha
426
+ * @input @beta
414
427
  */
415
428
  interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
416
429
  /**
@@ -425,7 +438,7 @@ export declare namespace TableSchema {
425
438
  }
426
439
  /**
427
440
  * {@link TableSchema.Table.insertRows} parameters.
428
- * @input @alpha
441
+ * @input @beta
429
442
  */
430
443
  interface InsertRowsParameters<TRow extends ImplicitAllowedTypes> {
431
444
  /**
@@ -440,7 +453,7 @@ export declare namespace TableSchema {
440
453
  }
441
454
  /**
442
455
  * {@link TableSchema.Table.setCell} parameters.
443
- * @input @alpha
456
+ * @input @beta
444
457
  */
445
458
  interface SetCellParameters<TCell extends ImplicitAllowedTypes, TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
446
459
  /**
@@ -464,7 +477,7 @@ export declare namespace TableSchema {
464
477
  * @typeParam TColumn - The type of the columns in the table.
465
478
  * @typeParam TRow - The type of the rows in the table.
466
479
  *
467
- * @sealed @alpha
480
+ * @sealed @beta
468
481
  */
469
482
  interface Table<TUserScope extends string, TCell extends ImplicitAllowedTypes, TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>, TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>> {
470
483
  /**
@@ -482,6 +495,11 @@ export declare namespace TableSchema {
482
495
  getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
483
496
  /**
484
497
  * Gets a table column by its index in the table.
498
+ *
499
+ * @remarks
500
+ * Note that edits to the table structure (including edits by collaborators) can cause indexes to refer to different columns over time.
501
+ * Therefore, it is recommended to use IDs whenever possible to identify columns.
502
+ *
485
503
  * @returns The column, if it exists. Otherwise, `undefined`.
486
504
  */
487
505
  getColumn(index: number): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
@@ -492,6 +510,11 @@ export declare namespace TableSchema {
492
510
  getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
493
511
  /**
494
512
  * Gets a table row by its index in the table.
513
+ *
514
+ * @remarks
515
+ * Note that edits to the table structure (including edits by collaborators) can cause indexes to refer to different rows over time.
516
+ * Therefore, it is recommended to use IDs whenever possible to identify rows.
517
+ *
495
518
  * @returns The row, if it exists. Otherwise, `undefined`.
496
519
  */
497
520
  getRow(index: number): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
@@ -600,7 +623,7 @@ export declare namespace TableSchema {
600
623
  }
601
624
  /**
602
625
  * Input parameters for {@link TableSchema.Table}'s `create` factory method.
603
- * @input @alpha
626
+ * @input @beta
604
627
  */
605
628
  interface TableFactoryMethodParameters<TUserScope extends string, TCell extends ImplicitAllowedTypes, TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>, TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>> {
606
629
  /**
@@ -618,7 +641,7 @@ export declare namespace TableSchema {
618
641
  * @typeParam TUserScope - The {@link SchemaFactory.scope | schema factory scope}.
619
642
  * The resulting schema will have an identifier of the form: `com.fluidframework.table<${TUserScope}>.Table`.
620
643
  * @typeParam TCell - The type of the cells in the table.
621
- * @alpha
644
+ * @beta
622
645
  */
623
646
  function table<const TUserScope extends string, const TCell extends ImplicitAllowedTypes>(params: System_TableSchema.TableFactoryOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell>): System_TableSchema.TableSchemaBase<TUserScope, TCell, System_TableSchema.ColumnSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>, System_TableSchema.RowSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>>;
624
647
  /**
@@ -627,7 +650,7 @@ export declare namespace TableSchema {
627
650
  * The resulting schema will have an identifier of the form: `com.fluidframework.table<${TUserScope}>.Table`.
628
651
  * @typeParam TCell - The type of the cells in the table.
629
652
  * @typeParam TColumn - The type of the columns in the table.
630
- * @alpha
653
+ * @beta
631
654
  */
632
655
  function table<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
633
656
  readonly column: TColumn;
@@ -638,7 +661,7 @@ export declare namespace TableSchema {
638
661
  * The resulting schema will have an identifier of the form: `com.fluidframework.table<${TUserScope}>.Table`.
639
662
  * @typeParam TCell - The type of the cells in the table.
640
663
  * @typeParam TRow - The type of the rows in the table.
641
- * @alpha
664
+ * @beta
642
665
  */
643
666
  function table<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
644
667
  readonly row: TRow;
@@ -650,7 +673,7 @@ export declare namespace TableSchema {
650
673
  * @typeParam TCell - The type of the cells in the table.
651
674
  * @typeParam TColumn - The type of the columns in the table.
652
675
  * @typeParam TRow - The type of the rows in the table.
653
- * @alpha
676
+ * @beta
654
677
  */
655
678
  function table<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>, const TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>>(params: System_TableSchema.TableFactoryOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
656
679
  readonly column: TColumn;