zenstack
Version:
FullStack enhancement for Prisma ORM: seamless integration from database to UI
21 lines • 758 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDefaultWithAuth = isDefaultWithAuth;
const sdk_1 = require("@zenstackhq/sdk");
const langium_1 = require("langium");
/**
* Check if the given field attribute is a `@default` with `auth()` invocation
*/
function isDefaultWithAuth(attr) {
var _a, _b;
if (((_a = attr.decl.ref) === null || _a === void 0 ? void 0 : _a.name) !== '@default') {
return false;
}
const expr = (_b = attr.args[0]) === null || _b === void 0 ? void 0 : _b.value;
if (!expr) {
return false;
}
// find `auth()` in default value expression
return (0, langium_1.streamAst)(expr).some(sdk_1.isAuthInvocation);
}
//# sourceMappingURL=enhancer-utils.js.map
;