poyka
Version:
A framework for interactively creating, extending and maintaining web application as never easier before while doing it in elegant design patterns.
52 lines • 2.74 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DB = exports.InstructionType = exports.StepType = void 0;
const decova_filesystem_1 = require("decova-filesystem");
const decova_json_1 = require("decova-json");
const path_1 = __importDefault(require("path"));
const uri = "mongodb+srv://aipianist:poykaIsGreat@cluster0.bdjm4.mongodb.net/GMate?retryWrites=true&w=majority";
var StepType;
(function (StepType) {
StepType["Command"] = "Command";
StepType["Prompt"] = "Prompt";
StepType["Instruction"] = "Instruction";
})(StepType = exports.StepType || (exports.StepType = {}));
var InstructionType;
(function (InstructionType) {
InstructionType[InstructionType["Command"] = 0] = "Command";
InstructionType[InstructionType["Instruction"] = 1] = "Instruction";
InstructionType[InstructionType["Prompt"] = 2] = "Prompt";
})(InstructionType = exports.InstructionType || (exports.InstructionType = {}));
class DB {
static get LocalCacheFile() {
return new decova_filesystem_1.FileInfo(path_1.default.join(__dirname, 'gmate-commands-sheet.json'));
}
static get IsCached() {
return this.LocalCacheFile.Exists();
}
static GetSheetAsync(forceRedownload) {
return __awaiter(this, void 0, void 0, function* () {
if (DB.IsCached == false || forceRedownload) {
const sheetUrl = `https://raw.githubusercontent.com/georgemesseha/gmate/master/src/gmate-commands-sheet.json`;
yield decova_filesystem_1.FileInfo.DownloadAsync(sheetUrl, this.LocalCacheFile.FullName);
}
const sheetContent = this.LocalCacheFile.ReadAllText(decova_filesystem_1.Encoding.utf8);
let sheet = decova_json_1.Json.Parse(sheetContent);
return sheet;
});
}
}
exports.DB = DB;
//# sourceMappingURL=DB.js.map