make SpaceRid and ProjectRid assignable to FolderRid - #303
Open
KuberSethi wants to merge 2 commits into
Open
Conversation
a space and a project are both folders in the filesystem domain (FolderType = "FOLDER" | "SPACE" | "PROJECT"), so generated SDK callers no longer have to write `space.rid as FolderRid` to call Folders.children, Folders.get, etc. • encode the IS-A relationship in the platform-sdk-generator by widening a parent rid's LooselyBrandedString brand union to include its children • regenerate FolderRid in @osdk/foundry.filesystem so it accepts SpaceRid and ProjectRid; siblings stay mutually non-assignable
…d only • flip the table from `child → parents[]` to `parent → children[]` so the call site is a direct `?.[]` lookup instead of a reverse Object.entries scan • drop the getChildBrandsOf helper (now one expression at the call site) • only widen brand unions for rid-typed builtins; string-typed components keep their narrow single-brand emit, matching the table's intent • tighten the JSDoc to describe just the mechanism (the domain motivation lives in the PR description and changeset)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before this PR
In
@osdk/foundry.filesystem,SpaceRidandProjectRidare disjoint branded types fromFolderRid, so users have to write a cast to call methods that accept any folder-typed rid:This is inconsistent with the documented domain — the same package defines:
A Space is a Folder, and a Project is a Folder. The type system should reflect that.
After this PR
A
SpaceRidorProjectRidis now assignable toFolderRidwith no cast:Sibling rids remain mutually non-assignable, plain strings still flow into all three (loose brand preserved), and
FolderRid → SpaceRidis still a type error.• encode the IS-A relationship in the
platform-sdk-generatorvia a smallRID_SUBTYPEStable; when a parent rid is emitted, itsLooselyBrandedStringbrand union is widened to include its declared children• apply the resulting shape to
FolderRidin@osdk/foundry.filesystem: `LooselyBrandedString<"FolderRid" | "SpaceRid" | "ProjectRid">`• children (
SpaceRid,ProjectRid) stay as single-brandLooselyBrandedStringso siblings don't collapse into each otherPossible downsides?
This is strictly type-widening on
FolderRidand behaviorally unchanged at runtime — the brand property is phantom (`__LOOSE_BRAND?: T` is never set on a runtime string). No existing code that compiled before should fail to compile.