Skip to content
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

tree: Add schema symbol to TreeNodes to allow NodeKind based narrowing. #22222

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

CraigMacomber
Copy link
Contributor

@CraigMacomber CraigMacomber commented Aug 15, 2024

Description

See changeset for details.

This will be used for things like providing object node specific events with strong typing.

This is aimed to provide the functionality attempted in alexvy86#7 to better support node kind specific data in #22043

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested review from a team as code owners August 15, 2024 21:37
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct changeset-present public api change Changes to a public API base: main PRs targeted against main branch labels Aug 15, 2024
function getKeys(node: TreeNode & WithType<string, NodeKind.Map | NodeKind.Object>): string[];
function getKeys(node: TreeNode): string[] | number[];
function getKeys(node: TreeNode): string[] | number[] {
const schema = Tree.schema(node);
Copy link
Contributor

Choose a reason for hiding this comment

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

Best practices question, since this example is end-user-facing: should we use a switch here with a default handler that errors on unrecognized node kind? I don't know how likely it is that we will add a fundamentally new node type any time soon, but if we were to do so, the default behavior here may not be what the user wants.

Seems like the switch pattern highlights this potential better. Curious what others think.

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.

type TreeObjectNodeUnsafe,
type InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
type TreeArrayNodeUnsafe,
type TreeMapNodeUnsafe,
type InsertableObjectFromSchemaRecordUnsafe,
type InsertableTreeFieldFromImplicitFieldUnsafe,
type FieldSchemaUnsafe,
// System types (not in Internal types for various reasons, like doc links or cannot be named errors).
getJsonSchema,
Copy link
Contributor

Choose a reason for hiding this comment

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

This function isn't a @system type. Should probably go somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Messed up some copy paste there. Fixed.

Copy link
Contributor

@Josmithr Josmithr left a comment

Choose a reason for hiding this comment

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

Left a couple more questions, but overall looks good to me

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Aug 15, 2024

@fluid-example/bundle-size-tests: +603 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 457.93 KB 457.96 KB +35 Bytes
azureClient.js 555.25 KB 555.29 KB +49 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 258.74 KB 258.75 KB +14 Bytes
fluidFramework.js 406.96 KB 407.14 KB +193 Bytes
loader.js 134.2 KB 134.22 KB +14 Bytes
map.js 42.25 KB 42.25 KB +7 Bytes
matrix.js 146.42 KB 146.42 KB +7 Bytes
odspClient.js 523.39 KB 523.44 KB +49 Bytes
odspDriver.js 97.66 KB 97.68 KB +21 Bytes
odspPrefetchSnapshot.js 42.72 KB 42.73 KB +14 Bytes
sharedString.js 163.12 KB 163.13 KB +7 Bytes
sharedTree.js 397.47 KB 397.65 KB +186 Bytes
Total Size 3.3 MB 3.3 MB +603 Bytes

Baseline commit: 425111e

Generated by 🚫 dangerJS against 112af61

@CraigMacomber CraigMacomber enabled auto-merge (squash) August 16, 2024 04:58
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:linkcheck /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test ci:start 1313 linkcheck:full

1: starting server using command "npm run ci:start"
and when url "[ 'http://127.0.0.1:1313' ]" is responding with HTTP status code 200
running tests using command "npm run linkcheck:full"


> [email protected] ci:start
> http-server ./public --port 1313 --silent


> [email protected] linkcheck:full
> npm run linkcheck:fast -- --external


> [email protected] linkcheck:fast
> linkcheck http://localhost:1313 --skip-file skipped-urls.txt --external

Crawling...

Stats:
  377871 links
    2980 destination URLs
       2 URLs ignored
       0 warnings
       0 errors


@CraigMacomber CraigMacomber merged commit 4d3bc87 into microsoft:main Aug 16, 2024
33 checks passed
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 area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch changeset-present public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants