Skip to content

Function: matchesSubscription()

Makaio Framework


Makaio Framework / bus-core / matchesSubscription

matchesSubscription(subject, pattern): boolean

Defined in: ../../../packages/bus-core/src/utils/subscription-matching.ts:78

Check if a subject matches a subscription pattern.

Patterns can be:

  • Exact match: ‘adapter:claudeCode.log’ matches only ‘adapter:claudeCode.log’
  • Subject wildcard: ‘adapter:claudeCode.*’ matches ‘adapter:claudeCode.log’, ‘adapter:claudeCode.initialized’
  • Namespace wildcard: ‘adapter:*’ matches subjects from child namespaces

string

Subject to match (e.g., ‘adapter:claudeCode:sdk.thinking’)

string

Subscription pattern (e.g., ‘adapter:’, ‘adapter:claudeCode.’, ‘adapter:claudeCode.log’)

boolean

true if subject matches pattern

// Exact match
matchesSubscription('adapter.log', 'adapter.log')
// → true
// Subject wildcard - matches subjects in namespace
matchesSubscription('adapter.log', 'adapter.*')
// → true
matchesSubscription('adapter.initialized', 'adapter.*')
// → true
matchesSubscription('adapter:claudeCode.log', 'adapter.*')
// → false (different namespace - adapter:claudeCode vs adapter)
// Namespace wildcard - matches child namespaces
matchesSubscription('adapter:claudeCode.initialized', 'adapter:*')
// → true (claudeCode is child of adapter)
matchesSubscription('adapter:claudeCode:sdk.thinking', 'adapter:*')
// → true (sdk is descendant of adapter)
matchesSubscription('adapter:gpt.initialized', 'adapter:*')
// → true (gpt is child of adapter)
// Multi-level namespace wildcard
matchesSubscription('adapter:claudeCode:sdk.thinking', 'adapter:claudeCode:*')
// → true (sdk is child of adapter:claudeCode)
matchesSubscription('adapter:gpt.initialized', 'adapter:claudeCode:*')
// → false (different branch)