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

Function getAttributeArgLiteral

packages/language/src/utils.ts:400–410  ·  view source on GitHub ↗
(
    attr: DataModelAttribute | DataFieldAttribute | InternalAttribute,
    name: string,
)

Source from the content-addressed store, hash-verified

398 * Gets the literal value of the argument with the given name from the given attribute. Returns `undefined` if no such argument is found or if the argument value cannot be determined or is not a literal.
399 */
400export function getAttributeArgLiteral<T extends string | number | boolean>(
401 attr: DataModelAttribute | DataFieldAttribute | InternalAttribute,
402 name: string,
403): T | undefined {
404 for (const arg of attr.args) {
405 if (arg.$resolvedParam?.name === name) {
406 return getLiteral<T>(arg.value);
407 }
408 }
409 return undefined;
410}
411
412/**
413 * Gets the allowed expression contexts for the given function declaration by looking for `@@expressionContext` attribute.

Callers 1

getRelationNameFunction · 0.90

Calls 1

getLiteralFunction · 0.85

Tested by

no test coverage detected