Skip to content

Conversation

@CraigMacomber
Copy link
Contributor

Description

Refactors to cleanup FlexFieldKind and its implementations.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested a review from a team as a code owner November 13, 2025 19:00
@github-actions github-actions bot added base: main PRs targeted against main branch area: dds Issues related to distributed data structures area: dds: tree labels Nov 13, 2025
});

export const valueFieldEditor: ValueFieldEditor = {
export const requiredFieldEditor: RequiredFieldEditor = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename from "value" to "required" was done long ago, but not everything was renamed. The field kind identifier has to stay, but these kinds of things can be updated to make things more consistant.

Comment on lines -46 to -48
* @param identifier - Globally scoped identifier.
* @param multiplicity - bound on the number of children that fields of this kind may have.
* TODO: replace with numeric upper and lower bounds.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs were moved to FieldKindData, and still apply here (and show up in IntelliSense) due to implements FieldKindData. As these are internal, IntelliSense is what matters most.

Comment on lines -49 to -58
* @param changeHandler - Change handling policy.
* @param allowsTreeSupersetOf - returns true iff `superset` supports all that this does
* and `superset` is an allowed upgrade. Does not have to handle the `never` cases.
* See {@link isNeverField}.
* TODO: when used as a method (instead of a free function like the other superset related functions),
* this name is/signature is confusing and seems backwards.
* @param handlesEditsFrom - Kinds (in addition to this) whose edits can be processed by changeHandler.
* If the kind of a field changes, and edits are rebased across that kind change,
* listing the other old kind here can prevent those edits from being conflicted and
* provide a chance to handle them.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs moved to the members of FieldKindOptions

* provide a chance to handle them.
*/
// TODO: provide this and use it for improved support for rebasing changes across schema upgrades.
// readonly handlesEditsFrom: ReadonlySet<FieldKindIdentifier>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never implemented the ability to preserve edits across schema changes, so this option which only exists to allow preserving edits to a field whose schema has changed never has had an opportunity to do anything, and has also never been provided as anything but empty.

Someday we will likely want this back, but for now it does not need to exist.

* @remarks
* Specifies everything needed to determine if a given field schema upgrade is allowed.
*/
export interface FieldKindOptions<TFieldChangeHandler> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was made force some of the less obvious from context parameters to the constructor into named members of an object for improved readability.

Comment on lines 92 to 97
* Compatibility portion of a {@link FlexFieldKind}.
*
* @remarks
* Specifies everything needed to determine if a given field schema upgrade is allowed.
*/
export interface FieldKindOptions<TFieldChangeHandler> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit misleading to me. The change handler is responsible for a lot more than just determining compatibility and handling schema upgrades. FieldKindOptions contains basically all of the field kind's policy. I would change the doc comment to reflect your PR comment, that this is just a bag of named arguments for field kind construction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds: tree area: dds Issues related to distributed data structures base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants