feat: support custom properties on beans (Refs: beans-digu)#107
Open
feat: support custom properties on beans (Refs: beans-digu)#107
Conversation
- Add Properties map[string]any field to Bean with SetProperty/UnsetProperty/GetProperty helpers - Add scalar JSON to GraphQL schema with properties on Bean, CreateBeanInput, UpdateBeanInput - Support replace-all (properties) and granular (setProperties/unsetProperties) update semantics - Add --set key=value flag to create and update commands, --unset flag to update - Display properties in beans show output (styled, raw, JSON) - YAML-based auto type detection for CLI values (int, float, bool, string) - Full test coverage across bean model, GraphQL resolvers, and CLI flag parser Refs: beans-digu
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.
Summary
Adds support for attaching arbitrary key-value metadata to beans via a
propertiesfield in YAML frontmatter.Bean:
beans-digu— "Support custom properties on beans"Changes
Data Model (
internal/bean/bean.go)Properties map[string]anyfield toBean,frontMatter, andrenderFrontMatterstructsSetProperty(key, value),UnsetProperty(key),GetProperty(key)UnsetPropertynormalizes empty maps to nil (soomitemptyworks correctly)GraphQL Schema
scalar JSONmapped to gqlgen built-ingraphql.Mapproperties: JSONtoBeantype andCreateBeanInputUpdateBeanInput:properties: JSON— replace all (mutually exclusive with set/unset)setProperties: JSON— merge/upsert specific keysunsetProperties: [String!]— remove specific keysCLI
beans create --set key=value(repeatable) — set properties at creation timebeans update --set key=value --unset key(repeatable) — granular property updatesbeans show— displays properties section between relationships and body3→int,true→bool,4.5→float,text→stringTests
parsePropertyFlagstable-driven tests (string, int, bool, float, empty, errors)Example Usage
YAML Frontmatter
Not in scope