@fluidframework/tree 2.117.0 → 2.118.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/api-report/tree.alpha.api.md +44 -1
  3. package/api-report/tree.beta.api.md +38 -0
  4. package/api-report/tree.legacy.beta.api.md +38 -0
  5. package/dist/entrypoints/alpha.d.ts +1 -1
  6. package/dist/entrypoints/alpha.d.ts.map +1 -1
  7. package/dist/entrypoints/alpha.js.map +1 -1
  8. package/dist/entrypoints/beta.d.ts +1 -1
  9. package/dist/entrypoints/beta.d.ts.map +1 -1
  10. package/dist/entrypoints/beta.js.map +1 -1
  11. package/dist/entrypoints/legacy.d.ts +1 -1
  12. package/dist/entrypoints/legacy.d.ts.map +1 -1
  13. package/dist/entrypoints/legacy.js.map +1 -1
  14. package/dist/feature-libraries/index.d.ts +1 -1
  15. package/dist/feature-libraries/index.js.map +1 -1
  16. package/dist/feature-libraries/schemaChecker.d.ts +9 -19
  17. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  18. package/dist/feature-libraries/schemaChecker.js +130 -46
  19. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/dist/shared-tree/schematizingTreeView.d.ts +13 -3
  27. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  28. package/dist/shared-tree/schematizingTreeView.js +48 -11
  29. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  30. package/dist/simple-tree/api/configuration.d.ts +4 -4
  31. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  32. package/dist/simple-tree/api/configuration.js.map +1 -1
  33. package/dist/simple-tree/api/discrepancies.d.ts +36 -3
  34. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  35. package/dist/simple-tree/api/discrepancies.js +40 -14
  36. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  37. package/dist/simple-tree/api/index.d.ts +3 -2
  38. package/dist/simple-tree/api/index.d.ts.map +1 -1
  39. package/dist/simple-tree/api/index.js +3 -2
  40. package/dist/simple-tree/api/index.js.map +1 -1
  41. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  42. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  43. package/dist/simple-tree/api/schemaCompatibilityTester.js +140 -10
  44. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  45. package/dist/simple-tree/api/tree.d.ts +172 -7
  46. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  47. package/dist/simple-tree/api/tree.js.map +1 -1
  48. package/dist/simple-tree/core/toStored.d.ts +7 -0
  49. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  50. package/dist/simple-tree/core/toStored.js.map +1 -1
  51. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  52. package/dist/simple-tree/core/treeNodeValid.js +2 -2
  53. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  54. package/dist/simple-tree/index.d.ts +1 -1
  55. package/dist/simple-tree/index.d.ts.map +1 -1
  56. package/dist/simple-tree/index.js +4 -3
  57. package/dist/simple-tree/index.js.map +1 -1
  58. package/docs/main/glossary.md +163 -0
  59. package/lib/entrypoints/alpha.d.ts +1 -1
  60. package/lib/entrypoints/alpha.d.ts.map +1 -1
  61. package/lib/entrypoints/alpha.js.map +1 -1
  62. package/lib/entrypoints/beta.d.ts +1 -1
  63. package/lib/entrypoints/beta.d.ts.map +1 -1
  64. package/lib/entrypoints/beta.js.map +1 -1
  65. package/lib/entrypoints/legacy.d.ts +1 -1
  66. package/lib/entrypoints/legacy.d.ts.map +1 -1
  67. package/lib/entrypoints/legacy.js.map +1 -1
  68. package/lib/feature-libraries/index.d.ts +1 -1
  69. package/lib/feature-libraries/index.js.map +1 -1
  70. package/lib/feature-libraries/schemaChecker.d.ts +9 -19
  71. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  72. package/lib/feature-libraries/schemaChecker.js +133 -49
  73. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  74. package/lib/index.d.ts +1 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js.map +1 -1
  77. package/lib/packageVersion.d.ts +1 -1
  78. package/lib/packageVersion.js +1 -1
  79. package/lib/packageVersion.js.map +1 -1
  80. package/lib/shared-tree/schematizingTreeView.d.ts +13 -3
  81. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  82. package/lib/shared-tree/schematizingTreeView.js +49 -12
  83. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  84. package/lib/simple-tree/api/configuration.d.ts +4 -4
  85. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  86. package/lib/simple-tree/api/configuration.js.map +1 -1
  87. package/lib/simple-tree/api/discrepancies.d.ts +36 -3
  88. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  89. package/lib/simple-tree/api/discrepancies.js +40 -14
  90. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  91. package/lib/simple-tree/api/index.d.ts +3 -2
  92. package/lib/simple-tree/api/index.d.ts.map +1 -1
  93. package/lib/simple-tree/api/index.js +1 -1
  94. package/lib/simple-tree/api/index.js.map +1 -1
  95. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  96. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  97. package/lib/simple-tree/api/schemaCompatibilityTester.js +136 -7
  98. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  99. package/lib/simple-tree/api/tree.d.ts +172 -7
  100. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  101. package/lib/simple-tree/api/tree.js.map +1 -1
  102. package/lib/simple-tree/core/toStored.d.ts +7 -0
  103. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  104. package/lib/simple-tree/core/toStored.js.map +1 -1
  105. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  106. package/lib/simple-tree/core/treeNodeValid.js +3 -3
  107. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  108. package/lib/simple-tree/index.d.ts +1 -1
  109. package/lib/simple-tree/index.d.ts.map +1 -1
  110. package/lib/simple-tree/index.js +1 -1
  111. package/lib/simple-tree/index.js.map +1 -1
  112. package/package.json +22 -22
  113. package/src/entrypoints/alpha.ts +3 -0
  114. package/src/entrypoints/beta.ts +2 -0
  115. package/src/entrypoints/legacy.ts +2 -0
  116. package/src/feature-libraries/index.ts +1 -1
  117. package/src/feature-libraries/schemaChecker.ts +198 -82
  118. package/src/index.ts +3 -0
  119. package/src/packageVersion.ts +1 -1
  120. package/src/shared-tree/schematizingTreeView.ts +75 -21
  121. package/src/simple-tree/api/configuration.ts +4 -4
  122. package/src/simple-tree/api/discrepancies.ts +100 -5
  123. package/src/simple-tree/api/index.ts +7 -1
  124. package/src/simple-tree/api/schemaCompatibilityTester.ts +186 -11
  125. package/src/simple-tree/api/tree.ts +184 -8
  126. package/src/simple-tree/core/toStored.ts +8 -0
  127. package/src/simple-tree/core/treeNodeValid.ts +3 -1
  128. package/src/simple-tree/index.ts +4 -0
  129. package/docs/main/runtime-schema-upgrade.md +0 -208
@@ -1 +1 @@
1
- {"version":3,"file":"schemaCompatibilityTester.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaCompatibilityTester.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAA2F;AAC3F,4DAAuD;AAGvD,yDAAsE;AAGtE;;;;;;;;;;;;GAYG;AACH,SAAgB,wBAAwB,CACvC,UAAsB,EACtB,MAAwB,EACxB,oBAA0E;IAE1E,qDAAqD;IACrD,MAAM,MAAM,GAAG,8BAAmB,CAAC;IAEnC,gHAAgH;IAChH,6HAA6H;IAC7H,sDAAsD;IACtD,8HAA8H;IAC9H,IAAI,OAAO,GAAG,IAAI,CAAC;IAEnB,KAAK,MAAM,YAAY,IAAI,IAAA,mDAAgC,EAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC;QACjF,OAAO,GAAG,KAAK,CAAC;QAChB,MAAM;IACP,CAAC;IAED,MAAM,cAAc,GAAG,IAAA,mCAAe,EAAC,UAAU,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAE9E,MAAM,UAAU,GAAG,IAAA,6BAAkB,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtE,+EAA+E;IAC/E,0HAA0H;IAC1H,MAAM,YAAY,GACjB,OAAO,IAAI,UAAU,IAAI,IAAA,6BAAkB,EAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAE7E,OAAO;QACN,OAAO;QACP,UAAU;QACV,YAAY;KACZ,CAAC;AACH,CAAC;AAjCD,4DAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeStoredSchema } from \"../../core/index.js\";\nimport type { SchemaUpgrade, StagedSchemaUpgradePolicy } from \"../core/index.js\";\nimport { allowsRepoSuperset, defaultSchemaPolicy } from \"../../feature-libraries/index.js\";\nimport { toUpgradeSchema } from \"../toStoredSchema.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\n\nimport { getDiscrepanciesInAllowedContent } from \"./discrepancies.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Determines the compatibility of a stored document (based on its stored schema) with a viewer (based on its view schema).\n *\n * Adapters can be provided to handle differences between the two schema.\n * Adapters should only use to types in the `view` SchemaRepository.\n *\n * TODO: this API violates the parse don't validate design philosophy.\n * It should be wrapped with (or replaced by) a parse style API.\n *\n * @param viewSchema - Schema for the view\n * @param stored - The stored schema to check compatibility against\n * @param stagedSchemaUpgrades - Staged schema upgrades enabled for this view, or explicit stored-schema generation options\n */\nexport function checkSchemaCompatibility(\n\tviewSchema: TreeSchema,\n\tstored: TreeStoredSchema,\n\tstagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// The public API surface assumes defaultSchemaPolicy\n\tconst policy = defaultSchemaPolicy;\n\n\t// View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy\n\t// determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.\n\t// In the future, this would also include things like:\n\t// - fields with more allowed types in the stored schema than in the view schema have out-of-schema \"unknown content\" adapters\n\tlet canView = true;\n\n\tfor (const _discrepancy of getDiscrepanciesInAllowedContent(viewSchema, stored)) {\n\t\tcanView = false;\n\t\tbreak;\n\t}\n\n\tconst wouldUpgradeTo = toUpgradeSchema(viewSchema.root, stagedSchemaUpgrades);\n\n\tconst canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);\n\n\t// If true, then upgrading has no effect on what can be stored in the document.\n\t// TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.\n\tconst isEquivalent =\n\t\tcanView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);\n\n\treturn {\n\t\tcanView,\n\t\tcanUpgrade,\n\t\tisEquivalent,\n\t};\n}\n"]}
1
+ {"version":3,"file":"schemaCompatibilityTester.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaCompatibilityTester.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AAEtE,kDAK6B;AAE7B,+CAA4C;AAC5C,+DAA2F;AAC3F,4DAA6F;AAG7F,yDAI4B;AAG5B;;;GAGG;AACH,SAAgB,+BAA+B,CAC9C,UAAsB,EACtB,MAAwB;IAExB,MAAM,aAAa,GAAG,CAAC,GAAG,IAAA,mDAAgC,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAChF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,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Ae,CAAC,GAAG,CAAC,OAAO,CAAC;QACxE,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CAClC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC;KAChF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAC9B,cAAkD,EAClD,gBAAoD;IAEpD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC7D,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,KAAK,EAAE,CAAC;YACpC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC5C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tValueSchema,\n} from \"../../core/index.js\";\nimport type { SchemaUpgrade, StagedSchemaUpgradePolicy } from \"../core/index.js\";\nimport { NodeKind } from \"../core/index.js\";\nimport { allowsRepoSuperset, defaultSchemaPolicy } from \"../../feature-libraries/index.js\";\nimport { resolveStoredSchemaGenerationOptions, toUpgradeSchema } from \"../toStoredSchema.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\n\nimport {\n\tgetDiscrepanciesInAllowedContent,\n\ttype Discrepancy,\n\ttype UpgradeLocationCollector,\n} from \"./discrepancies.js\";\nimport type { SchemaCompatibilityStatusBeta, SchemaDiscrepancy } from \"./tree.js\";\n\n/**\n * Describes the discrepancies that prevent a view schema from viewing a stored schema as a\n * readonly array.\n */\nexport function getSchemaIncompatibilityDetails(\n\tviewSchema: TreeSchema,\n\tstored: TreeStoredSchema,\n): readonly SchemaDiscrepancy[] | undefined {\n\tconst discrepancies = [...getDiscrepanciesInAllowedContent(viewSchema, stored)];\n\tif (discrepancies.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn discrepancies.map(formatSchemaDiscrepancy);\n}\n\nfunction formatSchemaDiscrepancy(value: Discrepancy): SchemaDiscrepancy {\n\tswitch (value.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\treturn {\n\t\t\t\tmismatch: value.mismatch,\n\t\t\t\tlocation:\n\t\t\t\t\tvalue.identifier === undefined\n\t\t\t\t\t\t? \"root\"\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tnodeType: value.identifier,\n\t\t\t\t\t\t\t\tfieldKey: value.fieldKey,\n\t\t\t\t\t\t\t},\n\t\t\t\tview: value.view.map(({ type }) => type.identifier).sort(),\n\t\t\t\t...(value.stagedView === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstagedView: value.stagedView.map(({ type }) => type.identifier).sort(),\n\t\t\t\t\t\t}),\n\t\t\t\tstored: [...value.stored].sort(),\n\t\t\t\t...(value.viewIsStagedOptional === true ? { viewIsStagedOptional: true } : {}),\n\t\t\t};\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn {\n\t\t\t\tmismatch: value.mismatch,\n\t\t\t\tlocation:\n\t\t\t\t\tvalue.identifier === undefined\n\t\t\t\t\t\t? \"root\"\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tnodeType: value.identifier,\n\t\t\t\t\t\t\t\tfieldKey: value.fieldKey,\n\t\t\t\t\t\t\t},\n\t\t\t\tview: value.view,\n\t\t\t\tstored: value.stored,\n\t\t\t\t...(value.viewIsStagedOptional === true ? { viewIsStagedOptional: true } : {}),\n\t\t\t};\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn {\n\t\t\t\tmismatch: value.mismatch,\n\t\t\t\tnodeType: value.identifier,\n\t\t\t\tview: value.view === undefined ? undefined : ValueSchema[value.view],\n\t\t\t\tstored: value.stored === undefined ? undefined : ValueSchema[value.stored],\n\t\t\t};\n\t\t}\n\t\tcase \"nodeKind\": {\n\t\t\tconst storedNodeKind =\n\t\t\t\tvalue.stored === ObjectNodeStoredSchema\n\t\t\t\t\t? \"Object\"\n\t\t\t\t\t: value.stored === MapNodeStoredSchema\n\t\t\t\t\t\t? \"Map\"\n\t\t\t\t\t\t: \"Leaf\";\n\t\t\treturn {\n\t\t\t\tmismatch: value.mismatch,\n\t\t\t\tnodeType: value.identifier,\n\t\t\t\tview: NodeKind[value.view],\n\t\t\t\tstored: storedNodeKind,\n\t\t\t};\n\t\t}\n\t\tdefault: {\n\t\t\treturn unreachableCase(value);\n\t\t}\n\t}\n}\n\n/**\n * The enablement status of a staged schema upgrade in a document's stored schema.\n *\n * @remarks\n * - `\"disabled\"` — no locations guarded by the upgrade are enabled in stored schema.\n * - `\"partial\"` — at least one location is enabled but not all of them.\n * - `\"enabled\"` — all locations guarded by the upgrade are enabled in stored schema.\n *\n * @alpha\n */\nexport type StagedUpgradeStatus = \"disabled\" | \"partial\" | \"enabled\";\n\n/**\n * Determines the compatibility of a stored document (based on its stored schema) with a viewer (based on its view schema).\n *\n * Adapters can be provided to handle differences between the two schema.\n * Adapters should only use to types in the `view` SchemaRepository.\n *\n * TODO: this API violates the parse don't validate design philosophy.\n * It should be wrapped with (or replaced by) a parse style API.\n *\n * @param viewSchema - Schema for the view\n * @param stored - The stored schema to check compatibility against\n * @param stagedSchemaUpgrades - Staged schema upgrades enabled for this view, or explicit stored-schema generation options\n *\n */\nexport function checkSchemaCompatibility(\n\tviewSchema: TreeSchema,\n\tstored: TreeStoredSchema,\n\tstagedSchemaUpgrades?: Iterable<SchemaUpgrade> | StagedSchemaUpgradePolicy,\n): Omit<SchemaCompatibilityStatusBeta, \"canInitialize\"> & {\n\tenabledUpgrades: ReadonlyMap<SchemaUpgrade, StagedUpgradeStatus>;\n} {\n\t// The public API surface assumes defaultSchemaPolicy\n\tconst policy = defaultSchemaPolicy;\n\tconst configuredPolicy = resolveStoredSchemaGenerationOptions(stagedSchemaUpgrades);\n\tconst includeAlreadyEnabledUpgrades =\n\t\tconfiguredPolicy.includeAlreadyEnabledUpgrades ?? false;\n\n\t// Collect upgrade locations during the discrepancy walk (single pass).\n\tconst totalLocations = new Map<SchemaUpgrade, number>();\n\tconst enabledLocations = new Map<SchemaUpgrade, number>();\n\tconst upgradeCollector: UpgradeLocationCollector = {\n\t\tallowedType(upgrade, isEnabled) {\n\t\t\ttotalLocations.set(upgrade, (totalLocations.get(upgrade) ?? 0) + 1);\n\t\t\tif (isEnabled) {\n\t\t\t\tenabledLocations.set(upgrade, (enabledLocations.get(upgrade) ?? 0) + 1);\n\t\t\t}\n\t\t},\n\t\toptionalField(upgrade, isEnabled) {\n\t\t\ttotalLocations.set(upgrade, (totalLocations.get(upgrade) ?? 0) + 1);\n\t\t\tif (isEnabled) {\n\t\t\t\tenabledLocations.set(upgrade, (enabledLocations.get(upgrade) ?? 0) + 1);\n\t\t\t}\n\t\t},\n\t};\n\n\t// View schema allows a subset of documents that stored schema does, and the discrepancies are allowed by policy\n\t// determined by the view schema (i.e. objects with extra optional fields in the stored schema have opted into allowing this.\n\t// In the future, this would also include things like:\n\t// - fields with more allowed types in the stored schema than in the view schema have out-of-schema \"unknown content\" adapters\n\t// Complete the full walk even after finding an incompatibility so discrepancy details and\n\t// staged-upgrade status contain all available information for debugging.\n\tconst discrepancies: SchemaDiscrepancy[] = [];\n\tfor (const discrepancy of getDiscrepanciesInAllowedContent(\n\t\tviewSchema,\n\t\tstored,\n\t\tupgradeCollector,\n\t)) {\n\t\tdiscrepancies.push(formatSchemaDiscrepancy(discrepancy));\n\t}\n\tconst canView = discrepancies.length === 0;\n\n\tconst enabledUpgrades = computeUpgradeStatuses(totalLocations, enabledLocations);\n\tconst upgradePolicy = includeAlreadyEnabledUpgrades\n\t\t? includeEnabledUpgrades(configuredPolicy, enabledUpgrades)\n\t\t: configuredPolicy;\n\tconst wouldUpgradeTo = toUpgradeSchema(viewSchema.root, upgradePolicy);\n\n\tconst canUpgrade = allowsRepoSuperset(policy, stored, wouldUpgradeTo);\n\n\t// If true, then upgrading has no effect on what can be stored in the document.\n\t// TODO: This should likely be changed to indicate up a schema upgrade would be a no-op, including stored schema metadata.\n\tconst isEquivalent =\n\t\tcanView && canUpgrade && allowsRepoSuperset(policy, wouldUpgradeTo, stored);\n\n\treturn {\n\t\tcanView,\n\t\tcanUpgrade,\n\t\tisEquivalent,\n\t\tdiscrepancies: canView ? undefined : discrepancies,\n\t\tenabledUpgrades,\n\t};\n}\n\nfunction includeEnabledUpgrades(\n\tconfiguredPolicy: StagedSchemaUpgradePolicy,\n\tenabledUpgrades: ReadonlyMap<SchemaUpgrade, StagedUpgradeStatus>,\n): StagedSchemaUpgradePolicy {\n\tif (enabledUpgrades.size === 0) {\n\t\treturn configuredPolicy;\n\t}\n\treturn {\n\t\tincludeStaged: (upgrade) =>\n\t\t\tconfiguredPolicy.includeStaged(upgrade) || enabledUpgrades.has(upgrade),\n\t\tincludeStagedOptional: (upgrade) =>\n\t\t\tconfiguredPolicy.includeStagedOptional(upgrade) || enabledUpgrades.has(upgrade),\n\t};\n}\n\n/**\n * Computes the {@link StagedUpgradeStatus} for each upgrade token from total and enabled location counts.\n * Only tokens with at least one enabled location are included in the returned map.\n */\nfunction computeUpgradeStatuses(\n\ttotalLocations: ReadonlyMap<SchemaUpgrade, number>,\n\tenabledLocations: ReadonlyMap<SchemaUpgrade, number>,\n): ReadonlyMap<SchemaUpgrade, StagedUpgradeStatus> {\n\tconst result = new Map<SchemaUpgrade, StagedUpgradeStatus>();\n\tfor (const [upgrade, total] of totalLocations) {\n\t\tconst enabled = enabledLocations.get(upgrade) ?? 0;\n\t\tif (enabled > 0 && enabled < total) {\n\t\t\tresult.set(upgrade, \"partial\");\n\t\t} else if (enabled >= total && enabled > 0) {\n\t\t\tresult.set(upgrade, \"enabled\");\n\t\t}\n\t}\n\treturn result;\n}\n"]}
@@ -5,10 +5,12 @@
5
5
  import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/core-interfaces";
6
6
  import type { ChangeMetadata, CommitMetadata, CustomMetadataTree, RevertibleAlphaFactory, RevertibleFactory, RevertToOptionsAlpha } from "../../core/index.js";
7
7
  import type { JsonCompatibleReadOnly, JsonCompatibleReadOnlyObject } from "../../util/index.js";
8
+ import type { SchemaUpgrade } from "../core/index.js";
8
9
  import type { ImplicitFieldSchema, InsertableField, InsertableTreeFieldFromImplicitField, ReadableField, ReadSchema, TreeFieldFromImplicitField } from "../fieldSchema.js";
9
10
  import type { SimpleTreeSchema } from "../simpleSchema.js";
10
11
  import type { UnsafeUnknownSchema } from "../unsafeUnknownSchema.js";
11
12
  import type { TreeViewConfiguration } from "./configuration.js";
13
+ import type { StagedUpgradeStatus } from "./schemaCompatibilityTester.js";
12
14
  import type { RunTransactionParamsAlpha, RunTransactionParamsBeta, TransactionCallbackStatusAlpha, TransactionCallbackStatusBeta, TransactionVoidResult, TransactionValueResult, VoidTransactionCallbackStatusAlpha, VoidTransactionCallbackStatusBeta, WithValue } from "./transactionTypes.js";
13
15
  import type { VerboseTree } from "./verboseTree.js";
14
16
  /**
@@ -485,9 +487,8 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
485
487
  *
486
488
  * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},
487
489
  * staged schema upgrades matching the configured policy are included in the target stored schema.
488
- * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
489
- * with a view that does not include equivalent staged members in its construction-time policy will cause
490
- * `upgradeSchema` to throw a `UsageError` because the requested target would narrow the stored schema.
490
+ * Set {@link (StagedSchemaUpgradePolicy:interface).includeAlreadyEnabledUpgrades} to `true` to
491
+ * also include staged upgrades that are already enabled in the document.
491
492
  *
492
493
  * @example Enabling a staged allowed type for documents, selected by a feature flag
493
494
  *
@@ -555,11 +556,163 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
555
556
  */
556
557
  readonly schema: TSchema;
557
558
  }
559
+ /**
560
+ * A discrepancy between a view schema and a document's stored schema.
561
+ *
562
+ * @remarks
563
+ * The `mismatch` property discriminates the different discrepancy shapes.
564
+ *
565
+ * @sealed @beta
566
+ */
567
+ export type SchemaDiscrepancy = {
568
+ /**
569
+ * Indicates that a field allows different node types in the view and stored schemas.
570
+ */
571
+ readonly mismatch: "allowedTypes";
572
+ /**
573
+ * The field with the discrepancy.
574
+ *
575
+ * `"root"` identifies the root field. Otherwise, `nodeType` identifies the containing
576
+ * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map
577
+ * node's implicit field.
578
+ */
579
+ readonly location: "root" | {
580
+ readonly nodeType: string;
581
+ readonly fieldKey: string | undefined;
582
+ };
583
+ /**
584
+ * Non-staged node type identifiers allowed by the view schema but not the stored schema.
585
+ */
586
+ readonly view: readonly string[];
587
+ /**
588
+ * Staged node type identifiers allowed by the view schema but not the stored schema.
589
+ *
590
+ * @remarks These types provide rollout context but do not cause the discrepancy.
591
+ */
592
+ readonly stagedView?: readonly string[];
593
+ /**
594
+ * Node type identifiers allowed by the stored schema but not the view schema.
595
+ */
596
+ readonly stored: readonly string[];
597
+ /**
598
+ * Whether the view field is a staged optional field.
599
+ *
600
+ * @remarks Omitted when false.
601
+ */
602
+ readonly viewIsStagedOptional?: true;
603
+ } | {
604
+ /**
605
+ * Indicates that a field has different field kinds in the view and stored schemas.
606
+ */
607
+ readonly mismatch: "fieldKind";
608
+ /**
609
+ * The field with the discrepancy.
610
+ *
611
+ * `"root"` identifies the root field. Otherwise, `nodeType` identifies the containing
612
+ * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map
613
+ * node's implicit field.
614
+ */
615
+ readonly location: "root" | {
616
+ readonly nodeType: string;
617
+ readonly fieldKey: string | undefined;
618
+ };
619
+ /**
620
+ * The field kind required by the view schema.
621
+ */
622
+ readonly view: string;
623
+ /**
624
+ * The field kind recorded in the stored schema.
625
+ */
626
+ readonly stored: string;
627
+ /**
628
+ * Whether the view field is a staged optional field.
629
+ *
630
+ * @remarks Omitted when false.
631
+ */
632
+ readonly viewIsStagedOptional?: true;
633
+ } | {
634
+ /**
635
+ * Indicates that a leaf node accepts different value types in the view and stored schemas.
636
+ */
637
+ readonly mismatch: "valueSchema";
638
+ /**
639
+ * The identifier of the leaf node schema with the discrepancy.
640
+ */
641
+ readonly nodeType: string;
642
+ /**
643
+ * The value schema required by the view, or undefined when it does not constrain values.
644
+ */
645
+ readonly view: string | undefined;
646
+ /**
647
+ * The value schema recorded in the stored schema, or undefined when it does not constrain values.
648
+ */
649
+ readonly stored: string | undefined;
650
+ } | {
651
+ /**
652
+ * Indicates that a node is represented by different node kinds in the view and stored schemas.
653
+ */
654
+ readonly mismatch: "nodeKind";
655
+ /**
656
+ * The identifier of the node schema with the discrepancy.
657
+ */
658
+ readonly nodeType: string;
659
+ /**
660
+ * The node kind required by the view schema.
661
+ */
662
+ readonly view: string;
663
+ /**
664
+ * The node kind recorded in the stored schema.
665
+ */
666
+ readonly stored: string;
667
+ };
668
+ /**
669
+ * {@link SchemaCompatibilityStatus} with additional beta APIs.
670
+ *
671
+ * @sealed @beta
672
+ */
673
+ export interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {
674
+ /**
675
+ * Details about the schema discrepancies that prevent this view from accessing the tree.
676
+ *
677
+ * @remarks
678
+ * This property is undefined when {@link SchemaCompatibilityStatus.canView} is true and present
679
+ * when `canView` is false.
680
+ * It can include application-defined schema identifiers and field keys.
681
+ *
682
+ * @example Interpreting an allowed-types discrepancy
683
+ *
684
+ * If a document's stored schema allows `string` for `Todo.title`, but the view schema expects
685
+ * `number`, the discrepancy identifies the field and the type permitted by each schema:
686
+ *
687
+ * ```typescript
688
+ * const sf = new SchemaFactory("com.example");
689
+ * class Todo extends sf.object("Todo", {
690
+ * title: sf.number,
691
+ * }) {}
692
+ *
693
+ * const view = asBeta(tree.viewWith(new TreeViewConfiguration({ schema: Todo })));
694
+ * if (!view.compatibility.canView) {
695
+ * // [{
696
+ * // mismatch: "allowedTypes",
697
+ * // location: { nodeType: "com.example.Todo", fieldKey: "title" },
698
+ * // view: ["com.fluidframework.leaf.number"],
699
+ * // stored: ["com.fluidframework.leaf.string"],
700
+ * // }]
701
+ * console.error(view.compatibility.discrepancies);
702
+ * }
703
+ * ```
704
+ */
705
+ readonly discrepancies: readonly SchemaDiscrepancy[] | undefined;
706
+ }
558
707
  /**
559
708
  * {@link TreeView} with additional beta APIs.
560
709
  * @sealed @beta
561
710
  */
562
711
  export interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, UntypedTreeView {
712
+ /**
713
+ * {@inheritDoc TreeView.compatibility}
714
+ */
715
+ readonly compatibility: SchemaCompatibilityStatusBeta;
563
716
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewBeta<TSchema>;
564
717
  /**
565
718
  * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.
@@ -617,15 +770,27 @@ export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | Unsa
617
770
  * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.
618
771
  *
619
772
  * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.
620
- * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document
621
- * with a view that does not include equivalent staged members in its construction-time policy will cause
622
- * a subsequent `upgradeSchema` call to throw a `UsageError` because the stored schema already contains
623
- * the upgraded members and the new target would narrow it.
624
773
  *
625
774
  * Applications should typically call this function before attaching a `SharedTree`.
626
775
  * @param content - The content to initialize the tree with.
627
776
  */
628
777
  initialize(content: InsertableField<TSchema>): void;
778
+ /**
779
+ * Checks whether a staged schema upgrade has been applied to the document's stored schema.
780
+ *
781
+ * @param upgrade - The upgrade token to check.
782
+ *
783
+ * @returns The {@link StagedUpgradeStatus} of the upgrade.
784
+ *
785
+ * @remarks
786
+ * Use this to determine whether a document has already been upgraded, for example when deciding
787
+ * whether to include an upgrade token in the view configuration after a feature flag rollback.
788
+ *
789
+ * Results are derived from this view's schema and the current stored schema.
790
+ * The full schema is checked even when the view is incompatible with the stored schema, so the
791
+ * result includes all locations declared by the view schema.
792
+ */
793
+ isStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;
629
794
  readonly events: Listenable<TreeViewEvents & TreeBranchEvents>;
630
795
  fork(): ReturnType<UntypedTreeView["fork"]> & TreeViewAlpha<TSchema>;
631
796
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,kBAAkB,EAGlB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EACX,sBAAsB,EACtB,4BAA4B,EAC5B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EACX,mBAAmB,EACnB,eAAe,EACf,oCAAoC,EACpC,aAAa,EACb,UAAU,EACV,0BAA0B,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KA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AC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;;;;;;;OAQG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CAKhC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC5E;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;OAMG;IACH,WAAW,IAAI,IAAI,CAAC;IAEpB;;;;;;;OAOG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC7E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,mBAAmB,EAClE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GACrB,aAAa,CAAC,OAAO,CAAC,CAExB"}
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+6BH;;;;;GAKG;AACH,SAAgB,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC;AAJD,0CAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tChangeMetadata,\n\tCommitMetadata,\n\tCustomMetadataTree,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\n\tRevertible,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n\tRevertToOptionsAlpha,\n} from \"../../core/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { TreeStatus } from \"../../feature-libraries/index.js\";\nimport type {\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports -- This is referenced by doc comments.\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../util/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { Unhydrated } from \"../core/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type {\n\tRunTransactionParamsAlpha,\n\tRunTransactionParamsBeta,\n\tTransactionCallbackStatusAlpha,\n\tTransactionCallbackStatusBeta,\n\tTransactionVoidResult,\n\tTransactionValueResult,\n\tVoidTransactionCallbackStatusAlpha,\n\tVoidTransactionCallbackStatusBeta,\n\tWithValue,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t * @param name - Optional name for the new branch.\n\t * This name is not guaranteed to be unique.\n\t * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)\n\t * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.\n\t */\n\tcreateSharedBranch(name?: string): string;\n\n\t/**\n\t * Retrieves the name, if any, of the shared branch with the given ID.\n\t * @param branchId - The ID of the shared branch to retrieve the name of.\n\t * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.\n\t * @throws if the branch with the given ID does not exist.\n\t */\n\tgetSharedBranchName(branchId: string): string | undefined;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * An untyped view of a (version-control-style) branch of a SharedTree.\n * @remarks An `UntypedTreeView` allows for the {@link UntypedTreeView.fork | creation of branches} and for those branches to later be {@link UntypedTreeView.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n *\n * See {@link UntypedTreeViewAlpha} for additional APIs that are in an earlier stage of development.\n * @sealed @beta\n */\nexport interface UntypedTreeView extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new view will not apply to this view until the new view is e.g. {@link UntypedTreeView.merge | merged} back into this view.\n\t * The view should be disposed when no longer needed, either {@link UntypedTreeView.dispose | explicitly} or {@link UntypedTreeView.merge | implicitly when merging} into another view.\n\t */\n\tfork(): UntypedTreeView;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - A view created by {@link UntypedTreeView.fork}.\n\t * @param disposeMerged - Whether or not to dispose `view` after the merge completes.\n\t * Defaults to true.\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: UntypedTreeView, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this view forward such that all new changes on the target view become part of this view.\n\t * @param view - The view to rebase onto.\n\t * @remarks After rebasing, this view will be \"ahead\" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view.\n\t * This method may only be called on views produced via {@link UntypedTreeView.fork | fork} - attempting to rebase the main view will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be rebased onto another view - attempting to do so will throw an error.\n\t */\n\trebaseOnto(view: UntypedTreeView): void;\n\n\t/**\n\t * Dispose of this view, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Views can also be automatically disposed when {@link UntypedTreeView.merge | they are merged} into another view.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" view was created or last {@link UntypedTreeView.rebaseOnto | rebased}.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeView}.\n *\n * @deprecated Use {@link UntypedTreeView} instead.\n * @beta\n */\nexport type TreeBranch = UntypedTreeView;\n\n/**\n * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.\n * @alpha\n */\nexport interface TreeContextAlpha {\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t * @param transaction - A callback run during the transaction to perform user-supplied operations.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t * @param params - Optional {@link RunTransactionParamsAlpha | parameters} for the transaction.\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.\n\t * Use {@link TreeContextAlpha.isView | isView() } to check whether this context is associated with a view and gain {@link UntypedTreeViewAlpha.(runTransaction:1) | access to more transaction capabilities} if so.\n\t */\n\trunTransaction<TValue>(\n\t\ttransaction: () => WithValue<TValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TValue, TValue>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeContextAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this context.\n\t */\n\trunTransactionAsync<TValue>(\n\t\ttransaction: () => Promise<WithValue<TValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TValue, TValue>>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * True if this context is associated with an {@link UntypedTreeViewAlpha | untyped view} and false if it is associated with an {@link Unhydrated | unhydrated } node.\n\t * @remarks If this returns true, the context can be safely inferred or cast to {@link UntypedTreeViewAlpha} to access additional view-specific APIs.\n\t * @example\n\t * ```typescript\n\t * const context = tree.context(someNode);\n\t * if (context.isView()) {\n\t * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on UntypedTreeViewAlpha, so this is only accessible if `context` is a view context.\n\t * context.root.foo = \"bar\"; // Edit the root of the SharedTree that `someNode` belongs to.\n\t * }\n\t * ```\n\t * @returns Whether this context is associated with an untyped view.\n\t */\n\tisView(): this is UntypedTreeViewAlpha;\n\n\t/**\n\t * {@inheritDoc TreeContextAlpha.isView}\n\t * @deprecated Use {@link TreeContextAlpha.isView | isView()} instead.\n\t */\n\tisBranch(): this is UntypedTreeViewAlpha;\n}\n\n/**\n * An identifier for a commit in a {@link UntypedTreeViewAlpha}'s {@link UntypedTreeViewAlpha.branchHistory | history}.\n * @alpha\n */\nexport type CommitRevision = string;\n\n/**\n * Metadata describing a single commit in a {@link UntypedTreeViewAlpha}'s history.\n * @sealed @alpha\n */\nexport interface TreeBranchCommitMetadata {\n\t/**\n\t * The revision UUID that uniquely identifies this commit within the branch's history.\n\t */\n\treadonly revision: CommitRevision;\n\n\t/**\n\t * Arbitrary, application-defined metadata that was {@link RunTransactionParamsAlpha.customMetadata | attached}\n\t * to this commit when it was created, flattened into a single object.\n\t *\n\t * @remarks\n\t * This is `undefined` for commits that were not annotated.\n\t *\n\t * A commit may be produced by nested transactions, each of which may supply metadata. This property combines\n\t * them: where two of them used the same property, the outermost transaction wins, and between siblings the\n\t * later one wins. Use {@link TreeBranchCommitMetadata.customTree} to recover which transaction supplied what.\n\t */\n\treadonly custom: JsonCompatibleReadOnlyObject | undefined;\n\n\t/**\n\t * The {@link CustomMetadataTree | tree} of metadata attached to this commit, reflecting the nesting of\n\t * the transactions that produced it.\n\t *\n\t * @remarks\n\t * The structural counterpart to {@link TreeBranchCommitMetadata.custom}, and `undefined` whenever it is.\n\t * Prefer `custom` unless you need to know which transaction supplied a particular property.\n\t */\n\treadonly customTree: CustomMetadataTree | undefined;\n\n\t/**\n\t * The metadata for the commit that this commit was based on, or `undefined` if this commit has no parent\n\t * (i.e. it is the oldest commit in the branch's history).\n\t *\n\t * @remarks\n\t * This method may return a different value over time if the parent commit is trimmed from the branch's history.\n\t */\n\tgetParent(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * Provides APIs for querying information about the history of a {@link UntypedTreeViewAlpha}.\n * @remarks\n * The history of a branch is the sequence of commits leading up to its current state.\n * @sealed @alpha\n */\nexport interface TreeBranchHistory {\n\t/**\n\t * The number of commits in this branch's history.\n\t * @remarks\n\t * This number grows when any of the following occurs:\n\t * - A new edit is made on this branch (either through editing or by reverting an existing commit on this branch).\n\t * - A branch that contains commits not already on this branch is merged into this branch.\n\t * - The branch is rebased onto another branch that contains commits not already on this branch.\n\t * This number shrinks when past commits are trimmed from the history.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * Returns metadata for the current head commit of this branch.\n\t * @returns The metadata for the head commit, or `undefined` if the branch has no commits.\n\t */\n\tgetHead(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * An untyped view of a {@link UntypedTreeView} with alpha-level APIs.\n * @remarks\n * The untyped view for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.context` and checking {@link TreeContextAlpha.isView | isView()}.\n *\n * An untyped view does not necessarily know the schema of its SharedTree. To convert it to a {@link TreeViewAlpha | view with a schema}, use {@link UntypedTreeViewAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {\n\t/**\n\t * Events for the view's underlying branch.\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * APIs for querying the history of the branch being viewed.\n\t */\n\treadonly branchHistory: TreeBranchHistory;\n\n\t/**\n\t * Returns true if this view has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this view to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (view.hasRootSchema(MySchema)) {\n\t * const { root } = view; // `view` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): UntypedTreeViewAlpha;\n\n\t/**\n\t * Switches this view to a new underlying branch with the given commit as the head, updating the view state accordingly.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to rewind to.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t *\n\t * @remarks\n\t * Unlike {@link UntypedTreeViewAlpha.revertTo | revertTo}, this does not apply a change to the underlying branch.\n\t * The original underlying branch will be disposed.\n\t * Consider {@link UntypedTreeViewAlpha.fork | forking} before rewinding.\n\t * Not valid to invoke on the main branch or a {@link (ITreeAlpha:interface).createSharedBranch | shared branch}.\n\t */\n\trewindTo(revision: CommitRevision): void;\n\n\t/**\n\t * Applies a new change which reverts all changes made since the given `revision`.\n\t * This is a no-op if the given revision is the head commit of the underlying branch being viewed.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to restore the state of.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t * @param options - Optional {@link RevertToOptionsAlpha | options} for the revert.\n\t *\n\t * @remarks\n\t * The generated change is subject to the same merge semantics as the {@link Revertible.(revert:1) | reverts of individual commits}:\n\t * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.\n\t *\n\t * Unlike {@link UntypedTreeViewAlpha.rewindTo | rewindTo}, this does not switch to a new branch.\n\t */\n\trevertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;\n\n\t/**\n\t * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on this view of the SharedTree.\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusAlpha | value or rollback signal}.\n\t * @remarks\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.\n\t */\n\n\trunTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * Apply a serialized change to this branch.\n\t * @param change - the change to apply.\n\t * Changes are acquired via `getChange` in a branch's {@link TreeBranchEvents.changed | \"changed\"} event.\n\t * @remarks Changes may only be applied to a SharedTree with the same IdCompressor instance and branch state from which they were generated.\n\t * They may be created by one branch and applied to another, but only if both branches share the same history at the time of creation and application.\n\t *\n\t * @privateRemarks\n\t * TODO: This method will support applying changes from different IdCompressor instances as long as they have the same local session ID.\n\t * Update the tests and docs to match when that is done.\n\t */\n\tapplyChange(change: JsonCompatibleReadOnly): void;\n\n\t/**\n\t * Determines if there are changes on the given view that are not present on this view.\n\t * @param view - The view to compare to.\n\t *\n\t * The new edits, if any, can be applied to this view by {@link UntypedTreeView.rebaseOnto | rebasing this view onto the given view}\n\t * or by {@link UntypedTreeView.merge | merging the given view into this view}.\n\t *\n\t * @throws UsageError if the branches are unrelated.\n\t */\n\tisMissingEditsFrom(view: UntypedTreeView): boolean;\n\n\t/**\n\t * Computes the net change that would result if this view were {@link UntypedTreeView.rebaseOnto | rebased onto} the given view.\n\t * Note that this method does not actually perform the rebase and therefore has no effect on this view.\n\t *\n\t * @param view - The view that would be rebased onto.\n\t * @returns The net change that would result if this view were rebased onto the given view,\n\t * or `undefined` if rebasing would have no impact.\n\t */\n\tcomputeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeViewAlpha}.\n *\n * @deprecated Use {@link UntypedTreeViewAlpha} instead.\n * @alpha\n */\nexport type TreeBranchAlpha = UntypedTreeViewAlpha;\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link UntypedTreeView} for additional APIs that are in earlier stages of development.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t * @remarks\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.\n\t * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.\n\t * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the target stored schema.\n\t * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document\n\t * with a view that does not include equivalent staged members in its construction-time policy will cause\n\t * `upgradeSchema` to throw a `UsageError` because the requested target would narrow the stored schema.\n\t *\n\t * @example Enabling a staged allowed type for documents, selected by a feature flag\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactoryBeta(\"my-app\");\n\t *\n\t * class TaskItem extends sf.object(\"TaskItem\", { title: sf.string }) {}\n\t * class ChecklistItem extends sf.object(\"ChecklistItem\", { text: sf.string }) {}\n\t *\n\t * // `staged` wraps ChecklistItem so it can be enabled at runtime.\n\t * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);\n\t * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;\n\t *\n\t * class AppSchema extends sf.object(\"AppSchema\", {\n\t * items: sf.array([TaskItem, stagedChecklist]),\n\t * }) {}\n\t *\n\t * // Feature flag controls whether the upgrade is enabled for this session.\n\t * const policy = featureFlags.enableChecklist\n\t * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)\n\t * : undefined;\n\t *\n\t * const view = tree.viewWith(\n\t * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),\n\t * );\n\t *\n\t * if (view.compatibility.canUpgrade) {\n\t * // Writes the staged type into the document's stored schema.\n\t * view.upgradeSchema();\n\t * }\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tUntypedTreeView {\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewBeta<TSchema>;\n\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t *\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusBeta | value or rollback signal}.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t *\n\t * @param params - Optional {@link RunTransactionParamsBeta | parameters} for the transaction.\n\t *\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t *\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => TOut,\n\t\tparams?: RunTransactionParamsBeta,\n\t): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t: TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeViewBeta.runTransaction | runTransaction}.\n\t *\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this view.\n\t */\n\trunTransactionAsync<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => Promise<TOut>,\n\t\tparams?: RunTransactionParamsBeta,\n\t): Promise<\n\t\tTOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t\t: TransactionVoidResult\n\t>;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<\n\t\t\tTreeViewBeta<ReadSchema<TSchema>>,\n\t\t\t\"root\" | \"initialize\" | \"fork\" | \"runTransaction\" | \"runTransactionAsync\"\n\t\t>,\n\t\tUntypedTreeViewAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.\n\t * Once a staged schema upgrade has been enabled in a document's stored schema, loading that document\n\t * with a view that does not include equivalent staged members in its construction-time policy will cause\n\t * a subsequent `upgradeSchema` call to throw a `UsageError` because the stored schema already contains\n\t * the upgraded members and the new target would narrow it.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * @see\n * See SharedTree's README for more information about choosing a compatibility policy.\n *\n * @privateRemarks\n * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.\n *\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the set of documents allowed by the view schema is a strict superset of those allowed by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link UntypedTreeView}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @remarks\n * See {@link TreeBranchEvents} for more events related to the underlying branch of the SharedTree.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link (asAlpha:1)} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+lCH;;;;;GAKG;AACH,SAAgB,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC;AAJD,0CAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tChangeMetadata,\n\tCommitMetadata,\n\tCustomMetadataTree,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\n\tRevertible,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n\tRevertToOptionsAlpha,\n} from \"../../core/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { TreeStatus } from \"../../feature-libraries/index.js\";\nimport type {\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports -- This is referenced by doc comments.\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../util/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { SchemaUpgrade, Unhydrated } from \"../core/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type { StagedUpgradeStatus } from \"./schemaCompatibilityTester.js\";\nimport type {\n\tRunTransactionParamsAlpha,\n\tRunTransactionParamsBeta,\n\tTransactionCallbackStatusAlpha,\n\tTransactionCallbackStatusBeta,\n\tTransactionVoidResult,\n\tTransactionValueResult,\n\tVoidTransactionCallbackStatusAlpha,\n\tVoidTransactionCallbackStatusBeta,\n\tWithValue,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t * @param name - Optional name for the new branch.\n\t * This name is not guaranteed to be unique.\n\t * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)\n\t * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.\n\t */\n\tcreateSharedBranch(name?: string): string;\n\n\t/**\n\t * Retrieves the name, if any, of the shared branch with the given ID.\n\t * @param branchId - The ID of the shared branch to retrieve the name of.\n\t * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.\n\t * @throws if the branch with the given ID does not exist.\n\t */\n\tgetSharedBranchName(branchId: string): string | undefined;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * An untyped view of a (version-control-style) branch of a SharedTree.\n * @remarks An `UntypedTreeView` allows for the {@link UntypedTreeView.fork | creation of branches} and for those branches to later be {@link UntypedTreeView.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n *\n * See {@link UntypedTreeViewAlpha} for additional APIs that are in an earlier stage of development.\n * @sealed @beta\n */\nexport interface UntypedTreeView extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new view will not apply to this view until the new view is e.g. {@link UntypedTreeView.merge | merged} back into this view.\n\t * The view should be disposed when no longer needed, either {@link UntypedTreeView.dispose | explicitly} or {@link UntypedTreeView.merge | implicitly when merging} into another view.\n\t */\n\tfork(): UntypedTreeView;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - A view created by {@link UntypedTreeView.fork}.\n\t * @param disposeMerged - Whether or not to dispose `view` after the merge completes.\n\t * Defaults to true.\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: UntypedTreeView, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this view forward such that all new changes on the target view become part of this view.\n\t * @param view - The view to rebase onto.\n\t * @remarks After rebasing, this view will be \"ahead\" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view.\n\t * This method may only be called on views produced via {@link UntypedTreeView.fork | fork} - attempting to rebase the main view will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be rebased onto another view - attempting to do so will throw an error.\n\t */\n\trebaseOnto(view: UntypedTreeView): void;\n\n\t/**\n\t * Dispose of this view, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Views can also be automatically disposed when {@link UntypedTreeView.merge | they are merged} into another view.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" view was created or last {@link UntypedTreeView.rebaseOnto | rebased}.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeView}.\n *\n * @deprecated Use {@link UntypedTreeView} instead.\n * @beta\n */\nexport type TreeBranch = UntypedTreeView;\n\n/**\n * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.\n * @alpha\n */\nexport interface TreeContextAlpha {\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t * @param transaction - A callback run during the transaction to perform user-supplied operations.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t * @param params - Optional {@link RunTransactionParamsAlpha | parameters} for the transaction.\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.\n\t * Use {@link TreeContextAlpha.isView | isView() } to check whether this context is associated with a view and gain {@link UntypedTreeViewAlpha.(runTransaction:1) | access to more transaction capabilities} if so.\n\t */\n\trunTransaction<TValue>(\n\t\ttransaction: () => WithValue<TValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TValue, TValue>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeContextAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this context.\n\t */\n\trunTransactionAsync<TValue>(\n\t\ttransaction: () => Promise<WithValue<TValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TValue, TValue>>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * True if this context is associated with an {@link UntypedTreeViewAlpha | untyped view} and false if it is associated with an {@link Unhydrated | unhydrated } node.\n\t * @remarks If this returns true, the context can be safely inferred or cast to {@link UntypedTreeViewAlpha} to access additional view-specific APIs.\n\t * @example\n\t * ```typescript\n\t * const context = tree.context(someNode);\n\t * if (context.isView()) {\n\t * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on UntypedTreeViewAlpha, so this is only accessible if `context` is a view context.\n\t * context.root.foo = \"bar\"; // Edit the root of the SharedTree that `someNode` belongs to.\n\t * }\n\t * ```\n\t * @returns Whether this context is associated with an untyped view.\n\t */\n\tisView(): this is UntypedTreeViewAlpha;\n\n\t/**\n\t * {@inheritDoc TreeContextAlpha.isView}\n\t * @deprecated Use {@link TreeContextAlpha.isView | isView()} instead.\n\t */\n\tisBranch(): this is UntypedTreeViewAlpha;\n}\n\n/**\n * An identifier for a commit in a {@link UntypedTreeViewAlpha}'s {@link UntypedTreeViewAlpha.branchHistory | history}.\n * @alpha\n */\nexport type CommitRevision = string;\n\n/**\n * Metadata describing a single commit in a {@link UntypedTreeViewAlpha}'s history.\n * @sealed @alpha\n */\nexport interface TreeBranchCommitMetadata {\n\t/**\n\t * The revision UUID that uniquely identifies this commit within the branch's history.\n\t */\n\treadonly revision: CommitRevision;\n\n\t/**\n\t * Arbitrary, application-defined metadata that was {@link RunTransactionParamsAlpha.customMetadata | attached}\n\t * to this commit when it was created, flattened into a single object.\n\t *\n\t * @remarks\n\t * This is `undefined` for commits that were not annotated.\n\t *\n\t * A commit may be produced by nested transactions, each of which may supply metadata. This property combines\n\t * them: where two of them used the same property, the outermost transaction wins, and between siblings the\n\t * later one wins. Use {@link TreeBranchCommitMetadata.customTree} to recover which transaction supplied what.\n\t */\n\treadonly custom: JsonCompatibleReadOnlyObject | undefined;\n\n\t/**\n\t * The {@link CustomMetadataTree | tree} of metadata attached to this commit, reflecting the nesting of\n\t * the transactions that produced it.\n\t *\n\t * @remarks\n\t * The structural counterpart to {@link TreeBranchCommitMetadata.custom}, and `undefined` whenever it is.\n\t * Prefer `custom` unless you need to know which transaction supplied a particular property.\n\t */\n\treadonly customTree: CustomMetadataTree | undefined;\n\n\t/**\n\t * The metadata for the commit that this commit was based on, or `undefined` if this commit has no parent\n\t * (i.e. it is the oldest commit in the branch's history).\n\t *\n\t * @remarks\n\t * This method may return a different value over time if the parent commit is trimmed from the branch's history.\n\t */\n\tgetParent(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * Provides APIs for querying information about the history of a {@link UntypedTreeViewAlpha}.\n * @remarks\n * The history of a branch is the sequence of commits leading up to its current state.\n * @sealed @alpha\n */\nexport interface TreeBranchHistory {\n\t/**\n\t * The number of commits in this branch's history.\n\t * @remarks\n\t * This number grows when any of the following occurs:\n\t * - A new edit is made on this branch (either through editing or by reverting an existing commit on this branch).\n\t * - A branch that contains commits not already on this branch is merged into this branch.\n\t * - The branch is rebased onto another branch that contains commits not already on this branch.\n\t * This number shrinks when past commits are trimmed from the history.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * Returns metadata for the current head commit of this branch.\n\t * @returns The metadata for the head commit, or `undefined` if the branch has no commits.\n\t */\n\tgetHead(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * An untyped view of a {@link UntypedTreeView} with alpha-level APIs.\n * @remarks\n * The untyped view for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.context` and checking {@link TreeContextAlpha.isView | isView()}.\n *\n * An untyped view does not necessarily know the schema of its SharedTree. To convert it to a {@link TreeViewAlpha | view with a schema}, use {@link UntypedTreeViewAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {\n\t/**\n\t * Events for the view's underlying branch.\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * APIs for querying the history of the branch being viewed.\n\t */\n\treadonly branchHistory: TreeBranchHistory;\n\n\t/**\n\t * Returns true if this view has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this view to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (view.hasRootSchema(MySchema)) {\n\t * const { root } = view; // `view` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): UntypedTreeViewAlpha;\n\n\t/**\n\t * Switches this view to a new underlying branch with the given commit as the head, updating the view state accordingly.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to rewind to.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t *\n\t * @remarks\n\t * Unlike {@link UntypedTreeViewAlpha.revertTo | revertTo}, this does not apply a change to the underlying branch.\n\t * The original underlying branch will be disposed.\n\t * Consider {@link UntypedTreeViewAlpha.fork | forking} before rewinding.\n\t * Not valid to invoke on the main branch or a {@link (ITreeAlpha:interface).createSharedBranch | shared branch}.\n\t */\n\trewindTo(revision: CommitRevision): void;\n\n\t/**\n\t * Applies a new change which reverts all changes made since the given `revision`.\n\t * This is a no-op if the given revision is the head commit of the underlying branch being viewed.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to restore the state of.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t * @param options - Optional {@link RevertToOptionsAlpha | options} for the revert.\n\t *\n\t * @remarks\n\t * The generated change is subject to the same merge semantics as the {@link Revertible.(revert:1) | reverts of individual commits}:\n\t * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.\n\t *\n\t * Unlike {@link UntypedTreeViewAlpha.rewindTo | rewindTo}, this does not switch to a new branch.\n\t */\n\trevertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;\n\n\t/**\n\t * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on this view of the SharedTree.\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusAlpha | value or rollback signal}.\n\t * @remarks\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.\n\t */\n\n\trunTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * Apply a serialized change to this branch.\n\t * @param change - the change to apply.\n\t * Changes are acquired via `getChange` in a branch's {@link TreeBranchEvents.changed | \"changed\"} event.\n\t * @remarks Changes may only be applied to a SharedTree with the same IdCompressor instance and branch state from which they were generated.\n\t * They may be created by one branch and applied to another, but only if both branches share the same history at the time of creation and application.\n\t *\n\t * @privateRemarks\n\t * TODO: This method will support applying changes from different IdCompressor instances as long as they have the same local session ID.\n\t * Update the tests and docs to match when that is done.\n\t */\n\tapplyChange(change: JsonCompatibleReadOnly): void;\n\n\t/**\n\t * Determines if there are changes on the given view that are not present on this view.\n\t * @param view - The view to compare to.\n\t *\n\t * The new edits, if any, can be applied to this view by {@link UntypedTreeView.rebaseOnto | rebasing this view onto the given view}\n\t * or by {@link UntypedTreeView.merge | merging the given view into this view}.\n\t *\n\t * @throws UsageError if the branches are unrelated.\n\t */\n\tisMissingEditsFrom(view: UntypedTreeView): boolean;\n\n\t/**\n\t * Computes the net change that would result if this view were {@link UntypedTreeView.rebaseOnto | rebased onto} the given view.\n\t * Note that this method does not actually perform the rebase and therefore has no effect on this view.\n\t *\n\t * @param view - The view that would be rebased onto.\n\t * @returns The net change that would result if this view were rebased onto the given view,\n\t * or `undefined` if rebasing would have no impact.\n\t */\n\tcomputeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeViewAlpha}.\n *\n * @deprecated Use {@link UntypedTreeViewAlpha} instead.\n * @alpha\n */\nexport type TreeBranchAlpha = UntypedTreeViewAlpha;\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link UntypedTreeView} for additional APIs that are in earlier stages of development.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t * @remarks\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.\n\t * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.\n\t * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the target stored schema.\n\t * Set {@link (StagedSchemaUpgradePolicy:interface).includeAlreadyEnabledUpgrades} to `true` to\n\t * also include staged upgrades that are already enabled in the document.\n\t *\n\t * @example Enabling a staged allowed type for documents, selected by a feature flag\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactoryBeta(\"my-app\");\n\t *\n\t * class TaskItem extends sf.object(\"TaskItem\", { title: sf.string }) {}\n\t * class ChecklistItem extends sf.object(\"ChecklistItem\", { text: sf.string }) {}\n\t *\n\t * // `staged` wraps ChecklistItem so it can be enabled at runtime.\n\t * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);\n\t * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;\n\t *\n\t * class AppSchema extends sf.object(\"AppSchema\", {\n\t * items: sf.array([TaskItem, stagedChecklist]),\n\t * }) {}\n\t *\n\t * // Feature flag controls whether the upgrade is enabled for this session.\n\t * const policy = featureFlags.enableChecklist\n\t * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)\n\t * : undefined;\n\t *\n\t * const view = tree.viewWith(\n\t * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),\n\t * );\n\t *\n\t * if (view.compatibility.canUpgrade) {\n\t * // Writes the staged type into the document's stored schema.\n\t * view.upgradeSchema();\n\t * }\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * A discrepancy between a view schema and a document's stored schema.\n *\n * @remarks\n * The `mismatch` property discriminates the different discrepancy shapes.\n *\n * @sealed @beta\n */\nexport type SchemaDiscrepancy =\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field allows different node types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"allowedTypes\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * Non-staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t */\n\t\t\treadonly view: readonly string[];\n\t\t\t/**\n\t\t\t * Staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t *\n\t\t\t * @remarks These types provide rollout context but do not cause the discrepancy.\n\t\t\t */\n\t\t\treadonly stagedView?: readonly string[];\n\t\t\t/**\n\t\t\t * Node type identifiers allowed by the stored schema but not the view schema.\n\t\t\t */\n\t\t\treadonly stored: readonly string[];\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field has different field kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"fieldKind\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * The field kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The field kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a leaf node accepts different value types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"valueSchema\";\n\t\t\t/**\n\t\t\t * The identifier of the leaf node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The value schema required by the view, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly view: string | undefined;\n\t\t\t/**\n\t\t\t * The value schema recorded in the stored schema, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly stored: string | undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a node is represented by different node kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"nodeKind\";\n\t\t\t/**\n\t\t\t * The identifier of the node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The node kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The node kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t };\n\n/**\n * {@link SchemaCompatibilityStatus} with additional beta APIs.\n *\n * @sealed @beta\n */\nexport interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {\n\t/**\n\t * Details about the schema discrepancies that prevent this view from accessing the tree.\n\t *\n\t * @remarks\n\t * This property is undefined when {@link SchemaCompatibilityStatus.canView} is true and present\n\t * when `canView` is false.\n\t * It can include application-defined schema identifiers and field keys.\n\t *\n\t * @example Interpreting an allowed-types discrepancy\n\t *\n\t * If a document's stored schema allows `string` for `Todo.title`, but the view schema expects\n\t * `number`, the discrepancy identifies the field and the type permitted by each schema:\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactory(\"com.example\");\n\t * class Todo extends sf.object(\"Todo\", {\n\t * \ttitle: sf.number,\n\t * }) {}\n\t *\n\t * const view = asBeta(tree.viewWith(new TreeViewConfiguration({ schema: Todo })));\n\t * if (!view.compatibility.canView) {\n\t * \t// [{\n\t * \t// mismatch: \"allowedTypes\",\n\t * \t// location: { nodeType: \"com.example.Todo\", fieldKey: \"title\" },\n\t * \t// view: [\"com.fluidframework.leaf.number\"],\n\t * \t// stored: [\"com.fluidframework.leaf.string\"],\n\t * \t// }]\n\t * \tconsole.error(view.compatibility.discrepancies);\n\t * }\n\t * ```\n\t */\n\treadonly discrepancies: readonly SchemaDiscrepancy[] | undefined;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tUntypedTreeView {\n\t/**\n\t * {@inheritDoc TreeView.compatibility}\n\t */\n\treadonly compatibility: SchemaCompatibilityStatusBeta;\n\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewBeta<TSchema>;\n\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t *\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusBeta | value or rollback signal}.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t *\n\t * @param params - Optional {@link RunTransactionParamsBeta | parameters} for the transaction.\n\t *\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t *\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => TOut,\n\t\tparams?: RunTransactionParamsBeta,\n\t): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t: TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeViewBeta.runTransaction | runTransaction}.\n\t *\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this view.\n\t */\n\trunTransactionAsync<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => Promise<TOut>,\n\t\tparams?: RunTransactionParamsBeta,\n\t): Promise<\n\t\tTOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t\t: TransactionVoidResult\n\t>;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<\n\t\t\tTreeViewBeta<ReadSchema<TSchema>>,\n\t\t\t\"root\" | \"initialize\" | \"fork\" | \"runTransaction\" | \"runTransactionAsync\"\n\t\t>,\n\t\tUntypedTreeViewAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\t/**\n\t * Checks whether a staged schema upgrade has been applied to the document's stored schema.\n\t *\n\t * @param upgrade - The upgrade token to check.\n\t *\n\t * @returns The {@link StagedUpgradeStatus} of the upgrade.\n\t *\n\t * @remarks\n\t * Use this to determine whether a document has already been upgraded, for example when deciding\n\t * whether to include an upgrade token in the view configuration after a feature flag rollback.\n\t *\n\t * Results are derived from this view's schema and the current stored schema.\n\t * The full schema is checked even when the view is incompatible with the stored schema, so the\n\t * result includes all locations declared by the view schema.\n\t */\n\tisStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * @see\n * See SharedTree's README for more information about choosing a compatibility policy.\n *\n * @privateRemarks\n * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.\n *\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the set of documents allowed by the view schema is a strict superset of those allowed by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link UntypedTreeView}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @remarks\n * See {@link TreeBranchEvents} for more events related to the underlying branch of the SharedTree.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link (asAlpha:1)} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
@@ -9,6 +9,13 @@ import type { SchemaUpgrade } from "./allowedTypes.js";
9
9
  * @alpha
10
10
  */
11
11
  export interface StagedSchemaUpgradePolicy {
12
+ /**
13
+ * Whether schema upgrades should include staged upgrades that are already enabled in the
14
+ * document's stored schema.
15
+ *
16
+ * @defaultValue `false`
17
+ */
18
+ readonly includeAlreadyEnabledUpgrades?: boolean;
12
19
  /**
13
20
  * Determines whether to include staged allowed types in the resulting stored schema.
14
21
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"toStored.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAE/C;;;;;OAKG;IACH,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,gCAAgC;IAChD;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAC/C;;;;;;;;;OASG;IACH,qBAAqB,CAAC,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,yBAAyB,CAAC;CAC/E;AAED;;;GAGG;AACH,eA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AC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Policy controlling which staged schema upgrades are included when generating stored schema from a view schema.\n * @input\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicy {\n\t/**\n\t * Determines whether to include staged allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n\n\t/**\n\t * Determines whether to treat a staged optional field as optional\n\t * (rather than required) in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStagedOptional(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Provides factory methods for creating {@link (StagedSchemaUpgradePolicy:interface)} instances.\n *\n * @remarks\n * Use the properties and methods on this object to obtain staged-schema generation options\n * for different scenarios:\n *\n * - {@link StagedSchemaUpgradePolicyFactory.restrictive} — no staged upgrades (default)\n *\n * - {@link StagedSchemaUpgradePolicyFactory.permissive} — all staged upgrades enabled\n *\n * - {@link StagedSchemaUpgradePolicyFactory.enabledStagedUpgrades} — only specific upgrades enabled\n *\n * @example\n * ```typescript\n * // Enable specific upgrades:\n * const options = StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade);\n *\n * // Use restrictive (default, no staged upgrades):\n * const options = StagedSchemaUpgradePolicy.restrictive;\n *\n * // Use permissive (all staged upgrades, useful for testing):\n * const options = StagedSchemaUpgradePolicy.permissive;\n * ```\n *\n * @sealed\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicyFactory {\n\t/**\n\t * Restrictive policy — excludes all staged schema members.\n\t *\n\t * @remarks\n\t * Use this when you want the most conservative stored schema for compatibility-sensitive\n\t * scenarios, or when staged schema upgrades should remain disabled.\n\t *\n\t * This is the default behavior when no staged upgrades are enabled.\n\t */\n\treadonly restrictive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Permissive policy — includes all staged schema upgrades.\n\t *\n\t * @remarks\n\t * Use this for testing, validation, and rollout rehearsal scenarios where you want to exercise\n\t * future document shapes before enabling staged upgrades broadly.\n\t */\n\treadonly permissive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Creates options that include only the specified staged schema upgrades.\n\t *\n\t * @param upgrades - The staged schema upgrades to enable.\n\t * @returns Options that include only the specified upgrades.\n\t *\n\t * @remarks\n\t * If an empty set of upgrades is passed, the result is equivalent to\n\t * `StagedSchemaUpgradePolicy.restrictive`.\n\t */\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy;\n}\n\n/**\n * {@inheritDoc (StagedSchemaUpgradePolicyFactory:interface)}\n * @alpha\n */\nexport const StagedSchemaUpgradePolicy: StagedSchemaUpgradePolicyFactory = {\n\trestrictive: {\n\t\tincludeStaged: () => false,\n\t\tincludeStagedOptional: () => false,\n\t},\n\n\tpermissive: {\n\t\tincludeStaged: () => true,\n\t\tincludeStagedOptional: () => true,\n\t},\n\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy {\n\t\tif (upgrades.length === 0) {\n\t\t\treturn StagedSchemaUpgradePolicy.restrictive;\n\t\t}\n\t\tconst enabledUpgradeSet = new Set(upgrades);\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t};\n\t},\n};\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions = StagedSchemaUpgradePolicy | ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StagedSchemaUpgradePolicy\n\t| ExpectStored\n\t| Unchanged;\n"]}
1
+ {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8FH;;;GAGG;AACU,QAAA,yBAAyB,GAAqC;IAC1E,WAAW,EAAE;QACZ,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;QAC1B,qBAAqB,EAAE,GAAG,EAAE,CAAC,KAAK;KAClC;IAED,UAAU,EAAE;QACX,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI;QACzB,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI;KACjC;IAED,qBAAqB,CAAC,GAAG,QAAyB;QACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,iCAAyB,CAAC,WAAW,CAAC;QAC9C,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO;YACN,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;YAC1D,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;SAClE,CAAC;IACH,CAAC;CACD,CAAC;AAEF;;GAEG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAGnD;;;;GAIG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Policy controlling which staged schema upgrades are included when generating stored schema from a view schema.\n * @input\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicy {\n\t/**\n\t * Whether schema upgrades should include staged upgrades that are already enabled in the\n\t * document's stored schema.\n\t *\n\t * @defaultValue `false`\n\t */\n\treadonly includeAlreadyEnabledUpgrades?: boolean;\n\n\t/**\n\t * Determines whether to include staged allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n\n\t/**\n\t * Determines whether to treat a staged optional field as optional\n\t * (rather than required) in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStagedOptional(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Provides factory methods for creating {@link (StagedSchemaUpgradePolicy:interface)} instances.\n *\n * @remarks\n * Use the properties and methods on this object to obtain staged-schema generation options\n * for different scenarios:\n *\n * - {@link StagedSchemaUpgradePolicyFactory.restrictive} — no staged upgrades (default)\n *\n * - {@link StagedSchemaUpgradePolicyFactory.permissive} — all staged upgrades enabled\n *\n * - {@link StagedSchemaUpgradePolicyFactory.enabledStagedUpgrades} — only specific upgrades enabled\n *\n * @example\n * ```typescript\n * // Enable specific upgrades:\n * const options = StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade);\n *\n * // Use restrictive (default, no staged upgrades):\n * const options = StagedSchemaUpgradePolicy.restrictive;\n *\n * // Use permissive (all staged upgrades, useful for testing):\n * const options = StagedSchemaUpgradePolicy.permissive;\n * ```\n *\n * @sealed\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicyFactory {\n\t/**\n\t * Restrictive policy — excludes all staged schema members.\n\t *\n\t * @remarks\n\t * Use this when you want the most conservative stored schema for compatibility-sensitive\n\t * scenarios, or when staged schema upgrades should remain disabled.\n\t *\n\t * This is the default behavior when no staged upgrades are enabled.\n\t */\n\treadonly restrictive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Permissive policy — includes all staged schema upgrades.\n\t *\n\t * @remarks\n\t * Use this for testing, validation, and rollout rehearsal scenarios where you want to exercise\n\t * future document shapes before enabling staged upgrades broadly.\n\t */\n\treadonly permissive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Creates options that include only the specified staged schema upgrades.\n\t *\n\t * @param upgrades - The staged schema upgrades to enable.\n\t * @returns Options that include only the specified upgrades.\n\t *\n\t * @remarks\n\t * If an empty set of upgrades is passed, the result is equivalent to\n\t * `StagedSchemaUpgradePolicy.restrictive`.\n\t */\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy;\n}\n\n/**\n * {@inheritDoc (StagedSchemaUpgradePolicyFactory:interface)}\n * @alpha\n */\nexport const StagedSchemaUpgradePolicy: StagedSchemaUpgradePolicyFactory = {\n\trestrictive: {\n\t\tincludeStaged: () => false,\n\t\tincludeStagedOptional: () => false,\n\t},\n\n\tpermissive: {\n\t\tincludeStaged: () => true,\n\t\tincludeStagedOptional: () => true,\n\t},\n\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy {\n\t\tif (upgrades.length === 0) {\n\t\t\treturn StagedSchemaUpgradePolicy.restrictive;\n\t\t}\n\t\tconst enabledUpgradeSet = new Set(upgrades);\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t};\n\t},\n};\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions = StagedSchemaUpgradePolicy | ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StagedSchemaUpgradePolicy\n\t| ExpectStored\n\t| Unchanged;\n"]}