@fluidframework/tree 2.10.0-306579 → 2.10.0-307399

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 (110) hide show
  1. package/api-report/tree.alpha.api.md +11 -9
  2. package/api-report/tree.beta.api.md +2 -0
  3. package/api-report/tree.legacy.alpha.api.md +2 -0
  4. package/api-report/tree.legacy.public.api.md +2 -0
  5. package/api-report/tree.public.api.md +2 -0
  6. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +26 -5
  7. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  8. package/dist/feature-libraries/chunked-forest/basicChunk.js +15 -5
  9. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  10. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  11. package/dist/feature-libraries/chunked-forest/chunkedForest.js +5 -0
  12. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  13. package/dist/feature-libraries/index.d.ts +1 -1
  14. package/dist/feature-libraries/index.d.ts.map +1 -1
  15. package/dist/feature-libraries/index.js +2 -2
  16. package/dist/feature-libraries/index.js.map +1 -1
  17. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +27 -27
  18. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  19. package/dist/feature-libraries/modular-schema/discrepancies.js +152 -193
  20. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  21. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  22. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  23. package/dist/feature-libraries/modular-schema/index.js +2 -2
  24. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/shared-tree/treeApi.js +4 -1
  29. package/dist/shared-tree/treeApi.js.map +1 -1
  30. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +12 -14
  31. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  32. package/dist/simple-tree/api/schemaCreationUtilities.js +9 -7
  33. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  34. package/dist/simple-tree/api/schemaFactory.d.ts +2 -0
  35. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  36. package/dist/simple-tree/api/schemaFactory.js +4 -1
  37. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  38. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  39. package/dist/simple-tree/core/treeNodeKernel.d.ts +4 -5
  40. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  41. package/dist/simple-tree/core/treeNodeKernel.js +63 -67
  42. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  43. package/dist/simple-tree/objectNode.d.ts +1 -1
  44. package/dist/simple-tree/objectNode.js.map +1 -1
  45. package/dist/simple-tree/objectNodeTypes.d.ts +3 -0
  46. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  47. package/dist/simple-tree/objectNodeTypes.js +3 -1
  48. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  49. package/docs/.attachments/object-merge-semantics.drawio +145 -0
  50. package/docs/user-facing/array-merge-semantics.md +344 -0
  51. package/docs/user-facing/map-merge-semantics.md +128 -0
  52. package/docs/user-facing/merge-semantics.md +7 -3
  53. package/docs/user-facing/object-merge-semantics.md +77 -0
  54. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +26 -5
  55. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  56. package/lib/feature-libraries/chunked-forest/basicChunk.js +15 -5
  57. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  58. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  59. package/lib/feature-libraries/chunked-forest/chunkedForest.js +5 -0
  60. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  61. package/lib/feature-libraries/index.d.ts +1 -1
  62. package/lib/feature-libraries/index.d.ts.map +1 -1
  63. package/lib/feature-libraries/index.js +1 -1
  64. package/lib/feature-libraries/index.js.map +1 -1
  65. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +27 -27
  66. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  67. package/lib/feature-libraries/modular-schema/discrepancies.js +150 -191
  68. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  69. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  70. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  71. package/lib/feature-libraries/modular-schema/index.js +1 -1
  72. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  73. package/lib/packageVersion.d.ts +1 -1
  74. package/lib/packageVersion.js +1 -1
  75. package/lib/packageVersion.js.map +1 -1
  76. package/lib/shared-tree/treeApi.js +5 -2
  77. package/lib/shared-tree/treeApi.js.map +1 -1
  78. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +12 -14
  79. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  80. package/lib/simple-tree/api/schemaCreationUtilities.js +9 -7
  81. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  82. package/lib/simple-tree/api/schemaFactory.d.ts +2 -0
  83. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  84. package/lib/simple-tree/api/schemaFactory.js +4 -1
  85. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  86. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  87. package/lib/simple-tree/core/treeNodeKernel.d.ts +4 -5
  88. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  89. package/lib/simple-tree/core/treeNodeKernel.js +64 -68
  90. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  91. package/lib/simple-tree/objectNode.d.ts +1 -1
  92. package/lib/simple-tree/objectNode.js.map +1 -1
  93. package/lib/simple-tree/objectNodeTypes.d.ts +3 -0
  94. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  95. package/lib/simple-tree/objectNodeTypes.js +3 -1
  96. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  97. package/package.json +23 -31
  98. package/src/feature-libraries/chunked-forest/basicChunk.ts +12 -4
  99. package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -0
  100. package/src/feature-libraries/index.ts +1 -1
  101. package/src/feature-libraries/modular-schema/discrepancies.ts +202 -241
  102. package/src/feature-libraries/modular-schema/index.ts +4 -1
  103. package/src/packageVersion.ts +1 -1
  104. package/src/shared-tree/treeApi.ts +7 -5
  105. package/src/simple-tree/api/schemaCreationUtilities.ts +29 -17
  106. package/src/simple-tree/api/schemaFactory.ts +25 -18
  107. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
  108. package/src/simple-tree/core/treeNodeKernel.ts +62 -64
  109. package/src/simple-tree/objectNode.ts +1 -1
  110. package/src/simple-tree/objectNodeTypes.ts +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAGiC;AADhC,mHAAA,UAAU,OAAA;AAEX,yDAAmF;AAA1E,gHAAA,WAAW,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAAE,gHAAA,WAAW,OAAA;AAErD,sDAA6D;AAApD,4GAAA,gBAAgB,OAAA;AACzB,uDAK4B;AAJ3B,yHAAA,qBAAqB,OAAA;AACrB,wHAAA,oBAAoB,OAAA;AACpB,qHAAA,iBAAiB,OAAA;AACjB,0HAAA,sBAAsB,OAAA;AAEvB,6EAAuF;AAA9E,uIAAA,wBAAwB,OAAA;AACjC,qDAAuD;AAA9C,uGAAA,WAAW,OAAA;AACpB,oDAA8F;AAArF,4GAAA,gBAAgB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAA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B,OAAA;AACnB,sGAAA,UAAU,OAAA;AACV,mHAAA,uBAAuB,OAAA;AACvB,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AACpB,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA;AAGhB,iDA4B8B;AAxB7B,gGAAA,IAAI,OAAA;AAOJ,0GAAA,cAAc,OAAA;AACd,sGAAA,UAAU,OAAA;AACV,mGAAA,OAAO,OAAA;AAGP,0GAAA,cAAc,OAAA;AACd,uGAAA,WAAW,OAAA;AACX,WAAW;AACX,0GAAA,cAAc,OAAA;AACd,wHAAA,4BAA4B,OAAA;AAC5B,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAAkB,OAAA;AAClB,yGAAA,aAAa,OAAA;AACb,sGAAA,UAAU,OAAA;AACV,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,8GAAA,kBAAkB,OAAA;AAGnB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAEhC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAE1B,qFAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AAErC,oDAIiC;AAFhC,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AAGpB,uEAAuE;AAA9D,qIAAA,yBAAyB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { MemoizedIdRangeAllocator, type IdRange } from \"./memoizedIdRangeAllocator.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentIncompatibilities,\n\tisRepoSuperset,\n\tisNeverTree,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeKeys,\n\tcreateNodeKeyManager,\n\tisStableNodeKey,\n\ttype LocalNodeKey,\n\tMockNodeKeyManager,\n\ttype NodeKeyManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeKey,\n} from \"./node-key/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationErrors,\n\tisNodeInSchema,\n\tisFieldInSchema,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tgetTreeContext,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tisFreedSymbol,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAGiC;AADhC,mHAAA,UAAU,OAAA;AAEX,yDAAmF;AAA1E,gHAAA,WAAW,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAAE,gHAAA,WAAW,OAAA;AAErD,sDAA6D;AAApD,4GAAA,gBAAgB,OAAA;AACzB,uDAK4B;AAJ3B,yHAAA,qBAAqB,OAAA;AACrB,wHAAA,oBAAoB,OAAA;AACpB,qHAAA,iBAAiB,OAAA;AACjB,0HAAA,sBAAsB,OAAA;AAEvB,6EAAuF;AAA9E,uIAAA,wBAAwB,OAAA;AACjC,qDAAuD;AAA9C,uGAAA,WAAW,OAAA;AACpB,oDAA8F;AAArF,4GAAA,gBAAgB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAAE,2GAAA,eAAe,OAAA;AAC5D,2DAO8B;AAN7B,yHAAA,mBAAmB,OAAA;AAEnB,gHAAA,UAAU,OAAA;AACV,qHAAA,eAAe,OAAA;AAEf,0HAAA,oBAAoB,OAAA;AAErB,yDAM6B;AAL5B,8HAAA,yBAAyB,OAAA;AACzB,+HAAA,0BAA0B,OAAA;AAC1B,2HAAA,sBAAsB,OAAA;AACtB,gIAAA,2BAA2B,OAAA;AAC3B,2HAAA,sBAAsB,OAAA;AAGvB,sFAAsF;AACtF,yEAA2D;AAClD,sCAAa;AAEtB,sDAsCmC;AArClC,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAA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,4BAA4B,OAAA;AAC5B,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAAkB,OAAA;AAClB,yGAAA,aAAa,OAAA;AACb,sGAAA,UAAU,OAAA;AACV,qHAAA,yBAAyB,OAAA;AACzB,sGAAA,UAAU,OAAA;AACV,8GAAA,kBAAkB,OAAA;AAGnB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAEhC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAE1B,qFAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AAErC,oDAIiC;AAFhC,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AAGpB,uEAAuE;AAA9D,qIAAA,yBAAyB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { MemoizedIdRangeAllocator, type IdRange } from \"./memoizedIdRangeAllocator.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\tisNeverTree,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeKeys,\n\tcreateNodeKeyManager,\n\tisStableNodeKey,\n\ttype LocalNodeKey,\n\tMockNodeKeyManager,\n\ttype NodeKeyManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeKey,\n} from \"./node-key/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationErrors,\n\tisNodeInSchema,\n\tisFieldInSchema,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tgetTreeContext,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tisFreedSymbol,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n"]}
@@ -6,39 +6,39 @@ import { type FieldKindIdentifier, type TreeStoredSchema, type ValueSchema } fro
6
6
  /**
7
7
  * @remarks
8
8
  *
9
- * 1. FieldIncompatibility
9
+ * 1. FieldDiscrepancy
10
10
  *
11
- * `FieldIncompatibility` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
11
+ * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
12
12
  * three types of incompatibilities:
13
13
  *
14
- * - FieldKindIncompatibility: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
14
+ * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
15
15
  * objects (e.g., optional, required, sequence, etc.).
16
- * - AllowedTypesIncompatibility: Indicates the differences in the allowed child types between the two schemas.
17
- * - ValueSchemaIncompatibility: Specifically indicates the differences in the `ValueSchema` of two
16
+ * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.
17
+ * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two
18
18
  * `LeafNodeStoredSchema` objects.
19
19
  *
20
- * 2. NodeIncompatibility
20
+ * 2. NodeDiscrepancy
21
21
  *
22
- * `NodeIncompatibility` represents the differences between two `TreeNodeStoredSchema` objects and includes:
22
+ * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:
23
23
  *
24
- * - NodeKindIncompatibility: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
24
+ * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
25
25
  * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).
26
- * - NodeFieldsIncompatibility: Indicates the `FieldIncompatibility` of `TreeFieldStoredSchema` within two
27
- * `TreeNodeStoredSchema`. It includes an array of `FieldIncompatibility` instances in the `differences` field.
26
+ * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two
27
+ * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.
28
28
  *
29
29
  * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of
30
30
  * the same kind (map, object, leaf).
31
31
  *
32
- * 3. Incompatibility
32
+ * 3. Discrepancy
33
33
  *
34
- * Incompatibility consists of both `NodeIncompatibility` and `FieldIncompatibility`, representing any kind of
35
- * schema differences. See {@link getAllowedContentIncompatibilities} for more details about how we process it
34
+ * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of
35
+ * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it
36
36
  * and the ordering.
37
37
  */
38
- export type Incompatibility = FieldIncompatibility | NodeIncompatibility;
39
- export type NodeIncompatibility = NodeKindIncompatibility | NodeFieldsIncompatibility;
40
- export type FieldIncompatibility = AllowedTypeIncompatibility | FieldKindIncompatibility | ValueSchemaIncompatibility;
41
- export interface AllowedTypeIncompatibility {
38
+ export type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;
39
+ export type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;
40
+ export type FieldDiscrepancy = AllowedTypeDiscrepancy | FieldKindDiscrepancy | ValueSchemaDiscrepancy;
41
+ export interface AllowedTypeDiscrepancy {
42
42
  identifier: string | undefined;
43
43
  mismatch: "allowedTypes";
44
44
  /**
@@ -50,48 +50,48 @@ export interface AllowedTypeIncompatibility {
50
50
  */
51
51
  stored: string[];
52
52
  }
53
- export interface FieldKindIncompatibility {
53
+ export interface FieldKindDiscrepancy {
54
54
  identifier: string | undefined;
55
55
  mismatch: "fieldKind";
56
56
  view: FieldKindIdentifier;
57
57
  stored: FieldKindIdentifier;
58
58
  }
59
- export interface ValueSchemaIncompatibility {
59
+ export interface ValueSchemaDiscrepancy {
60
60
  identifier: string;
61
61
  mismatch: "valueSchema";
62
62
  view: ValueSchema | undefined;
63
63
  stored: ValueSchema | undefined;
64
64
  }
65
- export interface NodeKindIncompatibility {
65
+ export interface NodeKindDiscrepancy {
66
66
  identifier: string;
67
67
  mismatch: "nodeKind";
68
68
  view: SchemaFactoryNodeKind | undefined;
69
69
  stored: SchemaFactoryNodeKind | undefined;
70
70
  }
71
- export interface NodeFieldsIncompatibility {
71
+ export interface NodeFieldsDiscrepancy {
72
72
  identifier: string;
73
73
  mismatch: "fields";
74
- differences: FieldIncompatibility[];
74
+ differences: FieldDiscrepancy[];
75
75
  }
76
76
  type SchemaFactoryNodeKind = "object" | "leaf" | "map";
77
77
  /**
78
- * @remarks
78
+ * Finds and reports discrepancies between a view schema and a stored schema.
79
79
  *
80
80
  * The workflow for finding schema incompatibilities:
81
- * 1. Compare the two root schemas to identify any `FieldIncompatibility`.
81
+ * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
82
82
  *
83
83
  * 2. For each node schema in the `view`:
84
84
  * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
85
- * consistent. Otherwise this difference is treated as `NodeKindIncompatibility`
85
+ * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
86
86
  * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
87
- * are consistent, perform a exhaustive validation to identify all `FieldIncompatibility`.
87
+ * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
88
88
  *
89
89
  * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
90
90
  * addressed in the previous step.
91
91
  *
92
92
  * @returns the discrepancies between two TreeStoredSchema objects
93
93
  */
94
- export declare function getAllowedContentIncompatibilities(view: TreeStoredSchema, stored: TreeStoredSchema): Incompatibility[];
94
+ export declare function getAllowedContentDiscrepancies(view: TreeStoredSchema, stored: TreeStoredSchema): Iterable<Discrepancy>;
95
95
  /**
96
96
  * @remarks
97
97
  *
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,mBAAmB,EAOxB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAO7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAA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,eAAe,EAAE,CA8JnB;AAwGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAkCxF"}
1
+ {"version":3,"file":"discrepancies.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,mBAAmB,EAQxB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAO7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE1E,MAAM,MAAM,gBAAgB,GACzB,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,CAAC;AAE1B,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,mBAAmB,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,KAAK,qBAAqB,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAavD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAiB,8BAA8B,CAC9C,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,gBAAgB,GACtB,QAAQ,CAAC,WAAW,CAAC,CAkCvB;AAkLD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAkCxF"}
@@ -4,214 +4,149 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isRepoSuperset = exports.getAllowedContentIncompatibilities = void 0;
7
+ exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../core/index.js");
10
10
  const index_js_2 = require("../../util/index.js");
11
+ function getNodeSchemaType(nodeSchema) {
12
+ if (nodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
13
+ return "object";
14
+ }
15
+ else if (nodeSchema instanceof index_js_1.MapNodeStoredSchema) {
16
+ return "map";
17
+ }
18
+ else if (nodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
19
+ return "leaf";
20
+ }
21
+ throwUnsupportedNodeType(nodeSchema.constructor.name);
22
+ }
11
23
  /**
12
- * @remarks
24
+ * Finds and reports discrepancies between a view schema and a stored schema.
13
25
  *
14
26
  * The workflow for finding schema incompatibilities:
15
- * 1. Compare the two root schemas to identify any `FieldIncompatibility`.
27
+ * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.
16
28
  *
17
29
  * 2. For each node schema in the `view`:
18
30
  * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are
19
- * consistent. Otherwise this difference is treated as `NodeKindIncompatibility`
31
+ * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`
20
32
  * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`
21
- * are consistent, perform a exhaustive validation to identify all `FieldIncompatibility`.
33
+ * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.
22
34
  *
23
35
  * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already
24
36
  * addressed in the previous step.
25
37
  *
26
38
  * @returns the discrepancies between two TreeStoredSchema objects
27
39
  */
28
- function getAllowedContentIncompatibilities(view, stored) {
29
- const incompatibilities = [];
40
+ function* getAllowedContentDiscrepancies(view, stored) {
30
41
  // check root schema discrepancies
31
- incompatibilities.push(...trackFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema));
32
- // Verify the existence and type of a node schema given its identifier (key), then determine if
33
- // an exhaustive search is necessary.
34
- const viewNodeKeys = new Set();
35
- for (const [key, viewNodeSchema] of view.nodeSchema) {
36
- viewNodeKeys.add(key);
37
- if (viewNodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
38
- if (!stored.nodeSchema.has(key)) {
39
- incompatibilities.push({
40
- identifier: key,
42
+ yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);
43
+ for (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {
44
+ switch (result.type) {
45
+ case "aExtra": {
46
+ const viewType = getNodeSchemaType(result.value);
47
+ yield {
48
+ identifier: result.key,
41
49
  mismatch: "nodeKind",
42
- view: "object",
50
+ view: viewType,
43
51
  stored: undefined,
44
- });
45
- }
46
- else {
47
- const storedNodeSchema = stored.nodeSchema.get(key);
48
- (0, internal_1.assert)(storedNodeSchema !== undefined, 0x9be /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
49
- if (storedNodeSchema instanceof index_js_1.MapNodeStoredSchema) {
50
- incompatibilities.push({
51
- identifier: key,
52
- mismatch: "nodeKind",
53
- view: "object",
54
- stored: "map",
55
- });
56
- }
57
- else if (storedNodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
58
- incompatibilities.push({
59
- identifier: key,
60
- mismatch: "nodeKind",
61
- view: "object",
62
- stored: "leaf",
63
- });
64
- }
65
- else if (storedNodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
66
- const differences = trackObjectNodeDiscrepancies(viewNodeSchema, storedNodeSchema);
67
- if (differences.length > 0) {
68
- incompatibilities.push({
69
- identifier: key,
70
- mismatch: "fields",
71
- differences,
72
- });
73
- }
74
- }
75
- else {
76
- throwUnsupportedNodeType(storedNodeSchema.constructor.name);
77
- }
52
+ };
53
+ break;
78
54
  }
79
- }
80
- else if (viewNodeSchema instanceof index_js_1.MapNodeStoredSchema) {
81
- if (!stored.nodeSchema.has(key)) {
82
- incompatibilities.push({
83
- identifier: key,
55
+ case "bExtra": {
56
+ const storedType = getNodeSchemaType(result.value);
57
+ yield {
58
+ identifier: result.key,
84
59
  mismatch: "nodeKind",
85
- view: "map",
86
- stored: undefined,
87
- });
60
+ view: undefined,
61
+ stored: storedType,
62
+ };
63
+ break;
88
64
  }
89
- else {
90
- const storedNodeSchema = stored.nodeSchema.get(key);
91
- (0, internal_1.assert)(storedNodeSchema !== undefined, 0x9bf /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
92
- if (storedNodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
93
- incompatibilities.push({
94
- identifier: key,
95
- mismatch: "nodeKind",
96
- view: "map",
97
- stored: "object",
98
- });
99
- }
100
- else if (storedNodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
101
- incompatibilities.push({
102
- identifier: key,
103
- mismatch: "nodeKind",
104
- view: "map",
105
- stored: "leaf",
106
- });
107
- }
108
- else if (storedNodeSchema instanceof index_js_1.MapNodeStoredSchema) {
109
- incompatibilities.push(...trackFieldDiscrepancies(viewNodeSchema.mapFields, storedNodeSchema.mapFields, key));
110
- }
111
- else {
112
- throwUnsupportedNodeType(storedNodeSchema.constructor.name);
113
- }
65
+ case "both": {
66
+ yield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);
67
+ break;
114
68
  }
69
+ default:
70
+ break;
115
71
  }
116
- else if (viewNodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
117
- if (!stored.nodeSchema.has(key)) {
118
- incompatibilities.push({
119
- identifier: key,
120
- mismatch: "nodeKind",
121
- view: "leaf",
122
- stored: undefined,
123
- });
124
- }
125
- else {
126
- const storedNodeSchema = stored.nodeSchema.get(key);
127
- (0, internal_1.assert)(storedNodeSchema !== undefined, 0x9c0 /* The storedNodeSchema in stored.nodeSchema should not be undefined */);
128
- if (storedNodeSchema instanceof index_js_1.MapNodeStoredSchema) {
129
- incompatibilities.push({
130
- identifier: key,
131
- mismatch: "nodeKind",
132
- view: "leaf",
133
- stored: "map",
134
- });
135
- }
136
- else if (storedNodeSchema instanceof index_js_1.ObjectNodeStoredSchema) {
137
- incompatibilities.push({
138
- identifier: key,
139
- mismatch: "nodeKind",
140
- view: "leaf",
141
- stored: "object",
142
- });
143
- }
144
- else if (storedNodeSchema instanceof index_js_1.LeafNodeStoredSchema) {
145
- if (viewNodeSchema.leafValue !== storedNodeSchema.leafValue) {
146
- incompatibilities.push({
147
- identifier: key,
148
- mismatch: "valueSchema",
149
- view: viewNodeSchema.leafValue,
150
- stored: storedNodeSchema.leafValue,
151
- });
152
- }
153
- }
154
- else {
155
- throwUnsupportedNodeType(storedNodeSchema.constructor.name);
156
- }
72
+ }
73
+ }
74
+ exports.getAllowedContentDiscrepancies = getAllowedContentDiscrepancies;
75
+ function* getNodeDiscrepancies(identifier, view, stored) {
76
+ const viewType = getNodeSchemaType(view);
77
+ const storedType = getNodeSchemaType(stored);
78
+ if (viewType !== storedType) {
79
+ yield {
80
+ identifier,
81
+ mismatch: "nodeKind",
82
+ view: viewType,
83
+ stored: storedType,
84
+ };
85
+ return;
86
+ }
87
+ switch (viewType) {
88
+ case "object": {
89
+ const differences = Array.from(trackObjectNodeDiscrepancies(view, stored));
90
+ if (differences.length > 0) {
91
+ yield {
92
+ identifier,
93
+ mismatch: "fields",
94
+ differences,
95
+ };
157
96
  }
97
+ break;
158
98
  }
159
- else {
160
- throwUnsupportedNodeType(viewNodeSchema.constructor.name);
161
- }
162
- }
163
- for (const [key, storedNodeSchema] of stored.nodeSchema) {
164
- if (!viewNodeKeys.has(key)) {
165
- incompatibilities.push({
166
- identifier: key,
167
- mismatch: "nodeKind",
168
- view: undefined,
169
- stored: storedNodeSchema instanceof index_js_1.MapNodeStoredSchema
170
- ? "map"
171
- : storedNodeSchema instanceof index_js_1.ObjectNodeStoredSchema
172
- ? "object"
173
- : "leaf",
174
- });
99
+ case "map":
100
+ yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier);
101
+ break;
102
+ case "leaf": {
103
+ const viewValue = view.leafValue;
104
+ const storedValue = stored.leafValue;
105
+ if (viewValue !== storedValue) {
106
+ yield {
107
+ identifier,
108
+ mismatch: "valueSchema",
109
+ view: viewValue,
110
+ stored: storedValue,
111
+ };
112
+ }
113
+ break;
175
114
  }
115
+ default:
116
+ break;
176
117
  }
177
- return incompatibilities;
178
118
  }
179
- exports.getAllowedContentIncompatibilities = getAllowedContentIncompatibilities;
180
119
  /**
181
120
  * The function to track the discrepancies between two field stored schemas.
182
121
  *
183
122
  * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
184
123
  */
185
- function trackFieldDiscrepancies(view, stored, keyOrRoot) {
186
- const differences = [];
124
+ function* getFieldDiscrepancies(view, stored, keyOrRoot) {
187
125
  // Only track the symmetric differences of two sets.
188
126
  const findSetDiscrepancies = (a, b) => {
189
127
  const aDiff = [...a].filter((value) => !b.has(value));
190
128
  const bDiff = [...b].filter((value) => !a.has(value));
191
129
  return [aDiff, bDiff];
192
130
  };
193
- const allowedTypesDiscrepancies = findSetDiscrepancies(view.types, stored.types);
194
- if (allowedTypesDiscrepancies[0].length > 0 || allowedTypesDiscrepancies[1].length > 0) {
195
- differences.push({
131
+ const [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);
132
+ if (viewExtra.length > 0 || storedExtra.length > 0) {
133
+ yield {
196
134
  identifier: keyOrRoot,
197
135
  mismatch: "allowedTypes",
198
- view: allowedTypesDiscrepancies[0],
199
- stored: allowedTypesDiscrepancies[1],
200
- });
136
+ view: viewExtra,
137
+ stored: storedExtra,
138
+ };
201
139
  }
202
140
  if (view.kind !== stored.kind) {
203
- differences.push({
141
+ yield {
204
142
  identifier: keyOrRoot,
205
143
  mismatch: "fieldKind",
206
144
  view: view.kind,
207
145
  stored: stored.kind,
208
- });
146
+ };
209
147
  }
210
- return differences;
211
148
  }
212
- function trackObjectNodeDiscrepancies(view, stored) {
213
- const differences = [];
214
- const viewFieldKeys = new Set();
149
+ function* trackObjectNodeDiscrepancies(view, stored) {
215
150
  /**
216
151
  * Similar to the logic used for tracking discrepancies between two node schemas, we will identify
217
152
  * three types of differences:
@@ -222,35 +157,59 @@ function trackObjectNodeDiscrepancies(view, stored) {
222
157
  * First, the view schema is iterated to track the first two types of differences.
223
158
  * Then, the stored schema is iterated to find the third type.
224
159
  */
225
- for (const [fieldKey, fieldStoredSchema] of view.objectNodeFields) {
226
- viewFieldKeys.add(fieldKey);
227
- if (!stored.objectNodeFields.has(fieldKey) &&
228
- fieldStoredSchema.kind !== index_js_1.storedEmptyFieldSchema.kind) {
229
- differences.push({
230
- identifier: fieldKey,
231
- mismatch: "fieldKind",
232
- view: fieldStoredSchema.kind,
233
- stored: index_js_1.storedEmptyFieldSchema.kind,
234
- });
235
- }
236
- else {
237
- differences.push(...trackFieldDiscrepancies(view.objectNodeFields.get(fieldKey), stored.objectNodeFields.get(fieldKey), fieldKey));
160
+ for (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {
161
+ const fieldKey = result.key;
162
+ switch (result.type) {
163
+ case "aExtra": {
164
+ if (result.value.kind === index_js_1.storedEmptyFieldSchema.kind) {
165
+ // In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden
166
+ // (by way of omission). We treat these identically anyway.
167
+ break;
168
+ }
169
+ yield {
170
+ identifier: fieldKey,
171
+ mismatch: "fieldKind",
172
+ view: result.value.kind,
173
+ stored: index_js_1.storedEmptyFieldSchema.kind,
174
+ };
175
+ break;
176
+ }
177
+ case "bExtra": {
178
+ if (result.value.kind === index_js_1.storedEmptyFieldSchema.kind) {
179
+ // In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden
180
+ // (by way of omission). We treat these identically anyway.
181
+ break;
182
+ }
183
+ yield {
184
+ identifier: fieldKey,
185
+ mismatch: "fieldKind",
186
+ view: index_js_1.storedEmptyFieldSchema.kind,
187
+ stored: result.value.kind,
188
+ };
189
+ break;
190
+ }
191
+ case "both": {
192
+ yield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);
193
+ break;
194
+ }
195
+ default: {
196
+ break;
197
+ }
238
198
  }
239
199
  }
240
- for (const [fieldKey, fieldStoredSchema] of stored.objectNodeFields) {
241
- if (viewFieldKeys.has(fieldKey)) {
242
- continue;
243
- }
244
- if (fieldStoredSchema.kind !== index_js_1.storedEmptyFieldSchema.kind) {
245
- differences.push({
246
- identifier: fieldKey,
247
- mismatch: "fieldKind",
248
- view: index_js_1.storedEmptyFieldSchema.kind,
249
- stored: fieldStoredSchema.kind,
250
- });
200
+ }
201
+ function* compareMaps(a, b) {
202
+ for (const [key, valueA] of a) {
203
+ const valueB = b.get(key);
204
+ yield valueB === undefined
205
+ ? { type: "aExtra", key, value: valueA }
206
+ : { type: "both", key, valueA, valueB };
207
+ }
208
+ for (const [key, valueB] of b) {
209
+ if (!a.has(key)) {
210
+ yield { type: "bExtra", key, value: valueB };
251
211
  }
252
212
  }
253
- return differences;
254
213
  }
255
214
  /**
256
215
  * @remarks
@@ -270,11 +229,11 @@ function trackObjectNodeDiscrepancies(view, stored) {
270
229
  * validating internal fields.
271
230
  */
272
231
  function isRepoSuperset(view, stored) {
273
- const incompatibilities = getAllowedContentIncompatibilities(view, stored);
274
- for (const incompatibility of incompatibilities) {
275
- switch (incompatibility.mismatch) {
232
+ const discrepancies = getAllowedContentDiscrepancies(view, stored);
233
+ for (const discrepancy of discrepancies) {
234
+ switch (discrepancy.mismatch) {
276
235
  case "nodeKind": {
277
- if (incompatibility.stored !== undefined) {
236
+ if (discrepancy.stored !== undefined) {
278
237
  // It's fine for the view schema to know of a node type that the stored schema doesn't know about.
279
238
  return false;
280
239
  }
@@ -283,13 +242,13 @@ function isRepoSuperset(view, stored) {
283
242
  case "valueSchema":
284
243
  case "allowedTypes":
285
244
  case "fieldKind": {
286
- if (!validateFieldIncompatibility(incompatibility)) {
245
+ if (!isFieldDiscrepancyCompatible(discrepancy)) {
287
246
  return false;
288
247
  }
289
248
  break;
290
249
  }
291
250
  case "fields": {
292
- if (incompatibility.differences.some((difference) => !validateFieldIncompatibility(difference))) {
251
+ if (discrepancy.differences.some((difference) => !isFieldDiscrepancyCompatible(difference))) {
293
252
  return false;
294
253
  }
295
254
  break;
@@ -300,16 +259,16 @@ function isRepoSuperset(view, stored) {
300
259
  return true;
301
260
  }
302
261
  exports.isRepoSuperset = isRepoSuperset;
303
- function validateFieldIncompatibility(incompatibility) {
304
- switch (incompatibility.mismatch) {
262
+ function isFieldDiscrepancyCompatible(discrepancy) {
263
+ switch (discrepancy.mismatch) {
305
264
  case "allowedTypes": {
306
265
  // Since we only track the symmetric difference between the allowed types in the view and
307
266
  // stored schemas, it's sufficient to check if any extra allowed types still exist in the
308
267
  // stored schema.
309
- return incompatibility.stored.length === 0;
268
+ return discrepancy.stored.length === 0;
310
269
  }
311
270
  case "fieldKind": {
312
- return posetLte(incompatibility.stored, incompatibility.view, fieldRealizer);
271
+ return posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);
313
272
  }
314
273
  case "valueSchema": {
315
274
  return false;