Skip to content

Commit

Permalink
Expose some of the modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-s-ccs committed Nov 16, 2021
1 parent b1e8f3d commit 0af64ed
Show file tree
Hide file tree
Showing 34 changed files with 64 additions and 43 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions lib/errors/authenticationError.js

This file was deleted.

24 changes: 24 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/@types/express-session.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/data/activeDataInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/data/dataInterface.ts
Original file line number Diff line number Diff line change
@@ -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<TableRow> => {
let table: Array<TableRow> = getTables(options.req)[options.tableName]
Expand Down
4 changes: 2 additions & 2 deletions src/data/staticDataInterface.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 0 additions & 9 deletions src/errors/authenticationError.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/frameworkConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FrameworkConfig from './types/frameworkConfig'
import FrameworkConfig from './@types/frameworkConfig'

const frameworkConfig: FrameworkConfig = require.main?.require('./frameworkConfig.json') as FrameworkConfig

Expand Down
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 3 additions & 3 deletions src/models/active/activeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/models/model.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/models/static/staticModel.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/validation/validator.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/validation/validators/customValidator.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/validation/validators/inputValidator.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/validation/validators/staticModelValidator.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0af64ed

Please sign in to comment.