diff --git a/.gitignore b/.gitignore index 67477cf..4529c79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ - .DS_Store node_modules/* .tmuxp.* -dist/* +lib/* diff --git a/lib/@types/data/activeDataSchema.js b/lib/@types/data/activeDataSchema.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/data/activeDataSchema.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/data/dataInterface.js b/lib/@types/data/dataInterface.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/data/dataInterface.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/data/tables.js b/lib/@types/data/tables.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/data/tables.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/frameworkConfig.js b/lib/@types/frameworkConfig.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/frameworkConfig.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/models/model.js b/lib/@types/models/model.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/models/model.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/validation/schema.js b/lib/@types/validation/schema.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/validation/schema.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/@types/validation/validator.js b/lib/@types/validation/validator.js deleted file mode 100644 index c8ad2e5..0000000 --- a/lib/@types/validation/validator.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/data/activeDataInterface.js b/lib/data/activeDataInterface.js deleted file mode 100644 index b5e464d..0000000 --- a/lib/data/activeDataInterface.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setActiveRow = exports.getActiveRow = exports.getActiveTable = void 0; -const frameworkConfig_1 = __importDefault(require("../frameworkConfig")); -const idMismatchError_1 = __importDefault(require("../errors/idMismatchError")); -const keysDoNotMatchError_1 = __importDefault(require("../errors/keysDoNotMatchError")); -const unexpectedDataTypeError_1 = __importDefault(require("../errors/unexpectedDataTypeError")); -const dataInterface_1 = require("./dataInterface"); -const ACTIVE_DATA_SCHEMA_PATH = frameworkConfig_1.default.activeDataSchemaPath; -const activeDataSchema = (_a = require.main) === null || _a === void 0 ? void 0 : _a.require(`./${ACTIVE_DATA_SCHEMA_PATH}`).default; -const getActiveTables = (req) => { - return req === null || req === void 0 ? void 0 : req.session.data.tables; -}; -const getActiveTable = (req, tableName, conditions) => { - return (0, dataInterface_1.getTable)(getActiveTables, { req: req, tableName: tableName, conditions: conditions }); -}; -exports.getActiveTable = getActiveTable; -const getActiveRow = (req, tableName, id) => { - return (0, dataInterface_1.getRow)(getActiveTables, { req: req, tableName: tableName, id: id }); -}; -exports.getActiveRow = getActiveRow; -const validateSentData = (req, tableName, id, sentData) => { - const rowScheme = activeDataSchema[tableName]; - const rowKeys = Object.keys(rowScheme).sort(); - const sentRowKeys = Object.keys(sentData).sort(); - if (!(rowKeys.length === sentRowKeys.length && rowKeys.every((key, index) => key === sentRowKeys[index]))) { - throw new keysDoNotMatchError_1.default(); - } - rowKeys.forEach((key) => { - if (sentData[key] !== undefined && rowScheme[key] !== typeof (sentData[key])) - throw new unexpectedDataTypeError_1.default(key, tableName, rowScheme[key], typeof (sentData[key])); - }); - if (getActiveRow(req, tableName, id).id !== sentData.id) - throw new idMismatchError_1.default(); -}; -const setActiveRow = (req, tableName, id, data) => { - validateSentData(req, tableName, id, data); - const tables = getActiveTables(req); - const index = tables[tableName].map(row => row.id).indexOf(id); - tables[tableName][index] = data; -}; -exports.setActiveRow = setActiveRow; diff --git a/lib/data/dataInterface.js b/lib/data/dataInterface.js deleted file mode 100644 index ed5d2e3..0000000 --- a/lib/data/dataInterface.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getRow = exports.getTable = void 0; -const rowNotFoundError_1 = __importDefault(require("../errors/rowNotFoundError")); -const tableNotFoundError_1 = __importDefault(require("../errors/tableNotFoundError")); -const getTable = (getTables, options) => { - let table = getTables(options.req)[options.tableName]; - if (table === undefined) - throw new tableNotFoundError_1.default(options.tableName); - if (options.conditions !== undefined) { - options.conditions.forEach(condition => { - table = table.filter(row => row[condition.attribute] === condition.value); - }); - } - return table; -}; -exports.getTable = getTable; -const getRow = (getTables, options) => { - const table = getTable(getTables, options); - const row = table.find(row => row.id === options.id); - if (row === undefined) - throw new rowNotFoundError_1.default(options.tableName, options.id); - return row; -}; -exports.getRow = getRow; diff --git a/lib/data/staticDataInterface.js b/lib/data/staticDataInterface.js deleted file mode 100644 index f886399..0000000 --- a/lib/data/staticDataInterface.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getStaticRow = exports.getStaticTable = void 0; -const frameworkConfig_1 = __importDefault(require("../frameworkConfig")); -const dataInterface_1 = require("./dataInterface"); -const STATIC_DATA_PATH = frameworkConfig_1.default.staticDataPath; -const staticData = (_a = require.main) === null || _a === void 0 ? void 0 : _a.require(`./${STATIC_DATA_PATH}`).default; -const getStaticTables = () => { - return staticData; -}; -const getStaticTable = (tableName, conditions) => { - return (0, dataInterface_1.getTable)(getStaticTables, { tableName: tableName, conditions: conditions }); -}; -exports.getStaticTable = getStaticTable; -const getStaticRow = (tableName, id) => { - return (0, dataInterface_1.getRow)(getStaticTables, { tableName: tableName, id: id }); -}; -exports.getStaticRow = getStaticRow; diff --git a/lib/errors/idMismatchError.js b/lib/errors/idMismatchError.js deleted file mode 100644 index 500bbe3..0000000 --- a/lib/errors/idMismatchError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class IDMismatchError extends Error { - constructor() { - super('The ID in the url and the request data do not match'); - this.name = 'IDMismatchError'; - } -} -exports.default = IDMismatchError; diff --git a/lib/errors/keysDoNotMatchError.js b/lib/errors/keysDoNotMatchError.js deleted file mode 100644 index 3f48c89..0000000 --- a/lib/errors/keysDoNotMatchError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class KeysDoNotMatchError extends Error { - constructor() { - super('The keys in the submitted data do not match the keys in the table'); - this.name = 'KeysDoNotMatchError'; - } -} -exports.default = KeysDoNotMatchError; diff --git a/lib/errors/rowNotFoundError.js b/lib/errors/rowNotFoundError.js deleted file mode 100644 index 4ecda62..0000000 --- a/lib/errors/rowNotFoundError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class RowNotFoundError extends Error { - constructor(tableName, id) { - super(`A row with ID ${id} for the table ${tableName} could not be found`); - this.name = 'RowNotFoundError'; - } -} -exports.default = RowNotFoundError; diff --git a/lib/errors/tableNotFoundError.js b/lib/errors/tableNotFoundError.js deleted file mode 100644 index 578757c..0000000 --- a/lib/errors/tableNotFoundError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class TableNotFoundError extends Error { - constructor(tableName) { - super(`A table with name ${tableName} could not be found`); - this.name = 'TableNotFoundError'; - } -} -exports.default = TableNotFoundError; diff --git a/lib/errors/unexpectedDataTypeError.js b/lib/errors/unexpectedDataTypeError.js deleted file mode 100644 index 7b6ff86..0000000 --- a/lib/errors/unexpectedDataTypeError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class UnexpectedDataTypeError extends Error { - constructor(key, table, expectedType, receivedType) { - super(`There was an unexpected data type for ${key} in ${table}. Expectd type: ${expectedType}. Recieved type: ${receivedType}`); - this.name = 'UnexpectedDataTypeError'; - } -} -exports.default = UnexpectedDataTypeError; diff --git a/lib/frameworkConfig.js b/lib/frameworkConfig.js deleted file mode 100644 index e81988d..0000000 --- a/lib/frameworkConfig.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -const frameworkConfig = (_a = require.main) === null || _a === void 0 ? void 0 : _a.require('./frameworkConfig.json'); -exports.default = frameworkConfig; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ee9b6eb..0000000 --- a/lib/index.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Export the functions from the data interfaces -__exportStar(require("./data/activeDataInterface"), exports); -__exportStar(require("./data/staticDataInterface"), exports); -// Export the model classes -__exportStar(require("./models/active/activeModel"), exports); -__exportStar(require("./models/static/staticModel"), exports); -// Export the validations -__exportStar(require("./validation/validators/staticModelValidator"), exports); -__exportStar(require("./validation/validators/customValidator"), exports); -__exportStar(require("./validation/validators/inputValidators/inclusionValidator"), exports); -__exportStar(require("./validation/validators/inputValidators/numberValidator"), exports); -__exportStar(require("./validation/validators/inputValidators/stringValidator"), exports); diff --git a/lib/models/active/activeModel.js b/lib/models/active/activeModel.js deleted file mode 100644 index 9a3efeb..0000000 --- a/lib/models/active/activeModel.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const cast_1 = __importDefault(require("../../utils/cast")); -const model_1 = __importDefault(require("../model")); -const staticModel_1 = __importDefault(require("../static/staticModel")); -const staticModelValidator_1 = __importDefault(require("../../validation/validators/staticModelValidator")); -const activeDataInterface_1 = require("../../data/activeDataInterface"); -class ActiveModel extends model_1.default { - constructor(data, schema = {}) { - super(data); - this.errors = {}; - this.validate = (call) => { - this.errors = {}; - if (this.schema.inputValidations !== undefined) { - this.schema.inputValidations.forEach(inputValidation => { - const attributeValidation = new inputValidation.validator(this.data[inputValidation.attribute], inputValidation.options); - this.validateAttribute(call, inputValidation, attributeValidation); - }); - } - if (this.schema.customValidations !== undefined) { - this.schema.customValidations.forEach(customValidation => { - const attributeValidation = new customValidation.validator(this, customValidation.options); - this.validateAttribute(call, customValidation, attributeValidation); - }); - } - if (this.schema.staticModelValidations !== undefined) { - this.schema.staticModelValidations.forEach(staticModelValidation => { - const attributeValidation = new staticModelValidator_1.default(this.data[staticModelValidation.attribute], staticModelValidation.options); - this.validateAttribute(call, staticModelValidation, attributeValidation); - }); - } - Object.keys(this.data) - .filter((attribute) => this.data[attribute] instanceof ActiveModel) - .forEach((attribute) => { - const model = this.data[attribute]; - if (!model.validate(call)) { - this.errors = { ...this.errors, ...model.errors }; - } - }); - return Object.keys(this.errors).length === 0; - }; - this.validateAttribute = (call, validation, attributeValidation) => { - if (!attributeValidation.valid(call)) { - this.errors[validation.attribute] = { - error: attributeValidation.error, - errorMessage: validation.errorMessages[attributeValidation.error] - }; - } - }; - this.errorList = () => { - return Object.entries(this.errors).map(([attribute, error]) => { - return { - text: error.errorMessage, - href: `#${attribute}-error` - }; - }); - }; - this.attributes = () => { - return Object.fromEntries(Object.keys(this.data).map((attribute) => { - if (this.data[attribute] instanceof model_1.default) { - return [`${attribute}ID`, this.data[attribute].data.id]; - } - else { - return [attribute, this.data[attribute]]; - } - })); - }; - this.assignAttributes = (data) => { - for (const attribute in this.data) { - if (attribute in data) { - if (this.data[attribute] instanceof ActiveModel) { - this.data[attribute].assignAttributes(data[attribute]); - } - else if (this.data[attribute] instanceof staticModel_1.default) { - const id = (0, cast_1.default)(data[attribute], 'number'); - if (this.data[attribute].data.id !== id) { - this.data[attribute] = new this.data[attribute].constructor(id); - } - } - else { - this.data[attribute] = (0, cast_1.default)(data[attribute], typeof this.data[attribute]); - } - } - } - }; - this.save = (req) => { - const activeModelAttributes = Object.keys(this.data).filter((attribute) => this.data[attribute] instanceof ActiveModel); - activeModelAttributes.forEach(activeModelAttribute => this.data[activeModelAttribute].save(req)); - (0, activeDataInterface_1.setActiveRow)(req, this.tableName, this.data.id, this.attributes()); - }; - this.schema = schema; - } -} -ActiveModel._find = (req, tableName, id) => { - return (0, activeDataInterface_1.getActiveRow)(req, tableName, id); -}; -ActiveModel._all = (req, tableName) => { - return (0, activeDataInterface_1.getActiveTable)(req, tableName); -}; -ActiveModel._where = (req, tableName, conditions) => { - return (0, activeDataInterface_1.getActiveTable)(req, tableName, conditions); -}; -exports.default = ActiveModel; diff --git a/lib/models/model.js b/lib/models/model.js deleted file mode 100644 index bdc43b1..0000000 --- a/lib/models/model.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class Model { - constructor(data) { - this.data = data; - } -} -exports.default = Model; diff --git a/lib/models/static/staticModel.js b/lib/models/static/staticModel.js deleted file mode 100644 index d2f6a10..0000000 --- a/lib/models/static/staticModel.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const model_1 = __importDefault(require("../model")); -const staticDataInterface_1 = require("../../data/staticDataInterface"); -class StaticModel extends model_1.default { -} -StaticModel._find = (tableName, id) => { - return (0, staticDataInterface_1.getStaticRow)(tableName, id); -}; -StaticModel._all = (tableName) => { - return (0, staticDataInterface_1.getStaticTable)(tableName); -}; -StaticModel._where = (tableName, conditions) => { - return (0, staticDataInterface_1.getStaticTable)(tableName, conditions); -}; -exports.default = StaticModel; diff --git a/lib/utils/cast.js b/lib/utils/cast.js deleted file mode 100644 index a547ab7..0000000 --- a/lib/utils/cast.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const cast = (input, targetType) => { - switch (targetType) { - case 'number': - if (input.length > 0) { - return Number(input); - } - else { - return undefined; - } - case 'boolean': - return String(input) === 'true'; - case 'string': - return String(input); - } -}; -exports.default = cast; diff --git a/lib/validation/validator.js b/lib/validation/validator.js deleted file mode 100644 index 1df8aa1..0000000 --- a/lib/validation/validator.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class Validator { - constructor(options = {}) { - this.error = ''; - this.valid = (call) => { - if (!this.condition) - return true; - if (this.options.on !== undefined && !this.options.on.includes(call)) - return true; - return this._validate(); - }; - this.options = options; - this.condition = options.condition === undefined ? true : options.condition; - } -} -exports.default = Validator; diff --git a/lib/validation/validators/customValidator.js b/lib/validation/validators/customValidator.js deleted file mode 100644 index 13d0265..0000000 --- a/lib/validation/validators/customValidator.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const validator_1 = __importDefault(require("../validator")); -class CustomValidator extends validator_1.default { - constructor(model, options = {}) { - super(options); - this.model = model; - } -} -exports.default = CustomValidator; diff --git a/lib/validation/validators/inputValidator.js b/lib/validation/validators/inputValidator.js deleted file mode 100644 index 029e166..0000000 --- a/lib/validation/validators/inputValidator.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const validator_1 = __importDefault(require("../validator")); -class InputValidator extends validator_1.default { - constructor(input, options = {}) { - super(options); - this.input = input; - } -} -exports.default = InputValidator; diff --git a/lib/validation/validators/inputValidators/inclusionValidator.js b/lib/validation/validators/inputValidators/inclusionValidator.js deleted file mode 100644 index ef35a1b..0000000 --- a/lib/validation/validators/inputValidators/inclusionValidator.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const inputValidator_1 = __importDefault(require("../inputValidator")); -class InclusionValidator extends inputValidator_1.default { - constructor(input, options) { - super(input, options); - this.options = this.options; - this._validate = () => { - if (!this.options.in.includes(this.input)) { - this.error = 'invalid'; - return false; - } - return true; - }; - } -} -exports.default = InclusionValidator; diff --git a/lib/validation/validators/inputValidators/numberValidator.js b/lib/validation/validators/inputValidators/numberValidator.js deleted file mode 100644 index b42c6f5..0000000 --- a/lib/validation/validators/inputValidators/numberValidator.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const inputValidator_1 = __importDefault(require("../inputValidator")); -class NumberValidator extends inputValidator_1.default { - constructor(input, options) { - super(input, options); - this.options = this.options; - this._validate = () => { - if (isNaN(this.input)) { - this.error = 'notANumber'; - return false; - } - if (this.options.onlyInteger && !Number.isInteger(this.input)) { - this.error = 'notAnInteger'; - return false; - } - if (this.options.greaterThan !== undefined && this.input < this.options.greaterThan) { - this.error = 'greaterThan'; - return false; - } - if (this.options.lessThan !== undefined && this.input > this.options.lessThan) { - this.error = 'lessThan'; - return false; - } - return true; - }; - } -} -exports.default = NumberValidator; diff --git a/lib/validation/validators/inputValidators/stringValidator.js b/lib/validation/validators/inputValidators/stringValidator.js deleted file mode 100644 index 9de08bd..0000000 --- a/lib/validation/validators/inputValidators/stringValidator.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const inputValidator_1 = __importDefault(require("../inputValidator")); -class StringValidator extends inputValidator_1.default { - constructor(input, options) { - super(input, options); - this.options = this.options; - this._validate = () => { - if (this.options.required) { - if (this.input === undefined || this.input.length === 0 || this.input.replace(/\s/g, '').length === 0) { - this.error = 'required'; - return false; - } - } - if (this.input !== undefined) { - if (this.input.length > this.options.maxLength) { - this.error = 'tooLong'; - return false; - } - if (this.options.pattern) { - const regex = new RegExp(this.options.pattern); - if (!regex.test(this.input)) { - this.error = 'invalid'; - return false; - } - } - } - return true; - }; - } -} -exports.default = StringValidator; diff --git a/lib/validation/validators/staticModelValidator.js b/lib/validation/validators/staticModelValidator.js deleted file mode 100644 index 96195bf..0000000 --- a/lib/validation/validators/staticModelValidator.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const validator_1 = __importDefault(require("../validator")); -class StaticModelValidator extends validator_1.default { - constructor(model, options = {}) { - super(options); - this._validate = () => { - if (this.model.data === undefined) { - this.error = 'required'; - return false; - } - return true; - }; - this.model = model; - } -} -exports.default = StaticModelValidator; diff --git a/package.json b/package.json index 09c57e1..95ec4ce 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ccs-prototype-kit-model-interface", "version": "0.0.1", "description": "An interface for the ccs-prototype-kit to allow for the use of a sudo database and models", - "main": "lib/index.js", + "main": "src/index", "types": "", "scripts": { "build": "rm -rf ./lib/ && tsc", @@ -10,7 +10,7 @@ }, "keywords": [], "author": "", - "license": "ISC", + "license": "MIT", "devDependencies": { "@types/express": "^4.17.13", "@types/express-session": "^1.17.4", diff --git a/src/index.ts b/src/index.ts index 5d2d80a..829df1d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,10 @@ -// Export the functions from the data interfaces -export * from './data/activeDataInterface' -export * from './data/staticDataInterface' - // Export the model classes -export * from './models/active/activeModel' -export * from './models/static/staticModel' +export { default as ActiveModel } from './models/active/activeModel' +export { default as StaticModel } from './models/static/staticModel' // Export the validations -export * from './validation/validators/staticModelValidator' -export * from './validation/validators/customValidator' -export * from './validation/validators/inputValidators/inclusionValidator' -export * from './validation/validators/inputValidators/numberValidator' -export * from './validation/validators/inputValidators/stringValidator' \ No newline at end of file +export { default as StaticModelValidator } from './validation/validators/staticModelValidator' +export { default as CustomValidator } from './validation/validators/customValidator' +export { default as InclusionValidator } from './validation/validators/inputValidators/inclusionValidator' +export { default as NumberValidator } from './validation/validators/inputValidators/numberValidator' +export { default as StringValidator } from './validation/validators/inputValidators/stringValidator' \ No newline at end of file