diff --git a/lib/types/data/activeDataSchema.js b/lib/@types/data/activeDataSchema.js similarity index 100% rename from lib/types/data/activeDataSchema.js rename to lib/@types/data/activeDataSchema.js diff --git a/lib/types/data/dataInterface.js b/lib/@types/data/dataInterface.js similarity index 100% rename from lib/types/data/dataInterface.js rename to lib/@types/data/dataInterface.js diff --git a/lib/types/data/tables.js b/lib/@types/data/tables.js similarity index 100% rename from lib/types/data/tables.js rename to lib/@types/data/tables.js diff --git a/lib/types/frameworkConfig.js b/lib/@types/frameworkConfig.js similarity index 100% rename from lib/types/frameworkConfig.js rename to lib/@types/frameworkConfig.js diff --git a/lib/types/models/model.js b/lib/@types/models/model.js similarity index 100% rename from lib/types/models/model.js rename to lib/@types/models/model.js diff --git a/lib/types/validation/schema.js b/lib/@types/validation/schema.js similarity index 100% rename from lib/types/validation/schema.js rename to lib/@types/validation/schema.js diff --git a/lib/types/validation/validator.js b/lib/@types/validation/validator.js similarity index 100% rename from lib/types/validation/validator.js rename to lib/@types/validation/validator.js diff --git a/lib/errors/authenticationError.js b/lib/errors/authenticationError.js deleted file mode 100644 index 9bf122d..0000000 --- a/lib/errors/authenticationError.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class AuthenticationError extends Error { - constructor() { - super('Request not authorized'); - this.name = 'AuthenticationError'; - } -} -exports.default = AuthenticationError; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..ee9b6eb --- /dev/null +++ b/lib/index.js @@ -0,0 +1,24 @@ +"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/package.json b/package.json index bb78ad0..09c57e1 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "ccs-prototype-kit-model-interface", - "version": "0.0.1a", + "version": "0.0.1", "description": "An interface for the ccs-prototype-kit to allow for the use of a sudo database and models", - "main": "", + "main": "lib/index.js", + "types": "", "scripts": { "build": "rm -rf ./lib/ && tsc", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/types/data/activeDataSchema.ts b/src/@types/data/activeDataSchema.ts similarity index 100% rename from src/types/data/activeDataSchema.ts rename to src/@types/data/activeDataSchema.ts diff --git a/src/types/data/dataInterface.ts b/src/@types/data/dataInterface.ts similarity index 100% rename from src/types/data/dataInterface.ts rename to src/@types/data/dataInterface.ts diff --git a/src/types/data/tables.ts b/src/@types/data/tables.ts similarity index 100% rename from src/types/data/tables.ts rename to src/@types/data/tables.ts diff --git a/src/@types/express-session.d.ts b/src/@types/express-session.d.ts index 4413bed..0e8c565 100644 --- a/src/@types/express-session.d.ts +++ b/src/@types/express-session.d.ts @@ -1,6 +1,6 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Session } from 'express-session' -import { Tables } from '../types/data/tables' +import { Tables } from './data/tables' declare module 'express-session' { interface Session { diff --git a/src/types/frameworkConfig.ts b/src/@types/frameworkConfig.ts similarity index 100% rename from src/types/frameworkConfig.ts rename to src/@types/frameworkConfig.ts diff --git a/src/types/models/model.ts b/src/@types/models/model.ts similarity index 100% rename from src/types/models/model.ts rename to src/@types/models/model.ts diff --git a/src/types/validation/schema.ts b/src/@types/validation/schema.ts similarity index 100% rename from src/types/validation/schema.ts rename to src/@types/validation/schema.ts diff --git a/src/types/validation/validator.ts b/src/@types/validation/validator.ts similarity index 100% rename from src/types/validation/validator.ts rename to src/@types/validation/validator.ts diff --git a/src/data/activeDataInterface.ts b/src/data/activeDataInterface.ts index 29ca164..6c2c078 100644 --- a/src/data/activeDataInterface.ts +++ b/src/data/activeDataInterface.ts @@ -2,11 +2,11 @@ import frameworkConfig from '../frameworkConfig' import IDMismatchError from '../errors/idMismatchError' import KeysDoNotMatchError from '../errors/keysDoNotMatchError' import UnexpectedDataTypeError from '../errors/unexpectedDataTypeError' -import { ActiveDataSchema, ActiveDataScheme } from '../types/data/activeDataSchema' -import { Condition, ModelData } from '../types/models/model' +import { ActiveDataSchema, ActiveDataScheme } from '../@types/data/activeDataSchema' +import { Condition, ModelData } from '../@types/models/model' import { getRow, getTable } from './dataInterface' import { Request } from 'express' -import { TableRow, Tables } from '../types/data/tables' +import { TableRow, Tables } from '../@types/data/tables' const ACTIVE_DATA_SCHEMA_PATH: string = frameworkConfig.activeDataSchemaPath diff --git a/src/data/dataInterface.ts b/src/data/dataInterface.ts index 42e1f3d..59f8e1c 100644 --- a/src/data/dataInterface.ts +++ b/src/data/dataInterface.ts @@ -1,7 +1,7 @@ import RowNotFoundError from '../errors/rowNotFoundError' import TableNotFoundError from '../errors/tableNotFoundError' -import { getRowOptions, getTableOptions, getTablesFunction } from '../types/data/dataInterface' -import { TableRow } from '../types/data/tables' +import { getRowOptions, getTableOptions, getTablesFunction } from '../@types/data/dataInterface' +import { TableRow } from '../@types/data/tables' const getTable = (getTables: getTablesFunction, options: getTableOptions): Array => { let table: Array = getTables(options.req)[options.tableName] diff --git a/src/data/staticDataInterface.ts b/src/data/staticDataInterface.ts index c4a79f7..e9473b4 100644 --- a/src/data/staticDataInterface.ts +++ b/src/data/staticDataInterface.ts @@ -1,7 +1,7 @@ import frameworkConfig from '../frameworkConfig' -import { Condition } from '../types/models/model' +import { Condition } from '../@types/models/model' import { getRow, getTable } from './dataInterface' -import { TableRow, Tables } from '../types/data/tables' +import { TableRow, Tables } from '../@types/data/tables' const STATIC_DATA_PATH: string = frameworkConfig.staticDataPath diff --git a/src/errors/authenticationError.ts b/src/errors/authenticationError.ts deleted file mode 100644 index c90681f..0000000 --- a/src/errors/authenticationError.ts +++ /dev/null @@ -1,9 +0,0 @@ -class AuthenticationError extends Error { - constructor() { - super('Request not authorized') - - this.name = 'AuthenticationError' - } -} - -export default AuthenticationError \ No newline at end of file diff --git a/src/frameworkConfig.ts b/src/frameworkConfig.ts index ffa5e59..2318689 100644 --- a/src/frameworkConfig.ts +++ b/src/frameworkConfig.ts @@ -1,4 +1,4 @@ -import FrameworkConfig from './types/frameworkConfig' +import FrameworkConfig from './@types/frameworkConfig' const frameworkConfig: FrameworkConfig = require.main?.require('./frameworkConfig.json') as FrameworkConfig diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..5d2d80a --- /dev/null +++ b/src/index.ts @@ -0,0 +1,14 @@ +// 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 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 diff --git a/src/models/active/activeModel.ts b/src/models/active/activeModel.ts index 9c57a25..28995f2 100644 --- a/src/models/active/activeModel.ts +++ b/src/models/active/activeModel.ts @@ -5,11 +5,11 @@ import Model from '../model' import StaticModel from '../static/staticModel' import StaticModelValidator from '../../validation/validators/staticModelValidator' import Validator from '../../validation/validator' -import { ActiveModelInterface, Condition, ModelData, ModelError } from '../../types/models/model' +import { ActiveModelInterface, Condition, ModelData, ModelError } from '../../@types/models/model' import { getActiveRow, getActiveTable, setActiveRow } from '../../data/activeDataInterface' import { Request } from 'express' -import { Schema, Scheme } from '../../types/validation/schema' -import { TableRow } from '../../types/data/tables' +import { Schema, Scheme } from '../../@types/validation/schema' +import { TableRow } from '../../@types/data/tables' abstract class ActiveModel extends Model implements ActiveModelInterface { abstract tableName: string diff --git a/src/models/model.ts b/src/models/model.ts index 7367d9b..e99a927 100644 --- a/src/models/model.ts +++ b/src/models/model.ts @@ -1,4 +1,4 @@ -import { ModelData, ModelInterface } from '../types/models/model' +import { ModelData, ModelInterface } from '../@types/models/model' abstract class Model implements ModelInterface { data: ModelData diff --git a/src/models/static/staticModel.ts b/src/models/static/staticModel.ts index 0e99dcf..d23cc64 100644 --- a/src/models/static/staticModel.ts +++ b/src/models/static/staticModel.ts @@ -1,5 +1,5 @@ import Model from '../model' -import { Condition, ModelData, StaticModelInterface } from '../../types/models/model' +import { Condition, ModelData, StaticModelInterface } from '../../@types/models/model' import { getStaticRow, getStaticTable } from '../../data/staticDataInterface' abstract class StaticModel extends Model implements StaticModelInterface { diff --git a/src/validation/validator.ts b/src/validation/validator.ts index 5d7fc8c..5e8a8ba 100644 --- a/src/validation/validator.ts +++ b/src/validation/validator.ts @@ -1,5 +1,5 @@ -import { ValidatorInterface } from '../types/validation/validator' -import { ValidatorOptions } from '../types/validation/validator' +import { ValidatorInterface } from '../@types/validation/validator' +import { ValidatorOptions } from '../@types/validation/validator' abstract class Validator implements ValidatorInterface { options: ValidatorOptions diff --git a/src/validation/validators/customValidator.ts b/src/validation/validators/customValidator.ts index 9641ac6..8748ff4 100644 --- a/src/validation/validators/customValidator.ts +++ b/src/validation/validators/customValidator.ts @@ -1,6 +1,6 @@ -import Validator from '../validator' -import { CustomValidatorInterface } from '../../types/validation/validator' import ActiveModel from '../../models/active/activeModel' +import Validator from '../validator' +import { CustomValidatorInterface } from '../../@types/validation/validator' abstract class CustomValidator extends Validator implements CustomValidatorInterface { model: ActiveModel diff --git a/src/validation/validators/inputValidator.ts b/src/validation/validators/inputValidator.ts index ebe934f..13bfa72 100644 --- a/src/validation/validators/inputValidator.ts +++ b/src/validation/validators/inputValidator.ts @@ -1,5 +1,5 @@ import Validator from '../validator' -import { InputValidatorInterface } from '../../types/validation/validator' +import { InputValidatorInterface } from '../../@types/validation/validator' abstract class InputValidator extends Validator implements InputValidatorInterface { input: any diff --git a/src/validation/validators/inputValidators/inclusionValidator.ts b/src/validation/validators/inputValidators/inclusionValidator.ts index 39f72b6..1b50f96 100644 --- a/src/validation/validators/inputValidators/inclusionValidator.ts +++ b/src/validation/validators/inputValidators/inclusionValidator.ts @@ -1,5 +1,5 @@ import InputValidator from '../inputValidator' -import { InclusionValidatorOptions } from '../../../types/validation/validator' +import { InclusionValidatorOptions } from '../../../@types/validation/validator' class InclusionValidator extends InputValidator { options: InclusionValidatorOptions = this.options as InclusionValidatorOptions diff --git a/src/validation/validators/inputValidators/numberValidator.ts b/src/validation/validators/inputValidators/numberValidator.ts index 7a0c5b7..9a24de3 100644 --- a/src/validation/validators/inputValidators/numberValidator.ts +++ b/src/validation/validators/inputValidators/numberValidator.ts @@ -1,5 +1,5 @@ import InputValidator from '../inputValidator' -import { NumberValidatorOptions } from '../../../types/validation/validator' +import { NumberValidatorOptions } from '../../../@types/validation/validator' class NumberValidator extends InputValidator { options: NumberValidatorOptions = this.options as NumberValidatorOptions diff --git a/src/validation/validators/inputValidators/stringValidator.ts b/src/validation/validators/inputValidators/stringValidator.ts index 203be48..928e084 100644 --- a/src/validation/validators/inputValidators/stringValidator.ts +++ b/src/validation/validators/inputValidators/stringValidator.ts @@ -1,5 +1,5 @@ import InputValidator from '../inputValidator' -import { StringValidatorOptions } from '../../../types/validation/validator' +import { StringValidatorOptions } from '../../../@types/validation/validator' class StringValidator extends InputValidator { options: StringValidatorOptions = this.options as StringValidatorOptions diff --git a/src/validation/validators/staticModelValidator.ts b/src/validation/validators/staticModelValidator.ts index 29ad59d..7d52baf 100644 --- a/src/validation/validators/staticModelValidator.ts +++ b/src/validation/validators/staticModelValidator.ts @@ -1,6 +1,6 @@ import StaticModel from '../../models/static/staticModel' import Validator from '../validator' -import { StaticModelValidatorInterface } from '../../types/validation/validator' +import { StaticModelValidatorInterface } from '../../@types/validation/validator' class StaticModelValidator extends Validator implements StaticModelValidatorInterface { model: StaticModel