novu
Version:
Novu CLI. Run Novu Studio and sync workflows with Novu Cloud
39 lines (38 loc) • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigService = void 0;
const configstore_1 = __importDefault(require("configstore"));
const jwt_decode_1 = __importDefault(require("jwt-decode"));
class ConfigService {
constructor() {
this._config = new configstore_1.default('novu-cli');
}
setValue(key, value) {
this._config.set(key, value);
}
getValue(key) {
return this._config.get(key);
}
async clearStore() {
return this._config.clear();
}
isOrganizationIdExist() {
return !!this.getDecodedToken().organizationId;
}
isEnvironmentIdExist() {
return !!this.getDecodedToken().environmentId;
}
getToken() {
return this.getValue('token');
}
getDecodedToken() {
if (!this.getToken()) {
return null;
}
return (0, jwt_decode_1.default)(this.getToken());
}
}
exports.ConfigService = ConfigService;