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

feat(dcs): add map type support for decorator command targets #722

Merged
merged 32 commits into from
Oct 19, 2023

Conversation

jonathan-casey
Copy link
Member

@jonathan-casey jonathan-casey commented Sep 29, 2023

Description

This change extends the Decorator Manager to support Map Types. A new optional property mapElement is added to the CommandTarget which allows users to specify the granularity of the intended target on a Map. The legal options of which are KEY, VALUE, or KEY_VALUE (both Key and Value).

Example 1:

{
    "$class" : "[email protected]",
    "name" : "web",
    "version": "1.0.0",
    "commands" : [
 
        {
            "$class" : "[email protected]",
            "type" : "UPSERT",
            "target" : {
                "$class" : "[email protected]",
                "namespace" : "[email protected]",
                "declaration" : "Dictionary",
                "mapElement": "KEY_VALUE"
            },
            "decorator" : {
                "$class" : "[email protected]",
                "name" : "Foo",
                "arguments" : []
            }
        }
    ]
}

In the above sample, the @Foo decorator will be added to both elements for the Map Declaration Dictionary

Example 2:

{
    "$class" : "[email protected]",
    "name" : "web",
    "version": "1.0.0",
    "commands" : [
 
        {
            "$class" : "[email protected]",
            "type" : "UPSERT",
            "target" : {
                "$class" : "[email protected]",
                "namespace" : "[email protected]",
                "declaration" : "Dictionary",
                "type" : "[email protected]",
            },
            "decorator" : {
                "$class" : "[email protected]",
                "name" : "Foo",
                "arguments" : []
            }
        }
    ]
}

In the above sample, the @Foo decorator will be added to the Dictionary Map Declaration, if it contains a StringMapKeyType.

Example 3:

{
    "$class" : "[email protected]",
    "name" : "web",
    "version": "1.0.0",
    "commands" : [
 
        {
            "$class" : "[email protected]",
            "type" : "UPSERT",
            "target" : {
                "$class" : "[email protected]",
                "namespace" : "[email protected]",
                "type" : "[email protected]",
            },
            "decorator" : {
                "$class" : "[email protected]",
                "name" : "Foo",
                "arguments" : []
            }
        }
    ]
}

In the above sample, the @Foo decorator will be added to all MapDeclarations found in the ModelFile, which contain a StringMapKeyType.

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format

@jonathan-casey jonathan-casey force-pushed the jonathan/decorator_command_sets_map branch from 8d5dae2 to 508bed4 Compare October 2, 2023 21:30
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
@jonathan-casey jonathan-casey force-pushed the jonathan/decorator_command_sets_map branch from 508bed4 to 134c20b Compare October 2, 2023 21:38
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
@jonathan-casey jonathan-casey marked this pull request as ready for review October 3, 2023 08:58
@jonathan-casey jonathan-casey requested a review from a team October 3, 2023 08:58
Copy link
Contributor

@dselman dselman left a comment

Choose a reason for hiding this comment

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

Looks good. element sounds very generic ... Perhaps something more explicitly (map specific) would help in the model? mapElement ?

Alternatively we could co-opt property and properties for maps, but use special property names so we don't need a model change.

property: 'MAP_KEY'
property: 'MAP_VALUE'
properties: ['MAP_KEY', 'MAP_VALUE']

Thinking about this - we will also need to update the Vocabulary and VocabularyManager to check that terms can be retrieved for map key and value.

Signed-off-by: Jonathan Casey <[email protected]>
@jonathan-casey
Copy link
Member Author

jonathan-casey commented Oct 3, 2023

Looks good. element sounds very generic ... Perhaps something more explicitly (map specific) would help in the model? mapElement ?

Yes, I'm good with mapElement, although I like the elegance of element, I see your point. Given we don't typically reference anything else as an element I felt it sits nicely in the command.

Alternatively we could co-opt property and properties for maps, but use special property names so we don't need a model change.

property: 'MAP_KEY'
property: 'MAP_VALUE'
properties: ['MAP_KEY', 'MAP_VALUE']

I am less in favour of this suggestion . Strictly speaking, Maps do not contain properties. I think we should align the language of the command to that of the models AST, so as to provide consistency and avoid confusion.

Thinking about this - we will also need to update the Vocabulary and VocabularyManager to check that terms can be retrieved for map key and value.

Yes this came up in a team meeting, will be implemented as part of the ongoing Vocabulary efforts.

Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
@jonathan-casey jonathan-casey force-pushed the jonathan/decorator_command_sets_map branch from 048dc8f to d51e5ef Compare October 4, 2023 08:46
Copy link
Contributor

@dselman dselman left a comment

Choose a reason for hiding this comment

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

Very close! I think making the mapElement an enum will make the model self-describing and improve validation.

packages/concerto-core/lib/decoratormanager.js Outdated Show resolved Hide resolved
@jonathan-casey
Copy link
Member Author

jonathan-casey commented Oct 4, 2023

Very close! I think making the mapElement an enum will make the model self-describing and improve validation.

Agree using an Enum set makes sense now that we have DecoratorSet validation changes merged earlier today.

One thing to clarify - do you mean to suggest bumping the concerto version, or the namespace version to [email protected]? It makes sense to bump only the namespace as the changes are scoped to the decoratorcommands version.

@dselman
Copy link
Contributor

dselman commented Oct 5, 2023

Very close! I think making the mapElement an enum will make the model self-describing and improve validation.

Agree using an Enum set makes sense now that we have DecoratorSet validation changes merged earlier today.

One thing to clarify - do you mean to suggest bumping the concerto version, or the namespace version to [email protected]? It makes sense to bump only the namespace as the changes are scoped to the decoratorcommands version.

Validate has been present for a while - the change yesterday exposed it as a standalone method, rather than just doing it implicitly as part of decorateModels.

I meant to bump to [email protected].

@jonathan-casey
Copy link
Member Author

@dselman given we haven't yet cut a release with the [email protected] changes , I suggest we stay with version 0.2.0 for now. This will solve the emergent migration story (in the short term) at DocuSign which surfaces should we move from v0.2.0. Longer term, we need to consider how we support versioning across DCS models, and the metamodel, in a scalable manner.

@dselman
Copy link
Contributor

dselman commented Oct 10, 2023

The problem remaining at v0.2.0 for DCS model will cause is that someone can define a DCS with mapElement and use it with concerto-core v3.13.0 and it will fail validation, even though the namespace version is correct.

I think downstream consumers need to migrate (on the fly or in batch) DCS docs to support what the version of concerto-core supports.

@jonathan-casey jonathan-casey force-pushed the jonathan/decorator_command_sets_map branch from b25603b to 8aab804 Compare October 10, 2023 14:26
@jonathan-casey jonathan-casey force-pushed the jonathan/decorator_command_sets_map branch from e68fb70 to 2d09e53 Compare October 17, 2023 09:27
Copy link
Contributor

@dselman dselman left a comment

Choose a reason for hiding this comment

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

Looking good. A couple of minor changes requested.

packages/concerto-core/lib/decoratormanager.js Outdated Show resolved Hide resolved
packages/concerto-core/lib/decoratormanager.js Outdated Show resolved Hide resolved
packages/concerto-core/lib/decoratormanager.js Outdated Show resolved Hide resolved
packages/concerto-core/lib/decoratormanager.js Outdated Show resolved Hide resolved
Copy link
Contributor

@dselman dselman left a comment

Choose a reason for hiding this comment

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

Bravo!

@jonathan-casey jonathan-casey merged commit 8d4fe1b into main Oct 19, 2023
11 checks passed
@jonathan-casey jonathan-casey deleted the jonathan/decorator_command_sets_map branch October 19, 2023 08:11
@DianaLease DianaLease mentioned this pull request Nov 8, 2023
@mttrbrts mttrbrts added this to the v3.x milestone Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants