-
Notifications
You must be signed in to change notification settings - Fork 7
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
Entity templates #193
Entity templates #193
Conversation
🦋 Changeset detectedLatest commit: 692e6db The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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 |
dmno
@dmno/configraph
@dmno/remix-integration
@dmno/vite-integration
@dmno/cloudflare-platform
@dmno/1password-plugin
@dmno/encrypted-vault-plugin
commit: |
|
||
readonly graphRoot: Configraph; | ||
readonly templateRootEntity?: ConfigraphEntity<EntityMetadata, NodeMetadata>; | ||
|
||
constructor( |
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.
This is where the significant changes are.
we now follow up a chain of templates, applying the changes to config nodes from each, and adding/deleting/removing additional entities to the graph if applicable
|
||
// add graph edges based on "pick" | ||
// we will not process individual items yet, but this will give us a DAG of entity dependencies | ||
for (const entity of entitiesArray) { |
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.
no longer doing all these shenanigans with pick up front. instead we create the nodes normally, and then do a pass to re-connect picked nodes to their sources
import { templateContextAls } from './entity-template'; | ||
|
||
// special new data type that will delegate calls back to the original "picked" data type | ||
export class PickedDataType extends ConfigraphDataType { |
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.
pick is a little different than something like inject - which is just a resolver. Pick needs to set all of the data type properties, not just how it is resolved, so we need to be able to link to the source node.
While the line here between data types / config nodes / resolvers all gets a bit blurrier than I would like, I think the end result for users is fairly clean and intuitive.
Deploying dmno with Cloudflare Pages
|
Making entity templates actually work invovled some larger changes, many of which were nice simplicications of other moving parts. Templates can now be created and entities can extend them. Templates can create/update/remove multiple entities from the graph. IDs are all relative to the template while inside of it, and while this was difficult to implement, for end users it should just feel intuitive. The big non-template change is that now pick is more unified with the rest of the system - reimplimented as a special kind of data type. Rather than being defined in a separate section we now use pick via extends - for example: `SOME_ITEM: { extends: pick('someEntityId', 'someNode')` and because of the shorthand format already available (ie `SOME_ITEM: 'string'`), this means `SOME_ITEM: pick()` will also work. The pick args work like this: - `ITEM: pick()` - defaults to picking from graph/template root, use same node path - `ITEM: pick('entityId')` - specify entity by id, use same node path - `ITEM: pick('entityId', 'somePath')` - specify both entity id and node path While we lose the ability to pick multiple keys at once, these changes were driven by user feedback and are worthwhile.
45cb39d
to
a6f6659
Compare
a6f6659
to
5bce745
Compare
5bce745
to
c624c05
Compare
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.
added a few nits, but docs look good. That stable id plugin will help a lot!
Co-authored-by: Phil Miller <[email protected]>
5fff14b
to
692e6db
Compare
This is a big update, driven by the goal of making entity templates work - which will be very important for deployment functionality.
Templates can now be created and entities can extend them. Templates can create/update/remove multiple entities from the graph. IDs are all relative to the template while inside of it, and while this was difficult to implement, for end users it should just feel intuitive. We wont see any user-facing DMNO changes just yet, but these will come next.
In the process, we also changed how "pick" works, to be more unified with the rest of the schema. Now it is reimplimented as a special kind of data type, and uses the existing data type chain for its settings. Rather than being defined in a separate section we now use pick via extends - for example:
SOME_ITEM: { extends: pick('someEntityId', 'someNode')
and because of the shorthand format already available (ieSOME_ITEM: 'string'
), this meansSOME_ITEM: pick()
will also work.The pick args work like this:
ITEM: pick()
- defaults to picking from graph/template root, use same node pathITEM: pick('entityId')
- specify entity by id, use same node pathITEM: pick('entityId', 'somePath')
- specify both entity id and node pathWhile we lose the ability to pick multiple keys at once, these changes were driven by user feedback and are worthwhile.
Additionally this removed some existing constraints around what is considered a cycle, and the system is now more permissive.