(modelName: string, op: string, queryOptions?: QueryOptions<any>)
| 25 | * Checks if a CRUD operation is included for a model based on slicing options. |
| 26 | */ |
| 27 | export function isOperationIncluded(modelName: string, op: string, queryOptions?: QueryOptions<any>): boolean { |
| 28 | const slicing = queryOptions?.slicing; |
| 29 | if (!slicing?.models) return true; |
| 30 | |
| 31 | const modelKey = lowerCaseFirst(modelName); |
| 32 | const modelSlicing = (slicing.models as Record<string, any>)[modelKey] ?? (slicing.models as any).$all; |
| 33 | if (!modelSlicing) return true; |
| 34 | |
| 35 | const excluded = modelSlicing.excludedOperations as readonly string[] | undefined; |
| 36 | if (excluded?.includes(op)) return false; |
| 37 | |
| 38 | const included = modelSlicing.includedOperations as readonly string[] | undefined; |
| 39 | if (included && !included.includes(op)) return false; |
| 40 | |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Checks if a procedure is included based on slicing options. |
no test coverage detected