(ServiceClass, optionsFactory)
| 98 | } |
| 99 | |
| 100 | export function wrapServiceClassMethods(ServiceClass, optionsFactory) { |
| 101 | const methodNames = Object.getOwnPropertyNames(ServiceClass) |
| 102 | .filter((name) => name !== 'length' && name !== 'name' && name !== 'prototype') |
| 103 | .filter((name) => typeof ServiceClass[name] === 'function'); |
| 104 | |
| 105 | for (const methodName of methodNames) { |
| 106 | ServiceClass[methodName] = wrapServiceBoundary( |
| 107 | ServiceClass[methodName], |
| 108 | (...args) => { |
| 109 | const baseOptions = typeof optionsFactory === 'function' |
| 110 | ? optionsFactory(methodName, ...args) |
| 111 | : {}; |
| 112 | |
| 113 | return { |
| 114 | service: ServiceClass.name || 'ServiceClass', |
| 115 | operation: methodName, |
| 116 | ...baseOptions |
| 117 | }; |
| 118 | } |
| 119 | ); |
| 120 | } |
| 121 | |
| 122 | return ServiceClass; |
| 123 | } |
no test coverage detected