Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
45ed7f7
Initial change. Implemented viewSchemaToViewCompatibilitySchema. No t…
TommyBrosman Oct 23, 2025
f76e1eb
Added test coverage using the existing toSimpleSchema tests as a star…
TommyBrosman Oct 23, 2025
491c2ed
Refactored the schema copying code.
TommyBrosman Oct 23, 2025
25eef86
Removed persistedMetadata and metadata from Node schemas copied in Vi…
TommyBrosman Oct 23, 2025
d80bee6
Minor: better typing in copy methods.
TommyBrosman Oct 23, 2025
15fa315
Added snapshot tests.
TommyBrosman Oct 24, 2025
a239d88
Got snapshotting working correctly. It currently involves a lot of ca…
TommyBrosman Oct 24, 2025
b168cd4
Cleanup.
TommyBrosman Oct 24, 2025
95c255a
Added a test around hasStagedSchemaUpgrades.
TommyBrosman Oct 24, 2025
7559289
Added staged allowed type info to SimpleSchema. Started replacing all…
TommyBrosman Oct 28, 2025
2e443d4
Replaced SimpleSchema allowedTypesIdentifiers with simpleAllowedTypes.
TommyBrosman Oct 29, 2025
4e970d2
- Fixed a couple references to allowedTypesIdentifiers.
TommyBrosman Oct 29, 2025
55ca84b
Minor refactors. Addressed some PR feedback.
TommyBrosman Oct 29, 2025
f48aa8a
- PR feedback.
TommyBrosman Oct 29, 2025
ee473df
Removed change that shouldn't be in this PR.
TommyBrosman Oct 29, 2025
8dc387a
Merge branch 'main' into simple-allowed-types
TommyBrosman Oct 29, 2025
9bf1810
- Removed evaluateSimpleAllowedTypes from AnnotatedAllowedTypes (whic…
TommyBrosman Oct 29, 2025
97e1b12
Apply suggestion from @noencke
TommyBrosman Oct 29, 2025
6eddd77
Rename.
TommyBrosman Oct 29, 2025
1464268
Merge branch 'simple-allowed-types' of https://github.com/TommyBrosma…
TommyBrosman Oct 29, 2025
f4e16ea
API Extractor.
TommyBrosman Oct 29, 2025
d00a237
Rename.
TommyBrosman Oct 29, 2025
e17113c
Merge branch 'main' into simple-allowed-types
TommyBrosman Oct 30, 2025
550240b
Fixed exports.
TommyBrosman Oct 30, 2025
1ca9064
Re-implemented most of the PR on top of the new changes to SimpleSche…
TommyBrosman Oct 30, 2025
68ac29d
Merge branch 'main' into view-schema-export
TommyBrosman Oct 31, 2025
49d3333
Copyright headers.
TommyBrosman Oct 31, 2025
9878a4b
- Refactored serializer.
TommyBrosman Oct 31, 2025
264087a
Fixed a few conversion edge cases.
TommyBrosman Oct 31, 2025
41db0f0
Added tests and fixed a bug in the deserializer.
TommyBrosman Oct 31, 2025
795b863
Merged viewSchemaToSimpleSchema and viewSchemaToCompatibilitySchema. …
TommyBrosman Nov 3, 2025
f94bfc2
Fixed test "exportVerbose & exportSimpleSchema"
TommyBrosman Nov 3, 2025
c77cf50
- Fixed a bug in roundtrip serialization test code.
TommyBrosman Nov 3, 2025
ce5701c
Exposed serialization functions as alpha.
TommyBrosman Nov 4, 2025
3bd0e15
Regenerated API file.
TommyBrosman Nov 4, 2025
7471b77
Tests for `allowUnknownOptionalFields`.
TommyBrosman Nov 4, 2025
dd4b51a
Cleanup and PR feedback.
TommyBrosman Nov 4, 2025
9ab7da1
Rename.
TommyBrosman Nov 4, 2025
86d20d6
PR feedback for the serializer/deserializer.
TommyBrosman Nov 4, 2025
7ae29dd
Merge branch 'main' into view-schema-export
TommyBrosman Nov 5, 2025
cf4beb4
Moved snapshots.
TommyBrosman Nov 5, 2025
b65177b
PR feedback.
TommyBrosman Nov 5, 2025
4940667
Merge branch 'main' into view-schema-export
TommyBrosman Nov 5, 2025
b49d114
PR feedback.
TommyBrosman Nov 5, 2025
7478715
PR feedback.
TommyBrosman Nov 6, 2025
cfb1a25
Updated a comment.
TommyBrosman Nov 6, 2025
b2e21d2
Better doc comments.
TommyBrosman Nov 6, 2025
b48bd71
Refactored serializer -> codec and updated a few doc comments.
TommyBrosman Nov 6, 2025
6136e77
Removed fail calls that should be exceptions.
TommyBrosman Nov 6, 2025
c0ef684
Refactored codec to use typebox types for verification.
TommyBrosman Nov 6, 2025
9b5e6d7
Cleanup.
TommyBrosman Nov 6, 2025
32cda8c
Copyright header.
TommyBrosman Nov 7, 2025
331ab54
- Lint
TommyBrosman Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/core-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export { PromiseTimer, setLongTimeout, Timer } from "./timer.js";
export { unreachableCase } from "./unreachable.js";
export { isObject, isPromiseLike } from "./typesGuards.js";
export { oob } from "./oob.js";
export { transformMapValues } from "./map.js";
19 changes: 19 additions & 0 deletions packages/common/core-utils/src/map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

/**
* Transform the values of a Map using the provided transform function.
* @param map - The map to transform.
* @param transformValue - A method for transforming values in the map.
* @returns A new map with the transformed values.
*
* @internal
*/
export function transformMapValues<Key, InputValue, OutputValue>(
map: ReadonlyMap<Key, InputValue>,
transformValue: (value: InputValue, key: Key) => OutputValue,
): Map<Key, OutputValue> {
return new Map([...map.entries()].map(([key, value]) => [key, transformValue(value, key)]));
}
7 changes: 7 additions & 0 deletions packages/dds/tree/api-report/tree.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema,
// @alpha
export function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): SimpleTreeIndex<TKey, TValue>;

// @alpha
export function decodeSimpleSchema(encodedSchema: JsonCompatibleReadOnly, validator?: FormatValidator): SimpleTreeSchema;

// @public @sealed @system
interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
}
Expand All @@ -213,6 +216,9 @@ export interface DirtyTreeMap {
// @alpha
export type DirtyTreeStatus = "new" | "changed" | "moved";

// @alpha
export function encodeSimpleSchema(simpleSchema: SimpleTreeSchema): JsonCompatibleReadOnly;

// @beta
export function enumFromStrings<TScope extends string, const Members extends readonly string[]>(factory: SchemaFactory<TScope>, members: Members): (<TValue extends Members[number]>(value: TValue) => TValue extends unknown ? TreeNode & {
readonly value: TValue;
Expand Down Expand Up @@ -1071,6 +1077,7 @@ export interface SimpleObjectFieldSchema extends SimpleFieldSchema {

// @alpha @sealed
export interface SimpleObjectNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Object, TCustomMetadata> {
readonly allowUnknownOptionalFields: boolean | undefined;
readonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/dds/tree/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export {
type SchemaFactory_base,
type NumberKeys,
type SimpleAllowedTypeAttributes,
encodeSimpleSchema,
decodeSimpleSchema,
} from "./simple-tree/index.js";
export {
SharedTree,
Expand Down
10 changes: 9 additions & 1 deletion packages/dds/tree/src/shared-tree/sharedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,8 @@ function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFie
* Export a {@link SimpleNodeSchema} from a {@link TreeNodeStoredSchema}.
* @privateRemarks
* TODO: Persist node metadata once schema FormatV2 is supported.
* Note on SimpleNodeSchema construction: In the persisted format `persistedMetadata` is just called `metadata` whereas the `metadata`
* field on SimpleNodeSchema is not persisted.
*/
function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeSchema {
const arrayTypes = tryStoredSchemaAsArray(schema);
Expand All @@ -951,7 +953,13 @@ function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeS
for (const [storedKey, field] of schema.objectNodeFields) {
fields.set(storedKey, { ...exportSimpleFieldSchemaStored(field), storedKey });
}
return { kind: NodeKind.Object, fields, metadata: {}, persistedMetadata: schema.metadata };
return {
kind: NodeKind.Object,
fields,
allowUnknownOptionalFields: undefined,
metadata: {},
persistedMetadata: schema.metadata,
};
}
if (schema instanceof MapNodeStoredSchema) {
assert(
Expand Down
4 changes: 4 additions & 0 deletions packages/dds/tree/src/simple-tree/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,7 @@ export {
getShouldIncrementallySummarizeAllowedTypes,
incrementalSummaryHint,
} from "./incrementalAllowedTypes.js";
export {
encodeSimpleSchema,
decodeSimpleSchema,
} from "./simpleSchemaCodec.js";
9 changes: 6 additions & 3 deletions packages/dds/tree/src/simple-tree/api/schemaFromSimple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ function generateNode(
for (const [key, field] of schema.fields) {
fields[key] = generateFieldSchema(field, context, field.storedKey);
}
// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:
// users of this code are expected to handle what ever choice this code makes for cases like this.
return factory.objectAlpha(id, fields, { metadata: schema.metadata });
// Here allowUnknownOptionalFields is implicitly defaulting in the case where the input schema does not explicitly specify the value.
// This is a subjective policy choice: users of this code are expected to handle what ever choice this code makes for cases like this.
return factory.objectAlpha(id, fields, {
metadata: schema.metadata,
allowUnknownOptionalFields: schema.allowUnknownOptionalFields ?? false,
});
}
case NodeKind.Array:
return factory.arrayAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {
Expand Down
Loading
Loading