diff --git a/packages/oc-pages/project_overview/store/modules/environments.js b/packages/oc-pages/project_overview/store/modules/environments.js index 6fd50300..89b52fa0 100644 --- a/packages/oc-pages/project_overview/store/modules/environments.js +++ b/packages/oc-pages/project_overview/store/modules/environments.js @@ -674,7 +674,11 @@ const getters = { if(environment.instances) result = Object.values(environment.instances).filter(conn => { const connExtends = [ ...(resolver(conn.type)?.extends || []), - ...(conn.metadata?.extends || []) + ...(conn.metadata?.extends || []), + // allow types declaring deprecates to substitute for any type they deprecate + ...(resolver(conn.type)?.metadata?.deprecates || []) + .map(deprecated => resolver(deprecated)?.extends || []) + .flat() ] return connExtends?.includes(constraintType) }) diff --git a/packages/oc-pages/project_overview/store/modules/template_resources.js b/packages/oc-pages/project_overview/store/modules/template_resources.js index 4d6258d3..45626d96 100644 --- a/packages/oc-pages/project_overview/store/modules/template_resources.js +++ b/packages/oc-pages/project_overview/store/modules/template_resources.js @@ -1093,10 +1093,26 @@ const getters = { return function(requirement, all=false) { if(!requirement) return [] const types = all? state.availableResourceTypes: getters.instantiableResourceTypes - return types.filter(type => { - const isValidImplementation = type.extends?.includes(requirement.constraint?.resourceType) + const validSubclasses = types.filter(type => { + const isValidImplementation = [ + ...(type.extends || []), + // allow types declaring deprecates to substitute for any type they deprecate + ...(type.metadata.deprecates || []) + .map(deprecated => getters.resolveResourceTypeFromAny(deprecated)?.extends) + .flat() + ].includes(requirement.constraint?.resourceType) return isValidImplementation }) + + // if a type is marked as deprecated by another type among validSubclasses, filter it out + let deprecatedTypes = [] + validSubclasses.forEach(type => { + if(type.metadata.deprecates) { + deprecatedTypes = _.union(deprecatedTypes, type.metadata.deprecates) + } + }) + + return validSubclasses.filter(type => !deprecatedTypes.includes(type.name)) } }, diff --git a/packages/oc-pages/vue_shared/lib/normalize.js b/packages/oc-pages/vue_shared/lib/normalize.js index 8aeacd91..a9f4897e 100644 --- a/packages/oc-pages/vue_shared/lib/normalize.js +++ b/packages/oc-pages/vue_shared/lib/normalize.js @@ -57,10 +57,21 @@ const transforms = { resourceType.requirements = [] } - if(resourceType.metadata?.alias) { + if(!resourceType.metadata) { + resourceType.metadata = {} + } + + if(resourceType.metadata.alias) { resourceType.implementations = [] } + if(resourceType.metadata.deprecates) { + const deprecates = resourceType.metadata.deprecates + if(!Array.isArray(deprecates)) { + resourceType.metadata.deprecates = [deprecates] + } + } + normalizeDirectives(resourceType.directives) const utilization = resourceType.directives?.includes('substitute')? 0: 1