accordproject / concerto

Business schema language and runtime
https://concerto.accordproject.org
Apache License 2.0
104 stars 97 forks source link

Vocabularies don't support namespace-scoped decorators #858

Open mttrbrts opened 1 month ago

mttrbrts commented 1 month ago

Bug Report 🐛

The following model definition is valid...

@Term("My HR Model")
@Term_description("Reusable data definitions for the HR department.")
namespace acme.hr@1.0.0

When applying the extract-decorators command

concerto extract-decorators --model hr.cto --removeDecoratorsFromSource 

Produces a vocabulary file:

locale: en
namespace: acme.hr@1.0.0
declarations:
  - : My HR Model
    description: Reusable data definitions for the HR department.

Expected Behavior

I would expect a vocabulary file such as this:

locale: en
namespace: acme.hr@1.0.0
term: My HR Model
description: Reusable data definitions for the HR department.
declarations:
   ...

Possible Solution

  1. The @accordproject/concerto-vocabulary package should be updated to support namespace-scoped decorators
sanketshevkar commented 1 month ago

How do we setup target for setting decorator on a model namespace? My assumption was target would look like this.

 {
                "$class": "org.accordproject.decoratorcommands@0.3.0.Command",
                "type": "UPSERT",
                "target": {
                    "$class": "org.accordproject.decoratorcommands@0.3.0.CommandTarget",
                    "namespace": "test@1.0.0"
}

But when I tried it out in code. It just applied the decorator on top of all the declarations and not on the namespace. https://replit.com/@sanketshevkar/AccordProjectConcerto-Decorator-Command-Set#index.js