@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
@@ -89,6 +89,11 @@ Kind
89
89
  // @beta
90
90
  export function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;
91
91
 
92
+ // @beta @input
93
+ export interface CodecWriteOptionsBeta {
94
+ readonly minVersionForCollab: MinimumVersionForCollab;
95
+ }
96
+
92
97
  // @public
93
98
  export enum CommitKind {
94
99
  Default = 0,
@@ -574,7 +579,7 @@ export const SharedTreeAttributes: IChannelAttributes;
574
579
  export const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
575
580
 
576
581
  // @beta @input
577
- export type SharedTreeOptionsBeta = ForestOptions;
582
+ export type SharedTreeOptionsBeta = ForestOptions & Partial<CodecWriteOptionsBeta>;
578
583
 
579
584
  // @public @sealed @system
580
585
  export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
@@ -587,6 +592,69 @@ export function singletonSchema<TScope extends string, TName extends string | nu
587
592
  readonly value: TName;
588
593
  }, Record<string, never>, true, Record<string, never>, undefined>;
589
594
 
595
+ // @beta @system
596
+ export namespace System_TableSchema {
597
+ // @sealed @system
598
+ export type ColumnSchemaBase<TUserScope extends string = string, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createColumnSchema<TUserScope, TCellSchema, TPropsSchema>>;
599
+ // @system
600
+ export type CreateColumnOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
601
+ // @system
602
+ export 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 & {
603
+ readonly id?: string | undefined;
604
+ } & (FieldHasDefault<TPropsSchema> extends true ? {
605
+ props?: InsertableTreeFieldFromImplicitField<TPropsSchema> | undefined;
606
+ } : {
607
+ props: InsertableTreeFieldFromImplicitField<TPropsSchema>;
608
+ }), true, {
609
+ readonly props: TPropsSchema;
610
+ readonly id: FieldSchema_2<FieldKind_2.Identifier, LeafSchema_2<"string", string>, unknown>;
611
+ }>;
612
+ // @system
613
+ export type CreateRowOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
614
+ // @system
615
+ export 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 & {
616
+ readonly id?: string | undefined;
617
+ readonly cells: (InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>> | undefined) & InsertableTypedNode_2<TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>>;
618
+ } & (FieldHasDefault<TPropsSchema> extends true ? {
619
+ props?: InsertableTreeFieldFromImplicitField<TPropsSchema> | undefined;
620
+ } : {
621
+ props: InsertableTreeFieldFromImplicitField<TPropsSchema>;
622
+ }), true, {
623
+ readonly props: TPropsSchema;
624
+ readonly id: FieldSchema_2<FieldKind_2.Identifier, LeafSchema_2<"string", string>, unknown>;
625
+ readonly cells: FieldSchema_2<FieldKind_2.Required, TreeNodeSchemaClass<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, TreeRecordNode<TCellSchema> & WithType<ScopedSchemaName<`com.fluidframework.tableV2<${TUserScope}>`, "Row.cells">, NodeKind.Record, unknown>, RecordNodeInsertableData_2<TCellSchema>, true, TCellSchema, undefined, unknown>, unknown>;
626
+ }>;
627
+ // @system
628
+ export 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): {
629
+ 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>;
630
+ } & (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>);
631
+ // @system
632
+ export type DefaultPropsType = ReturnType<typeof SchemaFactory.optional<[]>>;
633
+ // @system
634
+ export interface OptionsWithCellSchema<TCellSchema extends ImplicitAllowedTypes> {
635
+ readonly cell: TCellSchema;
636
+ }
637
+ // @system
638
+ export interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryBeta> {
639
+ readonly schemaFactory: TSchemaFactory;
640
+ }
641
+ // @system
642
+ export type RearrangeableList<TItemSchema extends ImplicitAllowedTypes> = TreeNode & readonly TreeNodeFromImplicitAllowedTypes<TItemSchema>[] & {
643
+ moveToEnd(sourceIndex: number): void;
644
+ moveToStart(sourceIndex: number): void;
645
+ moveToIndex(sourceIndex: number, destinationIndex: number): void;
646
+ moveRangeToEnd(startIndex: number, endIndex: number): void;
647
+ moveRangeToStart(startIndex: number, endIndex: number): void;
648
+ moveRangeToIndex(startIndex: number, endIndex: number, destinationIndex: number): void;
649
+ };
650
+ // @sealed @system
651
+ export type RowSchemaBase<TUserScope extends string = string, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes, TPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema> = ReturnType<typeof createRowSchema<TUserScope, TCellSchema, TPropsSchema>>;
652
+ // @system
653
+ export type TableFactoryOptionsBase<TUserScope extends string = string, TSchemaFactory extends SchemaFactoryBeta<TUserScope> = SchemaFactoryBeta<TUserScope>, TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCellSchema>;
654
+ // @sealed @system
655
+ export 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>>;
656
+ }
657
+
590
658
  // @public @system
591
659
  export namespace System_Unsafe {
592
660
  // @system
@@ -670,6 +738,86 @@ export namespace System_Unsafe {
670
738
  export type TreeObjectNodeUnsafe<T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecordUnsafe<T> & WithType<TypeName, NodeKind.Object, T>;
671
739
  }
672
740
 
741
+ // @beta
742
+ export namespace TableSchema {
743
+ // @input
744
+ export interface CellKey<TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
745
+ readonly column: string | number | TreeNodeFromImplicitAllowedTypes<TColumn>;
746
+ readonly row: string | number | TreeNodeFromImplicitAllowedTypes<TRow>;
747
+ }
748
+ // @sealed
749
+ export interface Column<TCell extends ImplicitAllowedTypes, TProps extends ImplicitFieldSchema = ImplicitFieldSchema> {
750
+ readonly id: string;
751
+ get props(): TreeFieldFromImplicitField<TProps>;
752
+ set props(value: InsertableTreeFieldFromImplicitField<TProps>);
753
+ }
754
+ export 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>;
755
+ export function column<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateColumnOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
756
+ readonly props: TProps;
757
+ }): System_TableSchema.ColumnSchemaBase<TUserScope, TCell, TProps>;
758
+ // @input
759
+ export interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
760
+ readonly columns: InsertableTreeNodeFromImplicitAllowedTypes<TColumn>[];
761
+ readonly index?: number | undefined;
762
+ }
763
+ // @input
764
+ export interface InsertRowsParameters<TRow extends ImplicitAllowedTypes> {
765
+ readonly index?: number | undefined;
766
+ readonly rows: InsertableTreeNodeFromImplicitAllowedTypes<TRow>[];
767
+ }
768
+ // @sealed
769
+ export interface Row<TCell extends ImplicitAllowedTypes, TProps extends ImplicitFieldSchema = ImplicitFieldSchema> {
770
+ readonly id: string;
771
+ get props(): TreeFieldFromImplicitField<TProps>;
772
+ set props(value: InsertableTreeFieldFromImplicitField<TProps>);
773
+ }
774
+ export 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>;
775
+ export function row<const TUserScope extends string, const TCell extends ImplicitAllowedTypes, const TProps extends ImplicitFieldSchema>(params: System_TableSchema.CreateRowOptionsBase<TUserScope, SchemaFactoryBeta<TUserScope>, TCell> & {
776
+ readonly props: TProps;
777
+ }): System_TableSchema.RowSchemaBase<TUserScope, TCell, TProps>;
778
+ // @input
779
+ export interface SetCellParameters<TCell extends ImplicitAllowedTypes, TColumn extends ImplicitAllowedTypes, TRow extends ImplicitAllowedTypes> {
780
+ readonly cell: InsertableTreeNodeFromImplicitAllowedTypes<TCell>;
781
+ readonly key: CellKey<TColumn, TRow>;
782
+ }
783
+ // @sealed
784
+ export interface Table<TUserScope extends string, TCell extends ImplicitAllowedTypes, TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>, TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>> {
785
+ readonly columns: System_TableSchema.RearrangeableList<TColumn>;
786
+ getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
787
+ getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
788
+ getColumn(index: number): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
789
+ getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
790
+ getRow(index: number): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
791
+ insertColumns(params: InsertColumnsParameters<TColumn>): TreeNodeFromImplicitAllowedTypes<TColumn>[];
792
+ insertRows(params: InsertRowsParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>[];
793
+ removeCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
794
+ removeColumns(index?: number | undefined, count?: number | undefined): TreeNodeFromImplicitAllowedTypes<TColumn>[];
795
+ removeColumns(columns: readonly TreeNodeFromImplicitAllowedTypes<TColumn>[]): TreeNodeFromImplicitAllowedTypes<TColumn>[];
796
+ removeColumns(columns: readonly string[]): TreeNodeFromImplicitAllowedTypes<TColumn>[];
797
+ removeRows(index?: number | undefined, count?: number | undefined): TreeNodeFromImplicitAllowedTypes<TRow>[];
798
+ removeRows(rows: readonly TreeNodeFromImplicitAllowedTypes<TRow>[]): TreeNodeFromImplicitAllowedTypes<TRow>[];
799
+ removeRows(rows: readonly string[]): TreeNodeFromImplicitAllowedTypes<TRow>[];
800
+ readonly rows: System_TableSchema.RearrangeableList<TRow>;
801
+ setCell(params: SetCellParameters<TCell, TColumn, TRow>): void;
802
+ }
803
+ export 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>>;
804
+ export 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> & {
805
+ readonly column: TColumn;
806
+ }): System_TableSchema.TableSchemaBase<TUserScope, TCell, TColumn, System_TableSchema.RowSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>>;
807
+ export 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> & {
808
+ readonly row: TRow;
809
+ }): System_TableSchema.TableSchemaBase<TUserScope, TCell, System_TableSchema.ColumnSchemaBase<TUserScope, TCell, System_TableSchema.DefaultPropsType>, TRow>;
810
+ export 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> & {
811
+ readonly column: TColumn;
812
+ readonly row: TRow;
813
+ }): System_TableSchema.TableSchemaBase<TUserScope, TCell, TColumn, TRow>;
814
+ // @input
815
+ export interface TableFactoryMethodParameters<TUserScope extends string, TCell extends ImplicitAllowedTypes, TColumn extends System_TableSchema.ColumnSchemaBase<TUserScope, TCell>, TRow extends System_TableSchema.RowSchemaBase<TUserScope, TCell>> {
816
+ readonly columns?: Iterable<InsertableTreeNodeFromImplicitAllowedTypes<TColumn>> | undefined;
817
+ readonly rows?: Iterable<InsertableTreeNodeFromImplicitAllowedTypes<TRow>> | undefined;
818
+ }
819
+ }
820
+
673
821
  // @public
674
822
  export type TransactionConstraint = NodeInDocumentConstraint;
675
823
 
@@ -699,6 +847,7 @@ export interface TreeArrayNode<TAllowedTypes extends System_Unsafe.ImplicitAllow
699
847
  moveToIndex(destinationGap: number, sourceIndex: number, source: TMoveFrom): void;
700
848
  moveToStart(sourceIndex: number): void;
701
849
  moveToStart(sourceIndex: number, source: TMoveFrom): void;
850
+ push(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
702
851
  removeAt(index: number): void;
703
852
  removeRange(start?: number, end?: number): void;
704
853
  values(): IterableIterator<T>;
@@ -476,6 +476,7 @@ export interface TreeArrayNode<TAllowedTypes extends System_Unsafe.ImplicitAllow
476
476
  moveToIndex(destinationGap: number, sourceIndex: number, source: TMoveFrom): void;
477
477
  moveToStart(sourceIndex: number): void;
478
478
  moveToStart(sourceIndex: number, source: TMoveFrom): void;
479
+ push(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
479
480
  removeAt(index: number): void;
480
481
  removeRange(start?: number, end?: number): void;
481
482
  values(): IterableIterator<T>;
@@ -476,6 +476,7 @@ export interface TreeArrayNode<TAllowedTypes extends System_Unsafe.ImplicitAllow
476
476
  moveToIndex(destinationGap: number, sourceIndex: number, source: TMoveFrom): void;
477
477
  moveToStart(sourceIndex: number): void;
478
478
  moveToStart(sourceIndex: number, source: TMoveFrom): void;
479
+ push(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
479
480
  removeAt(index: number): void;
480
481
  removeRange(start?: number, end?: number): void;
481
482
  values(): IterableIterator<T>;
package/dist/alpha.d.ts CHANGED
@@ -105,6 +105,7 @@ export {
105
105
  AnnotatedAllowedTypeUnsafe,
106
106
  AnnotatedAllowedTypes,
107
107
  AnnotatedAllowedTypesUnsafe,
108
+ CodecWriteOptionsBeta,
108
109
  ConciseTree,
109
110
  FixRecursiveArraySchema,
110
111
  FluidSerializableAsTree,
@@ -124,6 +125,8 @@ export {
124
125
  SchemaStaticsBeta,
125
126
  SchemaUpgrade,
126
127
  SharedTreeOptionsBeta,
128
+ System_TableSchema,
129
+ TableSchema,
127
130
  TreeBeta,
128
131
  TreeBranch,
129
132
  TreeChangeEventsBeta,
@@ -149,12 +152,15 @@ export {
149
152
  ArrayNodeCustomizableSchemaUnsafe,
150
153
  ArrayNodePojoEmulationSchema,
151
154
  ArrayNodeSchema,
155
+ ArrayPlaceAnchor,
152
156
  BranchableTree,
153
157
  ChangeMetadata,
154
158
  CodecName,
155
159
  CodecWriteOptions,
160
+ CreateIndependentTreeAlphaOptions,
156
161
  DirtyTreeMap,
157
162
  DirtyTreeStatus,
163
+ ExtensibleSchemaUnion,
158
164
  FactoryContent,
159
165
  FactoryContentObject,
160
166
  FieldPropsAlpha,
@@ -170,6 +176,7 @@ export {
170
176
  ITreeAlpha,
171
177
  IdentifierIndex,
172
178
  IncrementalEncodingPolicy,
179
+ IndependentViewOptions,
173
180
  Insertable,
174
181
  InsertableContent,
175
182
  InsertableField,
@@ -228,8 +235,6 @@ export {
228
235
  SimpleTreeIndex,
229
236
  SimpleTreeSchema,
230
237
  SnapshotFileSystem,
231
- System_TableSchema,
232
- TableSchema,
233
238
  TransactionCallbackStatus,
234
239
  TransactionConstraintAlpha,
235
240
  TransactionResult,
@@ -265,6 +270,7 @@ export {
265
270
  comparePersistedSchema,
266
271
  configuredSharedTreeAlpha,
267
272
  contentSchemaSymbol,
273
+ createArrayInsertionAnchor,
268
274
  createIdentifierIndex,
269
275
  createIndependentTreeAlpha,
270
276
  createSimpleTreeIndex,
package/dist/beta.d.ts CHANGED
@@ -105,6 +105,7 @@ export {
105
105
  AnnotatedAllowedTypeUnsafe,
106
106
  AnnotatedAllowedTypes,
107
107
  AnnotatedAllowedTypesUnsafe,
108
+ CodecWriteOptionsBeta,
108
109
  ConciseTree,
109
110
  FixRecursiveArraySchema,
110
111
  FluidSerializableAsTree,
@@ -124,6 +125,8 @@ export {
124
125
  SchemaStaticsBeta,
125
126
  SchemaUpgrade,
126
127
  SharedTreeOptionsBeta,
128
+ System_TableSchema,
129
+ TableSchema,
127
130
  TreeBeta,
128
131
  TreeBranch,
129
132
  TreeChangeEventsBeta,
@@ -6,7 +6,6 @@ import { IsoBuffer } from "@fluid-internal/client-utils";
6
6
  import type { ErasedType } from "@fluidframework/core-interfaces/internal";
7
7
  import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { Static, TAnySchema, TSchema } from "@sinclair/typebox";
9
- import type { ChangeEncodingContext } from "../core/index.js";
10
9
  import type { JsonCompatibleReadOnly } from "../util/index.js";
11
10
  /**
12
11
  * Translates decoded data to encoded data.
@@ -113,11 +112,9 @@ export interface ICodecOptions {
113
112
  }
114
113
  /**
115
114
  * Options relating to encoding of persisted data.
116
- * @remarks
117
- * Extends {@link ICodecOptions} with options that are specific to encoding data.
118
- * @alpha @input
115
+ * @input @beta
119
116
  */
120
- export interface CodecWriteOptions extends ICodecOptions {
117
+ export interface CodecWriteOptionsBeta {
121
118
  /**
122
119
  * The minimum version of the Fluid Framework client output must be encoded to be compatible with.
123
120
  * @remarks
@@ -128,14 +125,22 @@ export interface CodecWriteOptions extends ICodecOptions {
128
125
  * the data's format should be versioned and if they can't handle the format they should error.
129
126
  */
130
127
  readonly minVersionForCollab: MinimumVersionForCollab;
128
+ }
129
+ /**
130
+ * Options relating to encoding of persisted data.
131
+ * @remarks
132
+ * Extends {@link ICodecOptions} with options that are specific to encoding data.
133
+ * @alpha @input
134
+ */
135
+ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {
131
136
  /**
132
137
  * Overrides the version of the codec to use for encoding.
133
138
  * @remarks
134
- * Without an override, the selected version will be based on {@link CodecWriteOptions.minVersionForCollab}.
139
+ * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.
135
140
  */
136
141
  readonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;
137
142
  /**
138
- * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptions.minVersionForCollab}.
143
+ * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.
139
144
  */
140
145
  readonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;
141
146
  }
@@ -162,6 +167,10 @@ export interface CodecWriteOptions extends ICodecOptions {
162
167
  export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TContext = void> extends IEncoder<TDecoded, TEncoded, TContext>, IDecoder<TDecoded, TValidate, TContext> {
163
168
  encodedSchema?: TAnySchema;
164
169
  }
170
+ /**
171
+ * Type erase the more detailed encoded type from a codec.
172
+ */
173
+ export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TContext = void>(codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TValidate, TValidate, TContext>;
165
174
  /**
166
175
  * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.
167
176
  */
@@ -281,7 +290,7 @@ export declare const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, Jso
281
290
  * Wraps a codec with JSON schema validation for its encoded type.
282
291
  * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
283
292
  */
284
- export declare function withSchemaValidation<TInMemoryFormat, EncodedSchema extends TSchema, TEncodedFormat = JsonCompatibleReadOnly, TValidate = TEncodedFormat, TContext = ChangeEncodingContext>(schema: EncodedSchema, codec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>, validator?: JsonValidator | FormatValidator): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>;
293
+ export declare function withSchemaValidation<TInMemoryFormat, EncodedSchema extends TSchema, TEncodedFormat, TValidate, TContext>(schema: EncodedSchema, codec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>, validator?: JsonValidator | FormatValidator): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>;
285
294
  /**
286
295
  * Versions of Fluid Framework client packages.
287
296
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,Q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IAC9B;;;;;;OAMG;IAGH;;OAEG;;IAGH,4CAA4C;IAM5C;;;;;;;;OAQG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;OAQG;;CAEwD,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,uBAA2D,CAAC;AAEzF,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,sBAAsB,CAMzE"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.jsonableCodecTree = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.ensureBinaryEncoding = exports.withDefaultBinaryEncoding = exports.makeCodecFamily = exports.DependentFormatVersion = exports.MappedDependentFormatVersion = exports.UniqueDependentFormatVersion = exports.extractJsonValidator = exports.toFormatValidator = exports.FormatValidatorNoOp = void 0;
7
+ exports.jsonableCodecTree = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.ensureBinaryEncoding = exports.withDefaultBinaryEncoding = exports.makeCodecFamily = exports.DependentFormatVersion = exports.MappedDependentFormatVersion = exports.UniqueDependentFormatVersion = exports.eraseEncodedType = exports.extractJsonValidator = exports.toFormatValidator = exports.FormatValidatorNoOp = void 0;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/runtime-utils/internal");
@@ -35,6 +35,13 @@ function extractJsonValidator(input) {
35
35
  return input;
36
36
  }
37
37
  exports.extractJsonValidator = extractJsonValidator;
38
+ /**
39
+ * Type erase the more detailed encoded type from a codec.
40
+ */
41
+ function eraseEncodedType(codec) {
42
+ return codec;
43
+ }
44
+ exports.eraseEncodedType = eraseEncodedType;
38
45
  class UniqueDependentFormatVersion {
39
46
  constructor(child) {
40
47
  this.child = child;
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAEzE,kEAAmE;AAEnE,qEAAoH;AA2DpH;;;;GAIG;AACH,MAAM,aAAa,GAAkB;IACpC,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC;AAEF;;;GAGG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEpE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAsB;IACvD,OAAO,OAAqC,CAAC;AAC9C,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAsC;IAC1E,OAAO,KAAiC,CAAC;AAC1C,CAAC;AAFD,oDAEC;AA0MD,MAAa,4BAA4B;IAGxC,YAAoC,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IACrD,MAAM,CAAC,OAAsB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAPD,oEAOC;AAED,MAAa,4BAA4B;IAKxC,YAAoC,GAA+C;QAA/C,QAAG,GAAH,GAAG,CAA4C;IAAG,CAAC;IAChF,MAAM,CAAC,MAAsB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACzE,CAAC;CACD;AATD,oEASC;AAEY,QAAA,sBAAsB,GAAG;IACr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E,QAAQ;CAC4C,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACU,QAAA,cAAc,GAA4B,gCAAiC,CAAC;AAQzF,SAAgB,iBAAiB,CAAC,IAAe;IAChD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;KAC/C,CAAC;AACH,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { ChangeEncodingContext } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab;\n\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptions.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptions.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<\n\tTDecoded,\n\tTContext,\n\tTEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n>(\n\tjsonCodec: IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<\n\tTDecoded,\n\tTContext,\n\tTEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages.\n * @remarks\n * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.\n *\n * When no compatibility-impacting change is made in a given version, the value associated with its enum entry may point to the older version which it's fully compatible with.\n * Note that this can change if a future version of the framework introduces an option to use something which is only supported at a particular version. In which case, the values of the enum may shift,\n * but the semantics of keys in this enum will not change.\n *\n * Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.\n *\n * Some release may also be omitted if there is currently no need to express that specific version.\n * If the need arises, they might be added in the future.\n *\n * @privateRemarks\n * The entries in these enums should document the following:\n * - The user facing impact of opting into a particular version. This will help customers decide if they want to opt into\n * a new version. For example, document if there is an encoding efficiency improvement of oping into that version or newer.\n * - Any new data formats that are introduced in that version. This will help developers tell which data formats a given\n * version will write. For example, document if a new summary or encoding format is added in a version.\n * - Whether the above features or data formats introduced in a version are enabled by default or require the\n * {@link minVersionForCollab} option to be set to that particular version.\n *\n * Versions with no notable impact can be omitted.\n *\n * This scheme assumes a single version will always be enough to communicate compatibility.\n * For this to work, compatibility has to be strictly increasing.\n * If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),\n * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:\n * such a system can be added if/when its needed since it will be opt in and thus non-breaking.\n *\n * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.\n * TODO: compatibility requirements for how this enum can and cannot be changed should be clarified when/if it's used across multiple layers in the stack.\n * For example, if needed, would adding more leading zeros to the minor version break things.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 1.4 and newer.\n\t * @remarks\n\t * This opts into support for the 1.4 LTS branch.\n\t * @privateRemarks\n\t * As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.\n\t */\n\t// v1_4 = 1.004,\n\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/** Fluid Framework Client 2.1 and newer. */\n\t// If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),\n\t// we could add an entry like this to allow users to indicate that they can be opted in once we are ready,\n\t// then update it to \"2.001\" once we actually have the opt in working.\n\t// v2_1 = v2_0,\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n} as const satisfies Record<string, MinimumVersionForCollab>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid MinimumVersionForCollab\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: MinimumVersionForCollab = runtimeUtilsCleanedPackageVersion;\n\nexport interface CodecTree {\n\treadonly name: string;\n\treadonly version: FormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAEzE,kEAAmE;AAEnE,qEAAoH;AA0DpH;;;;GAIG;AACH,MAAM,aAAa,GAAkB;IACpC,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC;AAEF;;;GAGG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC,a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,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAmB,EAAE;YAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAClD,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,kBAAkB,GAAG;IACjC;;;;;;OAMG;IACH,gBAAgB;IAEhB;;OAEG;IACH,IAAI,EAAE,OAAO;IAEb,4CAA4C;IAC5C,8HAA8H;IAC9H,0GAA0G;IAC1G,sEAAsE;IACtE,eAAe;IAEf;;;;;;;;OAQG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;OAKG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;OAKG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;;;;;;;OAWG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;;;;OAQG;IACH,KAAK,EAAE,QAAQ;CAC4C,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACU,QAAA,cAAc,GAA4B,gCAAiC,CAAC;AAQzF,SAAgB,iBAAiB,CAAC,IAAe;IAChD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;KAC/C,CAAC;AACH,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @input @beta\n */\nexport interface CodecWriteOptionsBeta {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * Type erase the more detailed encoded type from a codec.\n */\nexport function eraseEncodedType<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TValidate, TValidate, TContext> {\n\treturn codec as unknown as IJsonCodec<TDecoded, TValidate, TValidate, TContext>;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json) as JsonCompatibleReadOnly;\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<\n\tTDecoded,\n\tTContext,\n\tTEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n>(\n\tjsonCodec: IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<\n\tTDecoded,\n\tTContext,\n\tTEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat,\n\tTValidate,\n\tTContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Encoded schema should validate */);\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages.\n * @remarks\n * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.\n *\n * When no compatibility-impacting change is made in a given version, the value associated with its enum entry may point to the older version which it's fully compatible with.\n * Note that this can change if a future version of the framework introduces an option to use something which is only supported at a particular version. In which case, the values of the enum may shift,\n * but the semantics of keys in this enum will not change.\n *\n * Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.\n *\n * Some release may also be omitted if there is currently no need to express that specific version.\n * If the need arises, they might be added in the future.\n *\n * @privateRemarks\n * The entries in these enums should document the following:\n * - The user facing impact of opting into a particular version. This will help customers decide if they want to opt into\n * a new version. For example, document if there is an encoding efficiency improvement of oping into that version or newer.\n * - Any new data formats that are introduced in that version. This will help developers tell which data formats a given\n * version will write. For example, document if a new summary or encoding format is added in a version.\n * - Whether the above features or data formats introduced in a version are enabled by default or require the\n * {@link minVersionForCollab} option to be set to that particular version.\n *\n * Versions with no notable impact can be omitted.\n *\n * This scheme assumes a single version will always be enough to communicate compatibility.\n * For this to work, compatibility has to be strictly increasing.\n * If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),\n * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:\n * such a system can be added if/when its needed since it will be opt in and thus non-breaking.\n *\n * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.\n * TODO: compatibility requirements for how this enum can and cannot be changed should be clarified when/if it's used across multiple layers in the stack.\n * For example, if needed, would adding more leading zeros to the minor version break things.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 1.4 and newer.\n\t * @remarks\n\t * This opts into support for the 1.4 LTS branch.\n\t * @privateRemarks\n\t * As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.\n\t */\n\t// v1_4 = 1.004,\n\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/** Fluid Framework Client 2.1 and newer. */\n\t// If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),\n\t// we could add an entry like this to allow users to indicate that they can be opted in once we are ready,\n\t// then update it to \"2.001\" once we actually have the opt in working.\n\t// v2_1 = v2_0,\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n} as const satisfies Record<string, MinimumVersionForCollab>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid MinimumVersionForCollab\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: MinimumVersionForCollab = runtimeUtilsCleanedPackageVersion;\n\nexport interface CodecTree {\n\treadonly name: string;\n\treadonly version: FormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { type FormatVersion, DependentFormatVersion, type IBinaryCodec, type ICodecFamily, type ICodecOptions, type CodecWriteOptions, type IDecoder, type IEncoder, type IJsonCodec, type IMultiFormatCodec, type JsonValidator, makeCodecFamily, type SchemaValidationFunction, unitCodec, withDefaultBinaryEncoding, withSchemaValidation, FluidClientVersion, currentVersion, toFormatValidator, FormatValidatorNoOp, type FormatValidator, type CodecTree, jsonableCodecTree, extractJsonValidator, type CodecName, } from "./codec.js";
5
+ export { type FormatVersion, DependentFormatVersion, type IBinaryCodec, type ICodecFamily, type ICodecOptions, type CodecWriteOptions, type CodecWriteOptionsBeta, type IDecoder, type IEncoder, type IJsonCodec, type IMultiFormatCodec, type JsonValidator, makeCodecFamily, type SchemaValidationFunction, unitCodec, withDefaultBinaryEncoding, withSchemaValidation, FluidClientVersion, currentVersion, toFormatValidator, FormatValidatorNoOp, type FormatValidator, type CodecTree, jsonableCodecTree, extractJsonValidator, type CodecName, eraseEncodedType, } from "./codec.js";
6
6
  export { DiscriminatedUnionDispatcher, type DiscriminatedUnionLibrary, unionOptions, } from "./discriminatedUnions.js";
7
7
  export { Versioned, makeVersionedValidatedCodec, makeVersionDispatchingCodec, makeDiscontinuedCodecVersion, ClientVersionDispatchingCodecBuilder, type CodecVersion, type CodecAndSchema, } from "./versioned/index.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,wBAAwB,EAC7B,SAAS,EACT,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,SAAS,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,KAAK,YAAY,EACjB,KAAK,cAAc,GACnB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,wBAAwB,EAC7B,SAAS,EACT,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,SAAS,EACd,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,oCAAoC,EACpC,KAAK,YAAY,EACjB,KAAK,cAAc,GACnB,MAAM,sBAAsB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ClientVersionDispatchingCodecBuilder = exports.makeDiscontinuedCodecVersion = exports.makeVersionDispatchingCodec = exports.makeVersionedValidatedCodec = exports.Versioned = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.extractJsonValidator = exports.jsonableCodecTree = exports.FormatValidatorNoOp = exports.toFormatValidator = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.withDefaultBinaryEncoding = exports.unitCodec = exports.makeCodecFamily = exports.DependentFormatVersion = void 0;
7
+ exports.ClientVersionDispatchingCodecBuilder = exports.makeDiscontinuedCodecVersion = exports.makeVersionDispatchingCodec = exports.makeVersionedValidatedCodec = exports.Versioned = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.eraseEncodedType = exports.extractJsonValidator = exports.jsonableCodecTree = exports.FormatValidatorNoOp = exports.toFormatValidator = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.withDefaultBinaryEncoding = exports.unitCodec = exports.makeCodecFamily = exports.DependentFormatVersion = void 0;
8
8
  var codec_js_1 = require("./codec.js");
9
9
  Object.defineProperty(exports, "DependentFormatVersion", { enumerable: true, get: function () { return codec_js_1.DependentFormatVersion; } });
10
10
  Object.defineProperty(exports, "makeCodecFamily", { enumerable: true, get: function () { return codec_js_1.makeCodecFamily; } });
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "toFormatValidator", { enumerable: true, get: fun
17
17
  Object.defineProperty(exports, "FormatValidatorNoOp", { enumerable: true, get: function () { return codec_js_1.FormatValidatorNoOp; } });
18
18
  Object.defineProperty(exports, "jsonableCodecTree", { enumerable: true, get: function () { return codec_js_1.jsonableCodecTree; } });
19
19
  Object.defineProperty(exports, "extractJsonValidator", { enumerable: true, get: function () { return codec_js_1.extractJsonValidator; } });
20
+ Object.defineProperty(exports, "eraseEncodedType", { enumerable: true, get: function () { return codec_js_1.eraseEncodedType; } });
20
21
  var discriminatedUnions_js_1 = require("./discriminatedUnions.js");
21
22
  Object.defineProperty(exports, "DiscriminatedUnionDispatcher", { enumerable: true, get: function () { return discriminatedUnions_js_1.DiscriminatedUnionDispatcher; } });
22
23
  Object.defineProperty(exports, "unionOptions", { enumerable: true, get: function () { return discriminatedUnions_js_1.unionOptions; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCA0BoB;AAxBnB,kHAAA,sBAAsB,OAAA;AAUtB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,qHAAA,yBAAyB,OAAA;AACzB,gHAAA,oBAAoB,OAAA;AACpB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AAGnB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AAGrB,mEAIkC;AAHjC,sIAAA,4BAA4B,OAAA;AAE5B,sHAAA,YAAY,OAAA;AAEb,iDAQ8B;AAP7B,qGAAA,SAAS,OAAA;AACT,uHAAA,2BAA2B,OAAA;AAC3B,uHAAA,2BAA2B,OAAA;AAC3B,wHAAA,4BAA4B,OAAA;AAC5B,gIAAA,oCAAoC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FormatVersion,\n\tDependentFormatVersion,\n\ttype IBinaryCodec,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n\ttype IDecoder,\n\ttype IEncoder,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype JsonValidator,\n\tmakeCodecFamily,\n\ttype SchemaValidationFunction,\n\tunitCodec,\n\twithDefaultBinaryEncoding,\n\twithSchemaValidation,\n\tFluidClientVersion,\n\tcurrentVersion,\n\ttoFormatValidator,\n\tFormatValidatorNoOp,\n\ttype FormatValidator,\n\ttype CodecTree,\n\tjsonableCodecTree,\n\textractJsonValidator,\n\ttype CodecName,\n} from \"./codec.js\";\nexport {\n\tDiscriminatedUnionDispatcher,\n\ttype DiscriminatedUnionLibrary,\n\tunionOptions,\n} from \"./discriminatedUnions.js\";\nexport {\n\tVersioned,\n\tmakeVersionedValidatedCodec,\n\tmakeVersionDispatchingCodec,\n\tmakeDiscontinuedCodecVersion,\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecVersion,\n\ttype CodecAndSchema,\n} from \"./versioned/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCA4BoB;AA1BnB,kHAAA,sBAAsB,OAAA;AAWtB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,qHAAA,yBAAyB,OAAA;AACzB,gHAAA,oBAAoB,OAAA;AACpB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AAGnB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AAEpB,4GAAA,gBAAgB,OAAA;AAEjB,mEAIkC;AAHjC,sIAAA,4BAA4B,OAAA;AAE5B,sHAAA,YAAY,OAAA;AAEb,iDAQ8B;AAP7B,qGAAA,SAAS,OAAA;AACT,uHAAA,2BAA2B,OAAA;AAC3B,uHAAA,2BAA2B,OAAA;AAC3B,wHAAA,4BAA4B,OAAA;AAC5B,gIAAA,oCAAoC,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FormatVersion,\n\tDependentFormatVersion,\n\ttype IBinaryCodec,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n\ttype CodecWriteOptionsBeta,\n\ttype IDecoder,\n\ttype IEncoder,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype JsonValidator,\n\tmakeCodecFamily,\n\ttype SchemaValidationFunction,\n\tunitCodec,\n\twithDefaultBinaryEncoding,\n\twithSchemaValidation,\n\tFluidClientVersion,\n\tcurrentVersion,\n\ttoFormatValidator,\n\tFormatValidatorNoOp,\n\ttype FormatValidator,\n\ttype CodecTree,\n\tjsonableCodecTree,\n\textractJsonValidator,\n\ttype CodecName,\n\teraseEncodedType,\n} from \"./codec.js\";\nexport {\n\tDiscriminatedUnionDispatcher,\n\ttype DiscriminatedUnionLibrary,\n\tunionOptions,\n} from \"./discriminatedUnions.js\";\nexport {\n\tVersioned,\n\tmakeVersionedValidatedCodec,\n\tmakeVersionDispatchingCodec,\n\tmakeDiscontinuedCodecVersion,\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecVersion,\n\ttype CodecAndSchema,\n} from \"./versioned/index.js\";\n"]}