-
Notifications
You must be signed in to change notification settings - Fork 549
Shared Tree: Persisted Schema Format v2 with persisted metadata support #24590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
bd8406a
Initial change.
TommyBrosman 3165fe3
persistedMetadata is now backed by an object instead of a string.
TommyBrosman 9709ede
Updated codec.spec.ts to cover FormatV2.
TommyBrosman ba058e1
Removed extraneous whitespace change.
TommyBrosman b819742
- Changed TreeNodeStoredSchema implementations to take the write vers…
TommyBrosman 0b5c842
- Changed the stored schema implementation to handle multiple schema …
TommyBrosman ecdca7a
Merge branch 'main' into metadata-schema-3
TommyBrosman 1117c2c
Apply suggestions from code review
TommyBrosman 94a5c39
- Switched to using the SchemaCodecVersion in public APIs. Eventually…
TommyBrosman 302cb21
Merge branch 'metadata-schema-3' of https://github.com/TommyBrosman/F…
TommyBrosman 0ba34d1
- Removed the schema version constant and replaced it with SchemaCode…
TommyBrosman 3275ee0
Minor: reverted changes to FluidClientVersion utils.
TommyBrosman 7c48b9d
Switched back to using min client version for importCompressed.
TommyBrosman a2f4195
Minor: reverted accidental change.
TommyBrosman 4786dcc
Apply suggestions from code review
TommyBrosman 6fa8836
Made persisted metadata schema field naming consistent.
TommyBrosman e4064c7
- Created a separate storedSchemaDecodeDispatcher for v2 schemas.
TommyBrosman ab1b882
- Refactored the node kind dispatch.
TommyBrosman 1027daa
Updated snapshots.
TommyBrosman e527eba
- Removed minimum client version changes. Equivalent changes will be …
TommyBrosman 3eae1f6
Removed more minimumClientVersion glue.
TommyBrosman 98e1b76
Updated API files.
TommyBrosman ecc77c9
Rename: SchemaCodecVersion -> SchemaVersion.
TommyBrosman 37e900f
Merge branch 'main' into metadata-schema-3
TommyBrosman 737633b
Removed top-level persisted metadata.
TommyBrosman 4bb136c
Fixed comments.
TommyBrosman 0bcb90f
Exposed persistedMetadata as a JsonCompatibleReadOnlyObject.
TommyBrosman a675338
Changeset.
TommyBrosman 1d1ef5f
Wired up toStoredSchema. Still needs tests.
TommyBrosman b9898e8
- Updated an old snapshot that didn't include the metadata field.
TommyBrosman 6ca189a
Refactor: persistedMetadata -> metadata on persisted types.
TommyBrosman 85240dc
Apply suggestions from code review
TommyBrosman 8883d45
- Updated the changeset description
TommyBrosman 9c2c13f
Reverted unnecessary change.
TommyBrosman c62f7ec
Wired up node schema metadata persistence. Currently errors on tests …
TommyBrosman 2f6b519
Reverted unneeded change.
TommyBrosman ae1779b
Removed tests for the alpha API I removed in a previous revision.
TommyBrosman 7eff8ab
This revision adds simple-tree persistence for node and field schema …
TommyBrosman f3f572c
- Fixed missing persistedMetadata on fields. toStoredSchema.ts and sh…
TommyBrosman faaf2f7
Merge branch 'main' into metadata-schema-3
TommyBrosman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/*! | ||
TommyBrosman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Copyright (c) Microsoft Corporation and contributors. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { type ObjectOptions, type Static, Type } from "@sinclair/typebox"; | ||
|
||
import { unionOptions } from "../../codec/index.js"; | ||
import { | ||
type Brand, | ||
brandedStringType, | ||
JsonCompatibleReadOnlySchema, | ||
} from "../../util/index.js"; | ||
|
||
export const version = 2 as const; | ||
TommyBrosman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Key (aka Name or Label) for a field which is scoped to a specific TreeNodeStoredSchema. | ||
* | ||
* Stable identifier, used when persisting data. | ||
*/ | ||
export type FieldKey = Brand<string, "tree.FieldKey">; | ||
|
||
/** | ||
* TypeBox Schema for encoding {@link FieldKey} in persisted data. | ||
*/ | ||
export const FieldKeySchema = brandedStringType<FieldKey>(); | ||
|
||
/** | ||
* Identifier for a TreeNode schema. | ||
* Also known as "Definition" | ||
* | ||
* Stable identifier, used when persisting data. | ||
*/ | ||
export type TreeNodeSchemaIdentifier<TName extends string = string> = Brand< | ||
TName, | ||
"tree.TreeNodeSchemaIdentifier" | ||
>; | ||
|
||
/** | ||
* Identifier for a FieldKind. | ||
* Refers to an exact stable policy (ex: specific version of a policy), | ||
* for how to handle (ex: edit and merge edits to) fields marked with this kind. | ||
* Persisted in documents as part of stored schema. | ||
*/ | ||
export type FieldKindIdentifier = Brand<string, "tree.FieldKindIdentifier">; | ||
export const FieldKindIdentifierSchema = brandedStringType<FieldKindIdentifier>(); | ||
|
||
/** | ||
* TypeBox Schema for encoding {@link TreeNodeSchemaIdentifiers} in persisted data. | ||
*/ | ||
export const TreeNodeSchemaIdentifierSchema = brandedStringType<TreeNodeSchemaIdentifier>(); | ||
|
||
export const PersistedMetadataFormat = Type.Optional(JsonCompatibleReadOnlySchema); | ||
|
||
const FieldSchemaFormatBase = Type.Object({ | ||
kind: FieldKindIdentifierSchema, | ||
types: Type.Array(TreeNodeSchemaIdentifierSchema), | ||
persistedMetadata: PersistedMetadataFormat, | ||
}); | ||
|
||
const noAdditionalProps: ObjectOptions = { additionalProperties: false }; | ||
|
||
export const FieldSchemaFormat = Type.Composite([FieldSchemaFormatBase], noAdditionalProps); | ||
|
||
/** | ||
* Persisted version of {@link ValueSchema}. | ||
*/ | ||
export enum PersistedValueSchema { | ||
Number, | ||
String, | ||
Boolean, | ||
FluidHandle, | ||
Null, | ||
} | ||
|
||
/** | ||
* Discriminated union content of tree node schema. | ||
* | ||
* See {@link DiscriminatedUnionDispatcher} for more information on this pattern. | ||
*/ | ||
export const TreeNodeSchemaDataFormat = Type.Object( | ||
{ | ||
/** | ||
* Object node union member. | ||
*/ | ||
object: Type.Optional(Type.Record(Type.String(), FieldSchemaFormat)), | ||
/** | ||
* Map node union member. | ||
*/ | ||
map: Type.Optional(FieldSchemaFormat), | ||
/** | ||
* Leaf node union member. | ||
*/ | ||
leaf: Type.Optional(Type.Enum(PersistedValueSchema)), | ||
/** | ||
* Persisted metadata for this node. | ||
TommyBrosman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
persistedMetadata: PersistedMetadataFormat, | ||
TommyBrosman marked this conversation as resolved.
Show resolved
Hide resolved
TommyBrosman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
unionOptions, | ||
); | ||
|
||
export type TreeNodeSchemaDataFormat = Static<typeof TreeNodeSchemaDataFormat>; | ||
|
||
export type FieldSchemaFormat = Static<typeof FieldSchemaFormat>; | ||
|
||
export type PersistedMetadataFormat = Static<typeof PersistedMetadataFormat>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.