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

refactor types w/ instance options system #175

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

theoephraim
Copy link
Member

@theoephraim theoephraim commented Dec 3, 2024

While working through some hairy type issues, I noticed simplification of how the type system works with regards to types that have specific instance options. Previously we were attaching those options to the DmnoDataType instance and then making them available on this during coercion and validation.

I wanted the settings to be available all the time, and realized I overlooked just using a function in a slightly different way.

End users will not notice anything. This may open the door for further simplification later, but for now it was easier to just leave things mostly as is.

Worked in a few related changes as well

  • add allowMissing option to ctx.get - useful within vendor schemas where another node might exist
  • skip resolution if overrides are present
  • add git vendor types ability to autopopulate git sha and branch

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 0e112f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@dmno/configraph Patch
dmno Patch

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

@github-actions github-actions bot added the maintainer Created by an official project maintainer label Dec 3, 2024
Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for dmno ready!

Name Link
🔨 Latest commit 0e112f2
🔍 Latest deploy log https://app.netlify.com/sites/dmno/deploys/6759eb6f4d57c40008e25a3f
😎 Deploy Preview https://deploy-preview-175--dmno.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 3, 2024

Deploy Preview for signup-api canceled.

Name Link
🔨 Latest commit 0e112f2
🔍 Latest deploy log https://app.netlify.com/sites/signup-api/deploys/6759eb6ff9aec90008aaaa8a

@theoephraim theoephraim marked this pull request as draft December 3, 2024 06:14
Copy link

pkg-pr-new bot commented Dec 3, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@dmno/configraph@175
npm i https://pkg.pr.new/dmno@175
npm i https://pkg.pr.new/@dmno/1password-plugin@175

commit: 0e112f2

@theoephraim theoephraim force-pushed the types-with-settings-refactor branch from 5d3db05 to eea2e1e Compare December 11, 2024 19:30
…ent, add allowMissing to ctx.get, add git vendor types autopopulate
@theoephraim theoephraim force-pushed the types-with-settings-refactor branch from eea2e1e to 0e112f2 Compare December 11, 2024 19:43
@theoephraim theoephraim marked this pull request as ready for review December 13, 2024 01:56
resolverCtxAls.enterWith(itemResolverCtx);


if (this.valueResolver) {
if (this.overrides.length) {
Copy link
Member Author

Choose a reason for hiding this comment

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

previously we were still running the resolver, and would still surface resolution errors if there were any. This now skips the resolution instead - both removing the error, and potentially speeding things up.

const node = this.entity?.getConfigNodeByPath(nodePath);
if (!node) {
if (opts?.allowMissing) return;
Copy link
Member Author

Choose a reason for hiding this comment

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

if allowMissing option is toggled on, it wont throw an error anymore. So far this is useful when defining a vendor schema and you have a computed value, and you dont know if the user will pick all of them. I can imagine other cases too.

...gitCommonTypeInfo,
}),
BranchName: createDmnoDataType(
(opts?: {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what prompted the changes. I wanted to be able to toggle having a built-in value (resolver) based on the presence of an instance option.

Copy link
Contributor

@philmillman philmillman left a comment

Choose a reason for hiding this comment

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

🚢

@theoephraim theoephraim merged commit 1b70c75 into main Dec 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer Created by an official project maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants