UNPKG

@wbg-mde/repository

Version:

Managing all common method for file system CRUD operations.

52 lines (51 loc) 2.9 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); const fileRepository_1 = require("../repository/fileRepository"); const app_repo_constants_1 = require("../shared/app.repo.constants"); const app_repo_utility_1 = require("../shared/app.repo.utility"); const project_configuration_1 = require("../configuration/project.configuration"); const path = require("path"); const trace_decorator_1 = require("../decorators/trace.decorator"); let Schema = class Schema extends fileRepository_1.FileRepository { readSchema(schemaName, callback) { let types = app_repo_utility_1.App_Repository_Utility.getTypes(); if (types.filter(function (val) { return val.schema == schemaName; }).length > 0) { this.basePath = project_configuration_1.configuaration.masterDataPath; this.find(app_repo_constants_1.App_Repository_Constants.masterDataPaths.schema_path, schemaName, (response) => { callback(response); }); } else { this.basePath = path.join(project_configuration_1.configuaration.userDataPath, app_repo_constants_1.App_Repository_Constants.userDataPaths.cur_user); this.find(app_repo_constants_1.App_Repository_Constants.userDataPaths.schema_path, schemaName, (response) => { callback(response); }); } } writeSchema(schemaName, schema, callback) { this.basePath = path.join(project_configuration_1.configuaration.userDataPath, app_repo_constants_1.App_Repository_Constants.userDataPaths.cur_user); this.create(app_repo_constants_1.App_Repository_Constants.userDataPaths.schema_path, schemaName, schema, (response) => { callback(response); }); } removeSchema(schemaName, callback) { this.basePath = path.join(project_configuration_1.configuaration.userDataPath, app_repo_constants_1.App_Repository_Constants.userDataPaths.cur_user); this.delete(app_repo_constants_1.App_Repository_Constants.userDataPaths.schema_path, schemaName, (response) => { callback(response); }); } }; Schema = __decorate([ trace_decorator_1.Trace({ params: { writeSchema: [1] } }) ], Schema); exports.Schema = Schema;