@martinmilo/verve
Version:
TypeScript domain modeling library with field-level authorization, business rule validation, and context-aware access control
24 lines • 899 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WithContext = WithContext;
const Context_1 = require("./Context");
const constants_1 = require("../../constants");
function WithContext(Base) {
return class WithContextMixin extends Base {
static withContext(context) {
const Subclass = class extends this {
};
Subclass[constants_1.MODEL_CONTEXT] = context;
return Subclass;
}
withContext(context) {
this[constants_1.MODEL_CONTEXT] = context;
return this;
}
getContext() {
var _a, _b;
return (_b = (_a = this[constants_1.MODEL_CONTEXT]) !== null && _a !== void 0 ? _a : this.constructor[constants_1.MODEL_CONTEXT]) !== null && _b !== void 0 ? _b : Context_1.Context.get();
}
};
}
//# sourceMappingURL=mixin.js.map