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

feat: Publish ObjectNodeSchema #23090

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CraigMacomber
Copy link
Contributor

Description

This tweaks how ObjectNodeSchema is used so it can work with objectRecursive, then makes it public.

This provides much better access to field schema, which us very useful when implementing logic like schema dependency inversions (where the set of schema allowed in a field might not be known at compile time) or generic node processing (where which schema a node has isn't know at compile time).

This API has been very useful internally, and as we support more cases where the schema is unknown at compile time, this is starting to be useful externally as well.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested review from a team as code owners November 14, 2024 18:58
@github-actions github-actions bot added base: main PRs targeted against main branch 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 labels Nov 14, 2024
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:
  443752 links
    3414 destination URLs
       2 URLs ignored
       0 warnings
       0 errors


Copy link
Collaborator

@msfluid-bot msfluid-bot left a comment

Choose a reason for hiding this comment

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

Code Coverage Summary

↑ packages.dds.tree.src.simple-tree.api:
Line Coverage Change: 0.01%    Branch Coverage Change: No change
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 88.76% 88.76% → No change
Line Coverage 82.35% 82.36% ↑ 0.01%
↑ packages.dds.tree.src.simple-tree:
Line Coverage Change: 0.03%    Branch Coverage Change: 0.01%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 94.07% 94.08% ↑ 0.01%
Line Coverage 97.23% 97.26% ↑ 0.03%

Baseline commit: 9485e13
Baseline build: 306922
Happy Coding!!

Code coverage comparison check passed!!

@msfluid-bot
Copy link
Collaborator

@fluid-example/bundle-size-tests: +245 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 465.72 KB 465.75 KB +35 Bytes
azureClient.js 563.04 KB 563.09 KB +49 Bytes
connectionState.js 724 Bytes 724 Bytes No change
containerRuntime.js 262.34 KB 262.35 KB +14 Bytes
fluidFramework.js 426.99 KB 427.01 KB +14 Bytes
loader.js 134.18 KB 134.19 KB +14 Bytes
map.js 42.71 KB 42.71 KB +7 Bytes
matrix.js 149.84 KB 149.85 KB +7 Bytes
odspClient.js 528.83 KB 528.88 KB +49 Bytes
odspDriver.js 97.88 KB 97.9 KB +21 Bytes
odspPrefetchSnapshot.js 42.81 KB 42.83 KB +14 Bytes
sharedString.js 165.77 KB 165.78 KB +7 Bytes
sharedTree.js 417.45 KB 417.46 KB +7 Bytes
Total Size 3.37 MB 3.37 MB +245 Bytes

Baseline commit: 9485e13

Generated by 🚫 dangerJS against b2d85ce

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 20 changed files in this pull request and generated no suggestions.

Files not reviewed (15)
  • packages/dds/tree/api-report/tree.legacy.public.api.md: Evaluated as low risk
  • packages/dds/tree/src/simple-tree/api/tree.ts: Evaluated as low risk
  • packages/dds/tree/src/simple-tree/objectNode.ts: Evaluated as low risk
  • packages/dds/tree/src/index.ts: Evaluated as low risk
  • packages/dds/tree/src/simple-tree/index.ts: Evaluated as low risk
  • packages/dds/tree/src/simple-tree/api/schemaFactory.ts: Evaluated as low risk
  • packages/dds/tree/src/simple-tree/objectNodeTypes.ts: Evaluated as low risk
  • packages/dds/tree/src/test/simple-tree/api/schemaFactory.spec.ts: Evaluated as low risk
  • packages/framework/fluid-framework/api-report/fluid-framework.alpha.api.md: Evaluated as low risk
  • packages/framework/fluid-framework/api-report/fluid-framework.legacy.alpha.api.md: Evaluated as low risk
  • packages/framework/fluid-framework/api-report/fluid-framework.beta.api.md: Evaluated as low risk
  • packages/dds/tree/api-report/tree.public.api.md: Evaluated as low risk
  • packages/framework/fluid-framework/api-report/fluid-framework.legacy.public.api.md: Evaluated as low risk
  • packages/framework/fluid-framework/api-report/fluid-framework.public.api.md: Evaluated as low risk
  • packages/dds/tree/api-report/tree.alpha.api.md: Evaluated as low risk

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more


[`SchemaFactory.object`](https://fluidframework.com/docs/api/v2/tree/schemafactory-class#object-method) now returns an `ObjectNodeSchema` which exposes a `.fields` property contains a map from its property names to its [`FieldSchema`](https://fluidframework.com/docs/api/v2/tree/fieldschema-class).

Additionally `schema instanceof ObjectNodeSchema` can be used to narrow a `TreeNodeSchema` to an `ObjectNodeSchema`.
Copy link
Contributor

@Josmithr Josmithr Nov 19, 2024

Choose a reason for hiding this comment

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

I'm still not sure how I feel about recommending usage of instanceof, even when it is supported. Do we also have a type-narrowing function we can recommend?

I am all for supporting instanceof to support consumers who choose to use it, but it doesn't seem like a best practice for us to recommend IMO.

@@ -726,6 +728,7 @@ export class SchemaFactory<
* `error TS2589: Type instantiation is excessively deep and possibly infinite.`
* which otherwise gets reported at sometimes incorrect source locations that vary based on incremental builds.
*/
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Before merging?

/**
* Extra data provided on all {@link ObjectNodeSchema} that is not included in the (soon possibly public) ObjectNodeSchema type.
* Extra data provided on all {@link ObjectNodeSchema} in addition to the public ObjectNodeSchema type.
Copy link
Contributor

@Josmithr Josmithr Nov 19, 2024

Choose a reason for hiding this comment

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

Nit (to avoid having to specify "ObjectNodeSchema" twice)

Suggested change
* Extra data provided on all {@link ObjectNodeSchema} in addition to the public ObjectNodeSchema type.
* Extra data provided on all {@link ObjectNodeSchema} beyond what is exposed by that type.

or something

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.

Code changes look good to me. My only concern is recommending consumers use instanceof. Curious what others think, but I generally think of instanceof as an antipattern.

@Josmithr Josmithr requested a review from a team November 19, 2024 18:43
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