MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / isOperationIncluded

Function isOperationIncluded

packages/server/src/api/common/spec-utils.ts:27–42  ·  view source on GitHub ↗
(modelName: string, op: string, queryOptions?: QueryOptions<any>)

Source from the content-addressed store, hash-verified

25 * Checks if a CRUD operation is included for a model based on slicing options.
26 */
27export 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.

Callers 5

generatePathsMethod · 0.90
buildCollectionPathMethod · 0.90
buildSinglePathMethod · 0.90
buildRelatedPathMethod · 0.90
buildNestedSinglePathMethod · 0.90

Calls 1

lowerCaseFirstFunction · 0.90

Tested by

no test coverage detected