-
Notifications
You must be signed in to change notification settings - Fork 196
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
refactor: human-readable resource IDs use double underscore #2310
Conversation
🦋 Changeset detectedLatest commit: 122b309 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/common/src/resourceLabel.ts
Outdated
name, | ||
}: { | ||
readonly namespace: string; | ||
readonly name: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not blocking but this could also be Pick<Resource, 'namespace' | 'name'>
(we should also make Resource
type use readonly
props)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kicking this one until we fix Resource
: #2321
packages/common/src/resourceLabel.ts
Outdated
@@ -0,0 +1,11 @@ | |||
export type ResourceLabel = `${string}__${string}`; | |||
|
|||
export function resourceLabel({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on getResourceLabel
or resourceToLabel
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely prefer one of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going with resourceToLabel
for consistency with resourceToHex
packages/common/src/resourceLabel.ts
Outdated
@@ -0,0 +1,11 @@ | |||
export type ResourceLabel = `${string}__${string}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you wanted to get real fancy, could make this generic, e.g.
export type ResourceLabel<namespace extends string = string, name extends string = string> = `${namespace}__${name}`;
only case I can think in which this might be useful is the RECS component metadata for a given table, where tableName
would show up as e.g. store__Tables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh I like that! I was thinking namespace
and name
should kinda be types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some tiny stylistic things, nothing particularly blocking
Co-authored-by: Kevin Ingersoll <[email protected]>
related to #2173