( model: IModelService, feature: QueryFeature, key: string | null = null, )
| 127 | }; |
| 128 | |
| 129 | export const isQueryFeatureEnabled = ( |
| 130 | model: IModelService, |
| 131 | feature: QueryFeature, |
| 132 | key: string | null = null, |
| 133 | ): boolean => { |
| 134 | const rules = model.queryLimits.filter( |
| 135 | (limit) => limit.feature === feature && limit.key === null, |
| 136 | ); |
| 137 | |
| 138 | if (key) { |
| 139 | const keyRules = model.queryLimits.filter( |
| 140 | (limit) => limit.feature === feature && limit.key === key, |
| 141 | ); |
| 142 | |
| 143 | if (keyRules.length > 0) { |
| 144 | const lastKeyRule = keyRules[keyRules.length - 1]; |
| 145 | if (lastKeyRule?.type === QueryFeatureType.Deny) { |
| 146 | return false; |
| 147 | } |
| 148 | |
| 149 | return true; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (rules.length === 0) { |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | const lastRule = rules[rules.length - 1]; |
| 158 | if (lastRule?.type === QueryFeatureType.Deny) { |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | return true; |
| 163 | }; |
| 164 | |
| 165 | export const valideteQueryFeature = ( |
| 166 | model: IModelService, |
no outgoing calls
no test coverage detected