Skip to content

Commit

Permalink
fix: add wildcard support for querying capabilities in the host app
Browse files Browse the repository at this point in the history
fixes: #201
  • Loading branch information
mofogasy committed Nov 8, 2019
1 parent a7d5409 commit 643b082
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Capability, Intent, Qualifier } from '@scion/workbench-application-plat
import { Defined } from './defined.util';
import { sha256 } from 'js-sha256';
import { matchesCapabilityQualifier, matchesIntentQualifier, qualifiersEqual } from './qualifier-tester';
import { patchQualifier } from './qualifier-patcher';

/**
* Registry with all registered application capabilities and intents.
Expand Down Expand Up @@ -50,9 +51,13 @@ export class ManifestRegistry {
/**
* Returns capabilities which have the given required type and qualifier.
*/
public getCapabilities<T extends Capability>(type: string, qualifier: Qualifier): T[] {
public getCapabilities<T extends Capability>(type: string, qualifier: Qualifier, options?: {wildcardQuery?: boolean}): T[] {
const wildcardQuery = Defined.orElse(options && options.wildcardQuery, false);
return this.getCapabilitiesByType(type)
.filter(capability => matchesCapabilityQualifier(capability.qualifier, qualifier)) as T[];
.filter(capability => {
const queryQualifier = wildcardQuery ? patchQualifier(qualifier, capability.qualifier) : qualifier;
return matchesCapabilityQualifier(capability.qualifier, queryQualifier);
}) as T[];
}

/**
Expand Down

0 comments on commit 643b082

Please sign in to comment.