UNPKG

@accordproject/concerto-core

Version:

Core Implementation for the Concerto Modeling Language

2 lines • 618 kB
/*! For license information please see concerto-core.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["concerto-core"]=t():e["concerto-core"]=t()}(self,(()=>(()=>{var e={3348:(e,t,r)=>{"use strict";const n=r(3954),{DcsCto:o,DcsNamespace:s}=r(5497);e.exports={MetaModelUtil:n,MetaModelNamespace:"concerto.metamodel@1.0.0",DcsCto:o,DcsNamespace:s}},5497:e=>{"use strict";e.exports={DcsCto:'/*\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nnamespace org.accordproject.decoratorcommands@0.4.0\n\nimport concerto.metamodel@1.0.0.Decorator\n\n/**\n * A reference to an existing named & versioned DecoratorCommandSet\n */\nconcept DecoratorCommandSetReference {\n o String name\n o String version\n}\n\n/**\n * Whether to upsert or append the decorator\n */\nenum CommandType {\n o UPSERT\n o APPEND\n}\n\n/**\n * Which models elements to add the decorator to. Any null\n * elements are \'wildcards\'.\n */\nconcept CommandTarget {\n o String namespace optional\n o String declaration optional\n o String property optional\n o String[] properties optional // property and properties are mutually exclusive\n o String type optional\n o MapElement mapElement optional\n}\n\n/**\n * Map Declaration elements which might be used as a target\n */\nenum MapElement {\n o KEY\n o VALUE\n o KEY_VALUE\n}\n\n/**\n * Applies a decorator to a given target\n */\nconcept Command {\n o CommandTarget target\n o Decorator decorator\n o CommandType type\n o String decoratorNamespace optional\n}\n\n/**\n * A named and versioned set of commands. Includes are supported for modularity/reuse.\n */\nconcept DecoratorCommandSet {\n o String name\n o String version\n o DecoratorCommandSetReference[] includes optional // not yet supported\n o Command[] commands\n}',DcsNamespace:"org.accordproject.decoratorcommands@0.4.0"}},4702:e=>{"use strict";e.exports='/*\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n@DotNetNamespace("AccordProject.Concerto.Metamodel")\nnamespace concerto.metamodel@1.0.0\n\nconcept Position {\n o Integer line\n o Integer column\n o Integer offset\n}\n\nconcept Range {\n o Position start\n o Position end\n o String source optional\n}\n\nconcept TypeIdentifier {\n o String name\n o String namespace optional\n}\n\nabstract concept DecoratorLiteral {\n o Range location optional\n}\n\nconcept DecoratorString extends DecoratorLiteral {\n o String value\n}\n\nconcept DecoratorNumber extends DecoratorLiteral {\n o Double value\n}\n\nconcept DecoratorBoolean extends DecoratorLiteral {\n o Boolean value\n}\n\nconcept DecoratorTypeReference extends DecoratorLiteral {\n o TypeIdentifier type\n o Boolean isArray default=false\n}\n\nconcept Decorator {\n o String name\n o DecoratorLiteral[] arguments optional\n o Range location optional\n}\n\nconcept Identified {\n}\n\nconcept IdentifiedBy extends Identified {\n o String name\n}\n\nabstract concept Declaration {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapKeyType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapValueType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept MapDeclaration extends Declaration {\n o MapKeyType key\n o MapValueType value\n}\n\nconcept StringMapKeyType extends MapKeyType {}\nconcept DateTimeMapKeyType extends MapKeyType {}\n\nconcept ObjectMapKeyType extends MapKeyType {\n o TypeIdentifier type\n}\n\nconcept BooleanMapValueType extends MapValueType {}\nconcept DateTimeMapValueType extends MapValueType {}\nconcept StringMapValueType extends MapValueType {}\nconcept IntegerMapValueType extends MapValueType {}\nconcept LongMapValueType extends MapValueType {}\nconcept DoubleMapValueType extends MapValueType {}\n\nconcept ObjectMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept RelationshipMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept EnumDeclaration extends Declaration {\n o EnumProperty[] properties\n}\n\nconcept EnumProperty {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept ConceptDeclaration extends Declaration {\n o Boolean isAbstract default=false\n o Identified identified optional\n o TypeIdentifier superType optional\n o Property[] properties\n}\n\nconcept AssetDeclaration extends ConceptDeclaration {\n}\n\nconcept ParticipantDeclaration extends ConceptDeclaration {\n}\n\nconcept TransactionDeclaration extends ConceptDeclaration {\n}\n\nconcept EventDeclaration extends ConceptDeclaration {\n}\n\nabstract concept Property {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Boolean isArray default=false\n o Boolean isOptional default=false\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept RelationshipProperty extends Property {\n o TypeIdentifier type\n}\n\nconcept ObjectProperty extends Property {\n o String defaultValue optional\n o TypeIdentifier type\n}\n\nconcept BooleanProperty extends Property {\n o Boolean defaultValue optional\n}\n\nconcept DateTimeProperty extends Property {\n}\n\nconcept StringProperty extends Property {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept StringRegexValidator {\n o String pattern\n o String flags\n}\n\nconcept StringLengthValidator {\n o Integer minLength optional\n o Integer maxLength optional\n}\n\nconcept DoubleProperty extends Property {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept DoubleDomainValidator {\n o Double lower optional\n o Double upper optional\n}\n\nconcept IntegerProperty extends Property {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept IntegerDomainValidator {\n o Integer lower optional\n o Integer upper optional\n}\n\nconcept LongProperty extends Property {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept LongDomainValidator {\n o Long lower optional\n o Long upper optional\n}\n\nconcept AliasedType{\n o String name\n o String aliasedName\n}\nabstract concept Import {\n o String namespace\n o String uri optional\n}\n\nconcept ImportAll extends Import {\n}\n\nconcept ImportType extends Import {\n o String name\n}\n\nconcept ImportTypes extends Import {\n o String[] types\n o AliasedType[] aliasedTypes optional\n}\n\nconcept Model {\n o String namespace\n o String sourceUri optional\n o String concertoVersion optional\n o Import[] imports optional\n o Declaration[] declarations optional\n o Decorator[] decorators optional\n}\n\nconcept Models {\n o Model[] models\n}\n\nabstract concept ScalarDeclaration extends Declaration {\n}\n\nconcept BooleanScalar extends ScalarDeclaration {\n o Boolean defaultValue optional\n}\n\nconcept IntegerScalar extends ScalarDeclaration {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept LongScalar extends ScalarDeclaration {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept DoubleScalar extends ScalarDeclaration {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept StringScalar extends ScalarDeclaration {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept DateTimeScalar extends ScalarDeclaration {\n o String defaultValue optional\n}\n'},3954:(e,t,r)=>{"use strict";const n=r(4865),o="concerto.metamodel@1.0.0",s=r(4702);function a(e,t){return e.declarations.find((e=>e.name===t))}function i(e,t){if(!t[e])throw new Error(`Name ${e} not found`);return t[e].namespace}function c(e,t){switch((e.decorators||[]).forEach((e=>{c(e,t)})),e.$class){case`${o}.Model`:(e.declarations||[]).forEach((e=>{c(e,t)}));break;case`${o}.EnumDeclaration`:case`${o}.AssetDeclaration`:case`${o}.ConceptDeclaration`:case`${o}.EventDeclaration`:case`${o}.TransactionDeclaration`:case`${o}.ParticipantDeclaration`:if(e.superType){const r=e.superType.name;e.superType.namespace=i(r,t),e.superType.name=t[r].name,t[r]?.resolvedName&&(e.superType.resolvedName=t[r].resolvedName)}(e.properties||[]).forEach((e=>{c(e,t)}));break;case`${o}.MapDeclaration`:c(e.key,t),c(e.value,t);break;case`${o}.Decorator`:(e.arguments||[]).forEach((e=>{c(e,t)}));break;case`${o}.ObjectProperty`:case`${o}.RelationshipProperty`:case`${o}.DecoratorTypeReference`:case`${o}.ObjectMapKeyType`:case`${o}.ObjectMapValueType`:case`${o}.RelationshipMapValueType`:e.type.namespace=i(e.type.name,t),e.type.name=t[e.type.name].name,t[e.type.name]?.resolvedName&&(e.type.resolvedName=t[e.type.name].resolvedName);break;case`${o}.StringScalar`:case`${o}.BooleanScalar`:case`${o}.DateTimeScalar`:case`${o}.DoubleScalar`:case`${o}.LongScalar`:case`${o}.IntegerScalar`:e.namespace=i(e.name,t),e.name=t[e.name].name}return e}function l(e,t){const r=JSON.parse(JSON.stringify(t)),n=function(e,t){const r="concerto@1.0.0",n={Concept:{namespace:r,name:"Concept"},Asset:{namespace:r,name:"Asset"},Participant:{namespace:r,name:"Participant"},Transaction:{namespace:r,name:"Transaction"},Event:{namespace:r,name:"Event"}};return(t.imports||[]).forEach((t=>{const r=t.namespace,s=function(e,t){return e.models.find((e=>e.namespace===t))}(e,r);if(t.$class===`${o}.ImportType`){if(!a(s,t.name))throw new Error(`Declaration ${t.name} in namespace ${r} not found`);n[t.name]={namespace:r,name:t.name}}else if(t.$class===`${o}.ImportTypes`){const e=t.aliasedTypes?new Map(t.aliasedTypes.map((({name:e,aliasedName:t})=>[e,t]))):new Map;t.types.forEach((t=>{const o=e.get(t)||t;if(!a(s,t))throw new Error(`Declaration ${t} in namespace ${r} not found`);n[o]=o!==t?{namespace:r,name:o,resolvedName:t}:{namespace:r,name:t}}))}else(s.declarations||[]).forEach((e=>{n[e.name]={namespace:r,name:e.name}}))})),(t.declarations||[]).forEach((e=>{n[e.name]={namespace:t.namespace,name:e.name}})),n}(e,t);return c(r,n),r}function u(e){const t=[];switch(e.$class){case`${o}.ImportAll`:t.push(`${e.namespace}.*`);break;case`${o}.ImportType`:t.push(`${e.namespace}.${e.name}`);break;case`${o}.ImportTypes`:e.types.forEach((r=>{t.push(`${e.namespace}.${r}`)}));break;default:throw new Error(`Unrecognized imports ${e.$class}`)}return t}e.exports={metaModelAst:n,metaModelCto:s,resolveLocalNames:l,resolveLocalNamesForAll:function(e){const t={$class:`${o}.Models`,models:[]};return e.models.forEach((r=>{const n=l(e,r);t.models.push(n)})),t},importFullyQualifiedNames:u,getExternalImports:function(e){const t={};return e.imports&&e.imports.forEach((e=>{const r=u(e);e.uri&&(t[r[0]]=e.uri)})),t}}},3832:(e,t,r)=>{"use strict";const n=r(5558),{DefaultFileLoader:o,FileDownloader:s,ModelWriter:a}=r(8487),{MetaModelUtil:i,MetaModelNamespace:c}=r(3348),l=r(1595),u=r(2438),p=r(1861),d=r(6226),f=r(1768),h=r(3673),m=r(5477),{getRootModel:g}=r(6128),{getDecoratorModel:y}=r(1051),v=r(5430);void 0===r.g&&(r(5437),r(953),r(9869),r(3135),r(6341),r(8088),r(2302),r(7337),r(3218),r(745));const b=r(7833)("concerto:BaseModelManager"),w=(e,t)=>({ast:t,definitions:null,fileName:e}),A={missingDecorator:void 0,invalidDecorator:void 0},$=["concerto@1.0.0","concerto","concerto.decorator@1.0.0"];class E{constructor(e,t){this.processFile=t||w,this.modelFiles={},this.factory=new l(this),this.serializer=new h(this.factory,this,e),this.decoratorFactories=[],this.strict=!!e?.strict,this.options=e,this.addDecoratorModel(),this.addRootModel(),this.decoratorValidation=e?.decoratorValidation?e?.decoratorValidation:A,this.enableMapType=!!e?.enableMapType,this.importAliasing="true"==={NODE_ENV:"production"}?.IMPORT_ALIASING||!!e?.importAliasing,this.metamodelModelFile=new d(this,i.metaModelAst,void 0,c),e?.addMetamodel&&this.addModelFile(this.metamodelModelFile)}isModelManager(){return!0}isStrict(){return this.strict}isAliasedTypeEnabled(){return this.importAliasing}addRootModel(){const{rootModelAst:e,rootModelCto:t,rootModelFile:r}=g(!0),n=new d(this,e,t,r);if(this.strict)this.addModelFile(n,t,r,!0);else{this.addModelFile(n,t,r,!0);const e=g(!1),o=new d(this,e.rootModelAst,e.rootModelCto,e.rootModelFile);this.addModelFile(o,e.rootModelCto,e.rootModelFile,!0)}}addDecoratorModel(){const{decoratorModelAst:e,decoratorModelCto:t,decoratorModelFile:r}=y(),n=new d(this,e,t,r);this.addModelFile(n,t,r,!0)}accept(e,t){return e.visit(this,t)}validateModelFile(e,t){if("string"==typeof e){const{ast:r}=this.processFile(t,e);new d(this,r,e,t).validate()}else e.validate()}_throwAlreadyExists(e){const t=this.modelFiles[e.getNamespace()].getName(),r=t?` in file ${t}`:"",n=e.getName()?` specified in file ${e.getName()}`:"";let o=`Namespace ${e.getNamespace()}${n} is already declared${r}`;throw new Error(o)}addModelFile(e,t,r,n){if(b("addModelFile","addModelFile",e,r),this.isStrict()&&!e.getVersion())throw new Error("Cannot add an unversioned namespace when 'strict' is true");return this.modelFiles[e.getNamespace()]?this._throwAlreadyExists(e):(n||(this.options?.metamodelValidation&&this.validateAst(e),e.validate()),this.modelFiles[e.getNamespace()]=e),e}validateAst(e){const{version:t}=f.parseNamespace(f.getNamespace(e.getAst().$class)),{version:r}=f.parseNamespace(c);if(t!==r)throw new v(`Model file version ${t} does not match metamodel version ${r}`);const n=!!this.getModelFile(c);n||this.addModelFile(this.metamodelModelFile,void 0,c,!0);try{this.getSerializer().fromJSON(e.getAst())}catch(e){if(this.isStrict())throw new v(e.message);console.warn("Invalid metamodel found. This will throw an exception in a future release. ",e.message)}n||this.deleteModelFile(c)}addModel(e,t,r,n){b("addModel","addModel",e,r);const{ast:o,definitions:s}=this.processFile(r,e),a=t||s,i=new d(this,o,a,r);return this.addModelFile(i,a,r,n),i}updateModelFile(e,t,r){if(b("updateModelFile","updateModelFile",e,t),"string"==typeof e){const{ast:n}=this.processFile(t,e);let o=new d(this,n,e,t);return this.updateModelFile(o,t,r)}if(!this.modelFiles[e.getNamespace()])throw new Error(`Model file for namespace ${e.getNamespace()} not found`);return r||e.validate(),this.modelFiles[e.getNamespace()]=e,e}deleteModelFile(e){if(!this.modelFiles[e])throw new Error("Model file does not exist");delete this.modelFiles[e]}addModelFiles(e,t,r){const n="addModelFiles";b(n,"addModelFiles",e,t);const o={};Object.assign(o,this.modelFiles);let s=[];try{for(let r=0;r<e.length;r++){const n=e[r];let o,a=null;if(t&&(a=t[r]),"string"==typeof n){const{ast:e}=this.processFile(a,n);o=new d(this,e,n,a)}else o=n;this.modelFiles[o.getNamespace()]?this._throwAlreadyExists(o):(this.modelFiles[o.getNamespace()]=o,s.push(o))}return r||this.validateModelFiles(),s}catch(e){throw this.modelFiles={},Object.assign(this.modelFiles,o),e}finally{b(n,s)}}validateModelFiles(){for(let e in this.modelFiles)this.modelFiles[e].validate()}async updateExternalModels(e,t){b("updateExternalModels","updateExternalModels",e),t||(t=new s(new o(this.processFile),(e=>i.getExternalImports(e.ast))));const r={};Object.assign(r,this.modelFiles);try{const r=await t.downloadExternalDependencies(this.getModelFiles(),e),n=[];return r.forEach((e=>{const t=new d(this,e.ast,e.definitions,e.fileName);this.modelFiles[t.getNamespace()]?n.push(this.updateModelFile(t,t.getName(),!0)):n.push(this.addModelFile(t,null,t.getName(),!0))})),this.validateModelFiles(),n}catch(e){throw this.modelFiles={},Object.assign(this.modelFiles,r),e}}writeModelsToFileSystem(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a.writeModelsToFileSystem(this.getModelFiles(),e,t)}getDecoratorValidation(){return this.decoratorValidation}getModelFiles(e){let t=Object.keys(this.modelFiles),r=[];for(let n=0;n<t.length;n++){const o=t[n];!e&&$.includes(o)||r.push(this.modelFiles[o])}return r}getModels(e){const t=this.getModelFiles();let r=[];const o=Object.assign({includeExternalModels:!0},e);return t.forEach((function(e){if(e.isExternal()&&!o.includeExternalModels)return;let t;if("UNKNOWN"!==e.fileName&&null!==e.fileName&&e.fileName){let r=e.fileName;t=n.basename(r)}else t=e.namespace+".cto";r.push({name:t,content:e.definitions})})),r}resolveType(e,t){if(f.isPrimitiveType(t))return t;let r=f.getNamespace(t),n=this.getModelFile(r);if(!n){let r=u.messageFormatter("modelmanager-resolvetype-nonsfortype");throw new p(r({type:t,context:e}))}if(n.isLocalType(t))return t;let o=u.messageFormatter("modelmanager-resolvetype-notypeinnsforcontext");throw new p(o({context:e,type:t,namespace:n.getNamespace()}))}clearModelFiles(){this.modelFiles={},this.addDecoratorModel(),this.addRootModel()}getModelFile(e){return this.modelFiles[e]}getModelFileByFileName(e){return this.getModelFiles().filter((t=>t.getName()===e))[0]}getNamespaces(){return Object.keys(this.modelFiles)}getType(e){const t=f.getNamespace(e),r=this.getModelFile(t);if(!r){const t=u.messageFormatter("modelmanager-gettype-noregisteredns");throw new m(e,t({type:e}))}const n=r.getType(e);if(!n){const r=u.messageFormatter("modelmanager-gettype-notypeinns");throw new m(e,r({type:f.getShortName(e),namespace:t}))}return n}getAssetDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getAssetDeclarations())),[])}getTransactionDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getTransactionDeclarations())),[])}getEventDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getEventDeclarations())),[])}getParticipantDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getParticipantDeclarations())),[])}getMapDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getMapDeclarations())),[])}getEnumDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getEnumDeclarations())),[])}getConceptDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getConceptDeclarations())),[])}getFactory(){return this.factory}getSerializer(){return this.serializer}getDecoratorFactories(){return this.decoratorFactories}addDecoratorFactory(e){this.decoratorFactories.push(e)}derivesFrom(e,t){let r=this.getType(e);for(;r;){if(r.getFullyQualifiedName()===t)return!0;r=r.getSuperTypeDeclaration()}return!1}resolveMetaModel(e){const t=this.getAst(!1,!0);return i.resolveLocalNames(t,e)}fromAst(e,t){this.clearModelFiles(),e.models.forEach((e=>{if(!$.includes(e.namespace)){const t=new d(this,e);this.addModelFile(t,null,null,!0)}})),t?.disableValidation||this.validateModelFiles()}getAst(e,t){const r={$class:`${c}.Models`,models:[]};return this.getModelFiles(t).forEach((t=>{let n=t.getAst();e&&(n=this.resolveMetaModel(n)),r.models.push(n)})),r}filter(e){const t=new E({...this.options},this.processFile),r=[];let n=Object.values(this.modelFiles).map((n=>n.filter(e,t,r))).filter(Boolean);n=n.filter((e=>!e.isSystemModelFile()));const o=n.map((e=>{const t=e.getAst();let n=!1;return r.forEach((r=>{const o=f.getNamespace(r);if(!o.startsWith("concerto@")&&"concerto"!==o&&e.getImports().includes(r)){const e=f.getShortName(r),o=f.getNamespace(r);t.imports=t.imports.filter((t=>{const r="ImportType"===f.getShortName(t.$class)&&t.name===e&&t.namespace===o;return r&&(n=!0),!r})),t.imports.forEach((t=>{t.namespace===o&&"ImportTypes"===f.getShortName(t.$class)&&(t.types=t.types.filter((t=>{const r=t===e;return r&&(n=!0),!r})))}))}})),n?new d(this,t,void 0,e.fileName):e}));return t.addModelFiles(o),t}}e.exports=E},7662:(e,t,r)=>{"use strict";const n=r(9472),o="resource",{TypedStack:s}=r(8487),a=r(3561);void 0===r.g&&r(9481),e.exports=class{constructor(e){this.modelManager=e}validate(e,t){const r=this.getTypeDeclaration(e),n={};n.stack=new s(e);const o=new a(this,t);r.accept(o,n)}getModelManager(){return this.modelManager}isObject(e){return"object"==typeof e&&e.$class}getTypeDeclaration(e){if(!e.$class)throw new Error("Input object does not have a $class attribute.");return this.modelManager.getType(e.$class)}getIdentifier(e){const t=this.getTypeDeclaration(e).getIdentifierFieldName();if(!t)throw new Error(`Object does not have an identifier: ${JSON.stringify(e)}`);return e[t]}isIdentifiable(e){const t=this.getTypeDeclaration(e);return!t.isSystemIdentified()&&null!==t.getIdentifierFieldName()}isRelationship(e){return"string"==typeof e&&e.startsWith(`${o}:`)}setIdentifier(e,t){const r=this.getTypeDeclaration(e).getIdentifierFieldName(),n=JSON.parse(JSON.stringify(e));return n[r]=t,n}getFullyQualifiedIdentifier(e){return this.getTypeDeclaration(e),`${e.$class}#${this.getIdentifier(e)}`}toURI(e){return this.getTypeDeclaration(e),`${o}:${e.$class}#${encodeURI(this.getIdentifier(e))}`}fromURI(e){let t;try{t=n.parse(e)}catch(t){throw new Error("Invalid URI: "+e)}const r=t.protocol;if(r&&r!==o)throw new Error("Invalid URI scheme: "+e);if(t.username||t.password||t.port||t.query)throw new Error("Invalid resource URI format: "+e);return{typeDeclaration:this.getTypeDeclaration({$class:t.path}),id:decodeURIComponent(t.fragment)}}getType(e){return this.getTypeDeclaration(e).getName()}getNamespace(e){return this.getTypeDeclaration(e).getNamespace()}}},7624:(e,t,r)=>{"use strict";const n=r(3464),o=r(7657);n.extend(o);const s=r(4491);n.extend(s);const a=r(3221);n.extend(a);const i=r(279);n.extend(i),e.exports={setCurrentTime:function(e,t){const r="number"==typeof t?t:n().utcOffset(),o=e?n.utc(e):n().utc();if(!o.isValid())throw new Error(`Current time '${e}' is not in standard UTC format`);const s=o.utcOffset(r);if(!s.isValid())throw new Error(`Cannot set current time to '${e}' with UTC offset '${t}'`);return{currentTime:s,utcOffset:r}}}},2307:(e,t,r)=>{"use strict";const n=r(3198),o=r(1768),{MetaModelNamespace:s}=r(3348);function a(e){const t=Object.keys(e),r={};return t.forEach((t=>{"$class"!==t&&(r[t]=e[t])})),r}function i(e){const t={[`${s}.DecoratorString`]:"String",[`${s}.DecoratorNumber`]:"Number",[`${s}.DecoratorBoolean`]:"Boolean"};return e.$class.endsWith("TypeReference")?{typeReference:{name:e.type.name,namespace:e.type.namespace,resolvedName:e.type.resolvedName,isArray:e.isArray}}:{type:t[e.$class],value:e.value}}function c(e){return{action:e.type,target:a(e.target),decorator:(t=e.decorator,{name:t.name,arguments:0===t.arguments?.length?void 0:t.arguments?.map(i)})};var t}e.exports={jsonToYaml:function(e){const t=o.getNamespace(e.$class),r={decoratorCommandsVersion:o.parseNamespace(t).version,name:e.name,version:e.version,commands:e.commands.map(c)};let s=n.stringify(r);return s=s.replace(/: "(true|false)"/g,": $1"),s=s.replace(/: "(\d+(\.\d+)?)"/g,": $1"),s},yamlToJson:function(e){const t=n.parse(e),r="org.accordproject.decoratorcommands@"+t.decoratorCommandsVersion;return{$class:o.getFullyQualifiedName(r,"DecoratorCommandSet"),name:t.name,version:t.version,commands:t.commands.map((e=>function(e,t){return{$class:o.getFullyQualifiedName(e,"Command"),type:t.action,target:{$class:o.getFullyQualifiedName(e,"CommandTarget"),...t.target},decorator:(r=t.decorator,{$class:o.getFullyQualifiedName(s,"Decorator"),name:r.name,arguments:r.arguments?r.arguments.map((e=>function(e,t){const r={String:`${e}.DecoratorString`,Number:`${e}.DecoratorNumber`,Boolean:`${e}.DecoratorBoolean`};return"typeReference"===Object.keys(t)[0]?{$class:o.getFullyQualifiedName(e,"DecoratorTypeReference"),type:{$class:o.getFullyQualifiedName(e,"TypeIdentifier"),name:t.typeReference.name,...void 0!==t.typeReference.namespace?{namespace:t.typeReference.namespace}:{},...void 0!==t.typeReference.resolvedName?{resolvedName:t.typeReference.resolvedName}:{}},isArray:t.typeReference.isArray}:{$class:r[t.type],value:"String"===t.type?String(t.value):t.value}}(s,e))):[]})};var r}(r,e)))}}}},8298:(e,t,r)=>{"use strict";const n=r(9481),o=r(1768),{MetaModelNamespace:s}=r(3348);class a{static Action={EXTRACT_ALL:0,EXTRACT_VOCAB:1,EXTRACT_NON_VOCAB:2};constructor(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:a.Action.EXTRACT_ALL,s=arguments.length>5?arguments[5]:void 0;this.extractionDictionary={},this.removeDecoratorsFromModel=e,this.locale=t,this.enableDcsNamespaceTarget=!!s?.enableDcsNamespaceTarget,this.dcs_version=r,this.sourceModelAst=n,this.updatedModelAst=n,this.action=Object.values(a.Action).includes(o)?o:a.Action.EXTRACT_ALL}isVocabDecorator(e){return"Term"===e||e.startsWith("Term_")}constructDCSDictionary(e,t,r){const n={declaration:r?.declaration||"",property:r?.property||"",mapElement:r?.mapElement||"",dcs:JSON.stringify(t)};this.extractionDictionary[e]&&Array.isArray(this.extractionDictionary[e])?this.extractionDictionary[e].push(n):this.extractionDictionary[e]=[n]}transformNonVocabularyDecorators(e,t,r){const{name:n,version:s}=o.parseNamespace(t),a=n,i=s;if(e?.length>0){const t={$class:`org.accordproject.decoratorcommands@${this.dcs_version}.DecoratorCommandSet`,name:a,version:i,commands:e};r.push(t)}return r}transformVocabularyDecorators(e,t,r){if(Object.keys(e).length>0){let n="";n+=`locale: ${this.locale}\n`,n+=`namespace: ${t}\n`,n+="declarations:\n",Object.keys(e).forEach((t=>{e[t].term&&(n+=` - ${t}: ${e[t].term}\n`);const r=Object.keys(e[t]).filter((e=>"term"!==e&&"propertyVocabs"!==e));r.length>0&&(e[t].term||(n+=` - ${t}: ${t}\n`),r.forEach((r=>{n+=` ${r}: ${e[t][r]}\n`}))),e[t].propertyVocabs&&Object.keys(e[t].propertyVocabs).length>0&&(e[t].term||0!==r.length||(n+=` - ${t}: ${t}\n`),n+=" properties:\n",Object.keys(e[t].propertyVocabs).forEach((r=>{n+=` - ${r}: ${e[t].propertyVocabs[r].term||""}\n`,Object.keys(e[t].propertyVocabs[r]).filter((e=>"term"!==e)).forEach((o=>{n+=` ${o}: ${e[t].propertyVocabs[r][o]}\n`}))})))})),r.push(n)}return r}transformVocabularyDecoratorsV2(e,t,r){if(Object.keys(e).length>0){let n="";n+=`locale: ${this.locale}\n`,n+=`namespace: ${t}\n`,e.namespace&&Object.keys(e.namespace).length>0&&(e.namespace.term&&(n+=`term: ${e.namespace.term}\n`),Object.keys(e.namespace).filter((e=>"term"!==e)).forEach((t=>{n+=`${t}: ${e.namespace[t]}\n`}))),e.declarations&&Object.keys(e.declarations).length>0?(n+="declarations:\n",Object.keys(e.declarations).forEach((t=>{e.declarations[t].term&&(n+=` - ${t}: ${e.declarations[t].term}\n`);const r=Object.keys(e.declarations[t]).filter((e=>"term"!==e&&"propertyVocabs"!==e));r.length>0&&(e.declarations[t].term||(n+=` - ${t}: ${t}\n`),r.forEach((r=>{n+=` ${r}: ${e.declarations[t][r]}\n`}))),e.declarations[t].propertyVocabs&&Object.keys(e.declarations[t].propertyVocabs).length>0&&(e.declarations[t].term||0!==r.length||(n+=` - ${t}: ${t}\n`),n+=" properties:\n",Object.keys(e.declarations[t].propertyVocabs).forEach((r=>{n+=` - ${r}: ${e.declarations[t].propertyVocabs[r].term||""}\n`,Object.keys(e.declarations[t].propertyVocabs[r]).filter((e=>"term"!==e)).forEach((o=>{n+=` ${o}: ${e.declarations[t].propertyVocabs[r][o]}\n`}))})))}))):n+="declarations: []\n",r.push(n)}return r}constructTarget(e,t){const r={$class:`org.accordproject.decoratorcommands@${this.dcs_version}.CommandTarget`,namespace:e};return t.declaration&&""!==t.declaration&&(r.declaration=t.declaration),t.property&&""!==t.property&&(r.property=t.property),t.mapElement&&""!==t.mapElement&&(r.mapElement=t.mapElement),r}parseNonVocabularyDecorators(e,t,r,n){const o={$class:"concerto.metamodel@1.0.0.Decorator",name:t.name};if(t.arguments){const e=t.arguments.map((e=>({$class:e.$class,value:e.value})));o.arguments=e}let s={$class:`org.accordproject.decoratorcommands@${r}.Command`,type:"UPSERT",target:n,decorator:o};return e.push(s),e}parseVocabularies(e,t,r){if(e[t.declaration]=e[t.declaration]||{propertyVocabs:{}},""!==t.property)if(e[t.declaration].propertyVocabs[t.property]||(e[t.declaration].propertyVocabs[t.property]={}),"Term"===r.name)e[t.declaration].propertyVocabs[t.property].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration].propertyVocabs[t.property][n]=r.arguments[0].value}else if(""!==t.mapElement)if(e[t.declaration].propertyVocabs[t.mapElement]||(e[t.declaration].propertyVocabs[t.mapElement]={}),"Term"===r.name)e[t.declaration].propertyVocabs[t.mapElement].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration].propertyVocabs[t.mapElement][n]=r.arguments[0].value}else if("Term"===r.name)e[t.declaration].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration][n]=r.arguments[0].value}return e}parseVocabulariesV2(e,t,r){if(""===t.declaration){if(e.namespace=e.namespace||{},"Term"===r.name)e.namespace.term=r.arguments[0].value;else{const t=r.name.split("Term_")[1];if("namespace"===t||"locale"===t||"declarations"===t)throw new Error(`Invalid vocabulary key: ${t}. The key should not be one of the reserved keys: namespace, locale, declarations`);e.namespace[t]=r.arguments[0].value}return e}if(e.declarations=e.declarations||{},e.declarations[t.declaration]=e.declarations[t.declaration]||{propertyVocabs:{}},""!==t.property)if(e.declarations[t.declaration].propertyVocabs[t.property]||(e.declarations[t.declaration].propertyVocabs[t.property]={}),"Term"===r.name)e.declarations[t.declaration].propertyVocabs[t.property].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];if(n===t.property)throw new Error(`Invalid vocabulary key: "${n}". The key should not be the name of the current property.`);e.declarations[t.declaration].propertyVocabs[t.property][n]=r.arguments[0].value}else if(""!==t.mapElement)if(e.declarations[t.declaration].propertyVocabs[t.mapElement]||(e.declarations[t.declaration].propertyVocabs[t.mapElement]={}),"Term"===r.name)e.declarations[t.declaration].propertyVocabs[t.mapElement].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];if(n===t.mapElement)throw new Error(`Invalid vocabulary key: "${n}". The key should not be the name of the current property.`);e.declarations[t.declaration].propertyVocabs[t.mapElement][n]=r.arguments[0].value}else if("Term"===r.name)e.declarations[t.declaration].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];if("properties"===n||n===t.declaration)throw new Error(`Invalid vocabulary key: "${n}". The key cannot be a reserved word such as "properties" or the name of the current declaration.`);e.declarations[t.declaration][n]=r.arguments[0].value}return e}transformDecoratorsAndVocabularies(){let e=[],t=[];return Object.keys(this.extractionDictionary).forEach((r=>{const n=this.extractionDictionary[r];let o=[],s={};n.forEach((e=>{const t=JSON.parse(e.dcs),n=this.constructTarget(r,e);t.forEach((t=>{const r=this.isVocabDecorator(t.name);r||this.action===a.Action.EXTRACT_VOCAB||(o=this.parseNonVocabularyDecorators(o,t,this.dcs_version,n)),r&&this.action!==a.Action.EXTRACT_NON_VOCAB&&(s=this.enableDcsNamespaceTarget?this.parseVocabulariesV2(s,e,t):this.parseVocabularies(s,e,t))}))})),this.action!==a.Action.EXTRACT_VOCAB&&(e=this.transformNonVocabularyDecorators(o,r,e)),this.action!==a.Action.EXTRACT_NON_VOCAB&&(t=this.enableDcsNamespaceTarget?this.transformVocabularyDecoratorsV2(s,r,t):this.transformVocabularyDecorators(s,r,t))})),{decoratorCommandSet:e,vocabularies:t}}filterOutDecorators(e){return this.removeDecoratorsFromModel?this.action===a.Action.EXTRACT_ALL?void 0:this.action===a.Action.EXTRACT_VOCAB?e.filter((e=>!this.isVocabDecorator(e.name))):e.filter((e=>this.isVocabDecorator(e.name))):e}processMapDeclaration(e,t){if(e.key&&e.key.decorators){const r={declaration:e.name,mapElement:"KEY"};this.constructDCSDictionary(t,e.key.decorators,r),e.key.decorators=this.filterOutDecorators(e.key.decorators)}if(e.value&&e.value.decorators){const r={declaration:e.name,mapElement:"VALUE"};this.constructDCSDictionary(t,e.value.decorators,r),e.value.decorators=this.filterOutDecorators(e.value.decorators)}return e}processProperties(e,t,r){return e.map((e=>{if(e.decorators){const n={declaration:t,property:e.name};this.constructDCSDictionary(r,e.decorators,n),e.decorators=this.filterOutDecorators(e.decorators)}return e}))}processDeclarations(e,t){return e.map((e=>{if(e.decorators){const r={declaration:e.name};this.constructDCSDictionary(t,e.decorators,r),e.decorators=this.filterOutDecorators(e.decorators)}if(e.$class===`${s}.MapDeclaration`&&(e=this.processMapDeclaration(e,t)),e.properties){const r=this.processProperties(e.properties,e.name,t);e.properties=r}return e}))}processModels(){const e=this.sourceModelAst.models.map((e=>{e?.decorators?.length>0&&(this.constructDCSDictionary(e.namespace,e.decorators,{}),e.decorators=this.filterOutDecorators(e.decorators));const t=this.processDeclarations(e.declarations,e.namespace);return e.declarations=t,e}));this.updatedModelAst={...this.updatedModelAst,models:e}}extract(){this.processModels();const e=new n;e.fromAst(this.updatedModelAst);const t=this.transformDecoratorsAndVocabularies();return{updatedModelManager:e,decoratorCommandSet:t.decoratorCommandSet,vocabularies:t.vocabularies}}}e.exports=a},6033:(e,t,r)=>{"use strict";const n=r(9481),o=r(3673),s=r(1595),a=r(1768),{MetaModelNamespace:i}=r(3348),c=r(2722),l=r(8298),{Warning:u,ErrorCodes:p}=r(8487),d=r(1861),f=r(4971)({circles:!0,proto:!1}),{jsonToYaml:h,yamlToJson:m}=r(2307);void 0===r.g&&r(6226);const g="0.4.0",y="concerto version \"^3.0.0\"\nnamespace org.accordproject.decoratorcommands@0.4.0\n\nimport concerto.metamodel@1.0.0.Decorator\n\n/**\n * A reference to an existing named & versioned DecoratorCommandSet\n */\nconcept DecoratorCommandSetReference {\n o String name\n o String version\n}\n\n/**\n * Whether to upsert or append the decorator\n */\nenum CommandType {\n o UPSERT\n o APPEND\n}\n\n/**\n * Which models elements to add the decorator to. Any null\n * elements are 'wildcards'.\n */\nconcept CommandTarget {\n o String namespace optional\n o String declaration optional\n o String property optional\n o String[] properties optional // property and properties are mutually exclusive\n o String type optional\n o MapElement mapElement optional\n}\n\n/**\n * Map Declaration elements which might be used as a target\n */\nenum MapElement {\n o KEY\n o VALUE\n o KEY_VALUE\n}\n\n/**\n * Applies a decorator to a given target\n */\nconcept Command {\n o CommandTarget target\n o Decorator decorator\n o CommandType type\n o String decoratorNamespace optional\n}\n\n/**\n * A named and versioned set of commands. Includes are supported for modularity/reuse.\n */\nconcept DecoratorCommandSet {\n o String name\n o String version\n o DecoratorCommandSetReference[] includes optional // not yet supported\n o Command[] commands\n}\n";class v{constructor(e,t){this.command=e,this.index=t}getCommand(){return this.command}getIndex(){return this.index}}class b{static validate(e,t){const r=new n({strict:!0,metamodelValidation:!0,addMetamodel:!0});t&&r.addModelFiles(t),r.addCTOModel(y,"decoratorcommands@0.3.0.cto");const a=new s(r);return new o(a,r).fromJSON(e),r}static migrateTo(e,t){if(e instanceof Object)for(let r in e){if("$class"===r&&e[r].includes("org.accordproject.decoratorcommands")){const t=a.getNamespace(e.$class);e[r]=e[r].replace(a.parseNamespace(t).version,g)}(e[r]instanceof Object||e[r]instanceof Array)&&this.migrateTo(e[r],t)}return e}static canMigrate(e,t){const r=a.parseNamespace(a.getNamespace(e.$class)).version;return c.major(r)===c.major(t)&&c.minor(r)<c.minor(t)}static addDcsWithIndexToMap(e,t,r){const n=e.get(t);n?n.push(r):e.set(t,[r])}static getDecoratorMaps(e){const t=new Map,r=new Map,n=new Map,o=new Map,s=new Map;return e.commands.map(((e,a)=>{const i=new v(e,a);switch(!0){case!!e?.target?.type:this.addDcsWithIndexToMap(s,e.target.type,i);break;case!!e?.target?.property:this.addDcsWithIndexToMap(n,e.target.property,i);break;case!!e?.target?.properties:e.target.properties.forEach((e=>{this.addDcsWithIndexToMap(n,e,i)}));break;case!!e?.target?.mapElement:this.addDcsWithIndexToMap(o,e.target.mapElement,i);break;case!!e?.target?.declaration:this.addDcsWithIndexToMap(r,e.target.declaration,i);break;case!!e?.target?.namespace:this.addDcsWithIndexToMap(t,e.target.namespace,i)}})),{namespaceCommandsMap:t,declarationCommandsMap:r,propertyCommandsMap:n,mapElementCommandsMap:o,typeCommandsMap:s}}static migrateAndValidate(e,t,r,a,i){if(r&&this.canMigrate(t,g)&&(t=this.migrateTo(t,g)),a){const r=new n({strict:!0,metamodelValidation:!0,addMetamodel:!0,enableMapType:!!e?.enableMapType,importAliasing:e.isAliasedTypeEnabled()});r.addModelFiles(e.getModelFiles()),r.addCTOModel(y,"decoratorcommands@0.4.0.cto");const a=new s(r);new o(a,r).fromJSON(t),i&&t.commands.forEach((e=>{b.validateCommand(r,e)}))}}static pushMapValues(e,t,r){for(const n of t.get(r)||[])e.push(n)}static decorateModels(e,t,r){if(r?.skipValidationAndResolution){if(!1===r?.disableMetamodelResolution||0==!r?.disableMetamodelValidation)throw new Error("skipValidationAndResolution cannot be used with disableMetamodelResolution or disableMetamodelValidation options as false");r.disableMetamodelResolution=!0,r.disableMetamodelValidation=!0}this.migrateAndValidate(e,t,r?.migrate,r?.validate,r?.validateCommands);const o=t.commands.flatMap((e=>[{$class:`${i}.ImportType`,name:e.decorator.name,namespace:e.decorator.namespace?e.decorator.namespace:r?.defaultNamespace}].concat(e.decorator.arguments?e.decorator.arguments?.filter((e=>e.type)).map((e=>({$class:`${i}.ImportType`,name:e.type.name,namespace:e.type.namespace?e.type.namespace:r?.defaultNamespace}))):[]))).filter((e=>e.namespace)),{namespaceCommandsMap:s,declarationCommandsMap:c,propertyCommandsMap:l,mapElementCommandsMap:u,typeCommandsMap:p}=this.getDecoratorMaps(t),d=r?.disableMetamodelResolution?e.getAst(!1,!0):e.getAst(!0,!0),h=f(d);h.models.forEach((e=>{const t=o.filter((t=>t.namespace!==e.namespace));e.imports=e.imports?e.imports.concat(t):t;const n=a.parseNamespace(e.namespace).name;e.declarations.forEach((t=>{const o=[],{name:a,$class:d}=t;if(this.pushMapValues(o,c,a),this.pushMapValues(o,s,e.namespace),this.pushMapValues(o,s,n),this.pushMapValues(o,p,d),o.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((n=>{this.executeCommand(e.namespace,t,n.getCommand(),null,r),this.isNamespaceTargetEnabled(r?.enableDcsNamespaceTarget)&&this.executeNamespaceCommand(e,n.getCommand())})),d===`${i}.MapDeclaration`){const r=[];this.pushMapValues(r,p,t.key.$class),this.pushMapValues(r,p,t.value.$class),this.pushMapValues(r,u,"KEY"),this.pushMapValues(r,u,"VALUE"),this.pushMapValues(r,u,"KEY_VALUE"),r.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((r=>{this.executeCommand(e.namespace,t,r.getCommand())}))}t.properties&&t.properties.forEach((r=>{const n=[],{name:o,$class:s}=r;this.pushMapValues(n,l,o),this.pushMapValues(n,p,s),n.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((n=>{this.executeCommand(e.namespace,t,n.getCommand(),r)}))}))}))}));const m=!!e?.enableMapType,g=new n({strict:e.isStrict(),enableMapType:m,importAliasing:e.isAliasedTypeEnabled(),decoratorValidation:e.getDecoratorValidation()});return g.fromAst(h,{disableValidation:r?.disableMetamodelValidation}),g}static extractDecorators(e,t){t={removeDecoratorsFromModel:!1,locale:"en",enableDcsNamespaceTarget:!1,...t};const r=e.getAst(!0,!0),n=new l(t.removeDecoratorsFromModel,t.locale,g,r,l.Action.EXTRACT_ALL,{enableDcsNamespaceTarget:this.isNamespaceTargetEnabled(t.enableDcsNamespaceTarget)}).extract();return{modelManager:n.updatedModelManager,decoratorCommandSet:n.decoratorCommandSet,vocabularies:n.vocabularies}}static extractVocabularies(e,t){t={removeDecoratorsFromModel:!1,locale:"en",enableDcsNamespaceTarget:!1,...t};const r=e.getAst(!0,!0),n=new l(t.removeDecoratorsFromModel,t.locale,g,r,l.Action.EXTRACT_VOCAB,{enableDcsNamespaceTarget:this.isNamespaceTargetEnabled(t.enableDcsNamespaceTarget)}).extract();return{modelManager:n.updatedModelManager,vocabularies:n.vocabularies}}static extractNonVocabDecorators(e,t){t={removeDecoratorsFromModel:!1,locale:"en",enableDcsNamespaceTarget:!1,...t};const r=e.getAst(!0),n=new l(t.removeDecoratorsFromModel,t.locale,g,r,l.Action.EXTRACT_NON_VOCAB,{enableDcsNamespaceTarget:this.isNamespaceTargetEnabled(t.enableDcsNamespaceTarget)}).extract();return{modelManager:n.updatedModelManager,decoratorCommandSet:n.decoratorCommandSet}}static validateCommand(e,t){t.target.type&&e.resolveType("DecoratorCommand.type",t.target.type);let r=null;if(t.target.namespace&&(r=e.getModelFile(t.target.namespace),!r)){const{name:n,version:o}=a.parseNamespace(t.target.namespace);o||(r=e.getModelFiles().find((e=>function(e,t){const{name:r}=a.parseNamespace(e.getNamespace());return r===t}(e,n))))}if(t.target.namespace&&!r)throw new Error(`Decorator Command references namespace "${t.target.namespace}" which does not exist: ${JSON.stringify(t,null,2)}`);if(t.target.namespace&&t.target.declaration&&e.resolveType("DecoratorCommand.target.declaration",`${r.getNamespace()}.${t.target.declaration}`),t.target.properties&&t.target.property)throw new Error("Decorator Command references both property and properties. You must either reference a single property or a list of properites.");if(t.target.namespace&&t.target.declaration&&t.target.property&&!e.getType(`${r.getNamespace()}.${t.target.declaration}`).getProperty(t.target.property))throw new Error(`Decorator Command references property "${t.target.namespace}.${t.target.declaration}.${t.target.property}" which does not exist.`);if(t.target.namespace&&t.target.declaration&&t.target.properties){const n=e.getType(`${r.getNamespace()}.${t.target.declaration}`);t.target.properties.forEach((e=>{if(!n.getProperty(e))throw new Error(`Decorator Command references property "${t.target.namespace}.${t.target.declaration}.${e}" which does not exist.`)}))}}static applyDecoratorForMapElement(e,t,r,n,o){const s="KEY"===e?r.key:r.value;t.type?this.falsyOrEqual(t.type,s.$class)&&this.applyDecorator(s,n,o):this.applyDecorator(s,n,o)}static falsyOrEqual(e,t){return Array.isArray(e)?function(e,t){const r=new Set(e),n=new Set(t),o=new Set([...r].filter((e=>n.has(e))));return Array.from(o)}(e,t).length>0:!e||t.includes(e)}static applyDecorator(e,t,r){if("UPSERT"===t){let t=!1;if(e.decorators)for(let n=0;n<e.decorators.length;n++)e.decorators[n].name===r.name&&(e.decorators[n]=r,t=!0);t||(e.decorators?e.decorators.push(r):e.decorators=[r])}else{if("APPEND"!==t)throw new Error(`Unknown command type ${t}`);e.decorators?e.decorators.push(r):e.decorators=[r],this.checkForDuplicateDecorators(e)}}static checkForDuplicateDecorators(e){const t=new Set;e.decorators.forEach((r=>{const n=r.name;if(t.has(n))throw new d(`Duplicate decorator ${n}`,e.location);t.add(n)}))}static executeNamespaceCommand(e,t){const{target:r,decorator:n,type:o}=t;if(2===Object.keys(r).length&&r.namespace){const{name:t}=a.parseNamespace(e.namespace);this.falsyOrEqual(r.namespace,[e.namespace,t])&&this.applyDecorator(e,o,n)}}static executeCommand(e,t,r,n,o){const{target:s,decorator:c,type:l}=r,{name:u}=a.parseNamespace(e,{disableVersionParsing:!0});if(this.falsyOrEqual(s.namespace,[e,u])&&this.falsyOrEqual(s.declaration,[t.name]))if(t.$class===`${i}.MapDeclaration`)if(s.mapElement)switch(s.mapElement){case"KEY":case"VALUE":this.applyDecoratorForMapElement(s.mapElement,s,t,l,c);break;case"KEY_VALUE":this.applyDecoratorForMapElement("KEY",s,t,l,c),this.applyDecoratorForMapElement("VALUE",s,t,l,c)}else s.type?(this.falsyOrEqual(s.type,t.key.$class)&&this.applyDecorator(t.key,l,c),this.falsyOrEqual(s.type,t.value.$class)&&this.applyDecorator(t.value,l,c)):this.checkForNamespaceTargetAndApplyDecorator(t,l,c,s,o?.enableDcsNamespaceTarget);else s.property||s.properties||s.type?n&&this.executePropertyCommand(n,r):this.checkForNamespaceTargetAndApplyDecorator(t,l,c,s,o?.enableDcsNamespaceTarget)}static executePropertyCommand(e,t){const{target:r,decorator:n,type:o}=t;(r.properties||r.property||r.type)&&this.falsyOrEqual(r.property?r.property:r.properties,[e.name])&&this.falsyOrEqual(r.type,[e.$class])&&this.applyDecorator(e,o,n)}static checkForNamespaceTargetAndApplyDecorator(e,t,r,n,o){this.isNamespaceTargetEnabled(o)?n.declaration&&this.applyDecorator(e,t,r):this.applyDecorator(e,t,r)}static isNamespaceTargetEnabled(e){return!(!e&&"true"!=={NODE_ENV:"production"}.ENABLE_DCS_NAMESPACE_TARGET&&(u.printDeprecationWarning("Functionality for namespace targeted Decorator Command Sets has changed. Using namespace targets to apply decorators on all declarations in a namespace will be deprecated soon.",p.DEPRECATION_WARNING,p.CONCERTO_DEPRECATION_001,"Please refer to https://concerto.accordproject.org/deprecation/001"),1))}static jsonToYaml(e){return this.validate(e),h(e)}static yamlToJson(e){const t=m(e);return this.validate(t),t}}e.exports=b},1051:(e,t,r)=>{"use strict";const n=r(480);e.exports={getDecoratorModel:function(){return{decoratorModelFile:"concerto_decorator_1.0.0.cto",decoratorModelCto:"namespace concerto.decorator@1.0.0\n abstract concept Decorator {}\n concept DotNetNamespace extends Decorator {\n o String namespace\n }",decoratorModelAst:JSON.parse(JSON.stringify(n))}}}},1595:(e,t,r)=>{"use strict";const{TypedStack:n}=r(8487),o=r(7833)("concerto:Factory"),s=r(2438),a=r(1768),i=r(6422),c=r(7854),l=r(2552),u=r(6113),p=r(7755),d=r(289),f=r(182),h=r(3464),m=r(7657);h.extend(m),void 0===r.g&&r(9481);class g{static newId(){return f.v4()}constructor(e){this.modelManager=e}newResource(e,t,r,n){n=n||{};const i=a.getFullyQualifiedName(e,t),c=this.modelManager.getType(i);if(c.isAbstract()){let r=s.messageFormatter("factory-newinstance-abstracttype");throw new Error(r({namespace:e,type:t}))}let u=c.getIdentifierFieldName();if(c.isSystemIdentified()&&(r=null==r?g.newId():r),u){if("string"!=typeof r){let r=s.messageFormatter("factory-newinstance-invalididentifier");throw new Error(r({namespace:e,type:t}))}if(0===r.trim().length){let r=s.messageFormatter("factory-newinstance-missingidentifier");throw new Error(r({namespace:e,type:t}))}if(r){let e=c.getProperty(u);if(e?.isTypeScalar?.()&&(e=e.getScalarField()),e?.validator?.regex&&!1===e.validator?.regex.test(r))throw new Error("Provided id does not match regex: "+e?.validator?.regex)}}else if(r)throw new Error("Type is not identifiable "+c.getFullyQualifiedName());let f=null,m=null;return(c.isTransaction()||c.isEvent())&&(m=h.utc()),f=n.disableValidation?new p(this.modelManager,c,e,t,r,m):new d(this.modelManager,c,e,t,r,m,new l),f.assignFieldDefaults(),this.initializeNewObject(f,c,n),u&&(f[u]=r),o("newResource","Factory.newResource created ",r||"valid"),f}newConcept(e,t,r,n){return this.newResource(e,t,r,n)}newRelationship(e,t,r){const n=a.getFullyQualifiedName(e,t),o=this.modelManager.getType(n);if(!o.isIdentified())throw new Error(`Cannot create a relationship to ${n}, it is not identifiable.`);return new u(this.modelManager,o,e,t,r)}newTransaction(e,t,r,n){if(!e)throw new Error("ns not specified");if(!t)throw new Error("type not specified");let o=this.newResource(e,t,r,n);if(!o.getClassDeclaration().isTransaction())throw new Error(o.getClassDeclaration().getFullyQualifiedName()+" is not a transaction");return o}newEvent(e,t,r,n){if(!e)throw new Error("ns not specified");if(!t)throw new Error("type not specified");let o=this.newResource(e,t,r,n);if(!o.getClassDeclaration().isEvent())throw new Error(o.getClassDeclaration().getFullyQualifiedName()+" is not an event");return o}initializeNewObject(e,t,r){const o=this.parseGenerateOptions(r);if(o){o.stack=new n(e),o.seen=[e.getFullyQualifiedType()];const r=new i;t.accept(r,o)}}parseGenerateOptions(e){if(!e.generate)return null;const t={};return t.modelManager=this.modelManager,t.factory=this,/^empty$/i.test(e.generate)?t.valueGenerator=c.empty():t.valueGenerator=c.sample(),t.includeOptionalFields=!!e.includeOptionalFields,t}}e.exports=g},2438:(e,t,r)=>{"use strict";const n=r(8168);function o(e){return function(t){let r=n.en[e];for(let e in t)r=r.replace(new RegExp(`\\{${e}\\}`,"g"),t[e]);return r}}function s(e){return n.en[e]}function a(e){return{messageFormatter:o,formatMessage:s}}a.messageFormatter=o,a.formatMessage=s,e.exports=a},953:(e,t,r)=>{"use strict";const n=r(8058);void 0===r.g&&r(6226),e.exports=class extends n{constructor(e,t){super(e,t)}declarationKind(){return"AssetDeclaration"}}},9869:(e,t,r)=>{"use strict";const{MetaModelNamespace:n}=r(3348),o=r(