fix basemodel import

This commit is contained in:
Simon Larsen 2022-08-03 20:13:50 +01:00
parent 5b0868514c
commit 0e588118c9
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
41 changed files with 374 additions and 166 deletions

View File

@ -4,11 +4,12 @@ import BadDataException from './Exception/BadDataException';
import { JSONObject } from './JSON';
import ObjectID from './ObjectID';
export interface PermissionProps {
permission: Permission;
description: string;
isAssignableToProject: boolean;
title: string;
title: string;
}
enum Permission {
@ -69,6 +70,7 @@ enum Permission {
CanDeleteProjectResources = 'CanDeleteProjectResources',
CanReadProjectResources = 'CanReadProjectResources',
// Project SMTP Config (Team Permission)
CanCreateProjectSMTPConfig = 'CanCreateProjectSMTPConfig',
CanEditProjectSMTPConfig = 'CanEditProjectSMTPConfig',
@ -77,6 +79,7 @@ enum Permission {
}
export class PermissionHelper {
public static doesPermissionsIntersect(
permissions1: Array<Permission>,
permissions2: Array<Permission>
@ -91,315 +94,278 @@ export class PermissionHelper {
public static getProjectPermissionProps(): Array<PermissionProps> {
return this.getAllPermissionProps().filter((item: PermissionProps) => {
return item.isAssignableToProject;
});
})
}
public static getDescription(permission: Permission): string {
const permissionProps: Array<PermissionProps> =
this.getAllPermissionProps().filter((item: PermissionProps) => {
return item.permission === permission;
});
const permissionProps: Array<PermissionProps> = this.getAllPermissionProps().filter((item: PermissionProps) => {
return item.permission === permission
});
if (!permissionProps[0]) {
throw new BadDataException(
`${permission} does not have permission props`
);
throw new BadDataException(`${permission} does not have permission props`);
}
return permissionProps[0].description;
}
public static getTitle(permission: Permission): string {
const permissionProps: Array<PermissionProps> =
this.getAllPermissionProps().filter((item: PermissionProps) => {
return item.permission === permission;
});
const permissionProps: Array<PermissionProps> = this.getAllPermissionProps().filter((item: PermissionProps) => {
return item.permission === permission
});
if (!permissionProps[0]) {
throw new BadDataException(
`${permission} does not have permission props`
);
throw new BadDataException(`${permission} does not have permission props`);
}
return permissionProps[0].title;
}
public static getAllPermissionProps(): Array<PermissionProps> {
const permissions: Array<PermissionProps> = [
{
permission: Permission.ProjectOwner,
title: 'Project Owner',
description:
'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: true,
description: 'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: true
},
{
permission: Permission.ProjectMember,
title: 'Project Member',
description:
'Member of this project. Can view most resources unless restricted.',
isAssignableToProject: true,
description: 'Member of this project. Can view most resources unless restricted.',
isAssignableToProject: true
},
{
permission: Permission.ProjectAdmin,
title: 'Project Admin',
description:
'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: true,
description: 'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: true
},
{
permission: Permission.CurrentUser,
title: 'Current User',
description:
'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: false,
description: 'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: false
},
{
permission: Permission.CustomerSupport,
title: 'Customer Support',
description: 'Customer Support Resource of OneUptime.',
isAssignableToProject: false,
isAssignableToProject: false
},
{
permission: Permission.User,
title: 'User',
description:
'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: false,
description: 'Owner of this project, manages billing, inviting other admins to this project, and can delete this project.',
isAssignableToProject: false
},
{
permission: Permission.Public,
title: 'Public',
description:
'Non registered user. Typically used for sign up or log in.',
isAssignableToProject: false,
description: 'Non registered user. Typically used for sign up or log in.',
isAssignableToProject: false
},
{
permission: Permission.CanDeleteProject,
title: 'Can Delete Project',
description:
'A user assigned this permission can delete this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete this project.',
isAssignableToProject: true
},
{
permission: Permission.CanUpdateProject,
title: 'Can Update Project',
description:
'A user assigned this permission can update this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can update this project.',
isAssignableToProject: true
},
{
permission: Permission.CanManageProjectBilling,
title: 'Can Manage Billing',
description:
'A user assigned this permission can update project billing.',
isAssignableToProject: true,
description: 'A user assigned this permission can update project billing.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectApiKey,
title: 'Can Create API Key',
description:
'A user assigned this permission can create api keys of this project',
isAssignableToProject: true,
description: 'A user assigned this permission can create api keys of this project',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectApiKey,
title: 'Can Delete API Key',
description:
'A user assigned this permission can delete api keys of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete api keys of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectApiKeyPermissions,
title: 'Can Edit API Key Permissions',
description:
'A user assigned this permission can edit api key permissions of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit api key permissions of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectApiKey,
title: 'Can Edit API Key',
description:
'A user assigned this permission can edit api keys of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit api keys of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectApiKey,
title: 'Can Read API Key',
description:
'A user assigned this permission can read api keys of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read api keys of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectLabel,
title: 'Can Create Label',
description:
'A user assigned this permission can create labels this this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can create labels this this project.',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectLabel,
title: 'Can Delete Label',
description:
'A user assigned this permission can delete labels of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete labels of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanAddLabelsToProjectResources,
title: 'Can Add Label to Resources',
description:
'A user assigned this permission can add project labels to resources of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can add project labels to resources of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectLabel,
title: 'Can Edit Label',
description:
'A user assigned this permission can edit labels of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit labels of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectLabel,
title: 'Can Read Label',
description:
'A user assigned this permission can read labels of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read labels of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectSMTPConfig,
title: 'Can Create SMTP Config',
description:
'A user assigned this permission can create SMTP configs this this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can create SMTP configs this this project.',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectSMTPConfig,
title: 'Can Delete SMTP Config',
description:
'A user assigned this permission can delete SMTP configs of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete SMTP configs of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectSMTPConfig,
title: 'Can Edit SMTP Config',
description:
'A user assigned this permission can edit SMTP configs of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit SMTP configs of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectSMTPConfig,
title: 'Can Read SMTP Config',
description:
'A user assigned this permission can read SMTP configs of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read SMTP configs of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectTeam,
title: 'Can Create Team',
description:
'A user assigned this permission can create teams this this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can create teams this this project.',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectTeam,
title: 'Can Delete Team',
description:
'A user assigned this permission can delete teams of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete teams of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanInviteProjectTeamMembers,
title: 'Can Invite New Members',
description:
'A user assigned this permission can inivte users to the team.',
isAssignableToProject: true,
description: 'A user assigned this permission can inivte users to the team.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectTeamPermissions,
title: 'Can Edit Team Permissions',
description:
'A user assigned this permission can edit team permissions of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit team permissions of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectTeam,
title: 'Can Edit Team',
description:
'A user assigned this permission can edit teams of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit teams of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectTeam,
title: 'Can Read Teams',
description:
'A user assigned this permission can read teams of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read teams of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectResources,
title: 'Can Create Resources',
description:
'A user assigned this permission can create resources this this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can create resources this this project.',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectResources,
title: 'Can Delete Resources',
description:
'A user assigned this permission can delete resources of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete resources of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectResources,
title: 'Can Edit Resources',
description:
'A user assigned this permission can edit resources of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit resources of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectResources,
title: 'Can Read Resources',
description:
'A user assigned this permission can read resources of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read resources of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanCreateProjectProbe,
title: 'Can Create Probe',
description:
'A user assigned this permission can create probe this this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can create probe this this project.',
isAssignableToProject: true
},
{
permission: Permission.CanDeleteProjectProbe,
title: 'Can Delete Probe',
description:
'A user assigned this permission can delete probe of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can delete probe of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanEditProjectProbe,
title: 'Can Edit Probe',
description:
'A user assigned this permission can edit probe of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can edit probe of this project.',
isAssignableToProject: true
},
{
permission: Permission.CanReadProjectProbe,
title: 'Can Read Probe',
description:
'A user assigned this permission can read probe of this project.',
isAssignableToProject: true,
description: 'A user assigned this permission can read probe of this project.',
isAssignableToProject: true
},
];
return permissions;
}
}
export interface UserGlobalAccessPermission extends JSONObject {

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseService from '../Services/DatabaseService';
import Express, {
ExpressRequest,

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import Dictionary from 'Common/Types/Dictionary';
import { JSONValue } from 'Common/Types/JSON';

View File

@ -16,7 +16,7 @@ import Exception from 'Common/Types/Exception/Exception';
import SearchResult from '../Types/Database/SearchResult';
import Encryption from '../Utils/Encryption';
import { JSONObject } from 'Common/Types/JSON';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import PostgresDatabase, {
PostgresAppInstance,
} from '../Infrastructure/PostgresDatabase';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import PositiveNumber from 'Common/Types/PositiveNumber';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
import Query from './Query';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
export default interface CreateBy<TBaseModel extends BaseModel> {

View File

@ -1,5 +1,5 @@
import DeleteOneBy from './DeleteOneBy';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
type DeleteBy<TBaseModel extends BaseModel> = DeleteOneBy<TBaseModel>;
export default DeleteBy;

View File

@ -1,5 +1,5 @@
import Query from './Query';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import User from 'Model/Models/User';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import PositiveNumber from 'Common/Types/PositiveNumber';
import FindOneBy from './FindOneBy';

View File

@ -2,7 +2,7 @@ import Query from './Query';
import Select from './Select';
import Populate from './Populate';
import Sort from './Sort';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
export default interface FindOneBy<TBaseModel extends BaseModel> {

View File

@ -1,6 +1,6 @@
import ObjectID from 'Common/Types/ObjectID';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import Select from './Select';
import Populate from './Populate';

View File

@ -1,5 +1,5 @@
import Query from './Query';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
export default interface HardDeleteBy<TBaseModel extends BaseModel> {

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import { FindOptionsRelations } from 'typeorm';
type Populate<TBaseModel extends BaseModel> = FindOptionsRelations<TBaseModel>;

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseProperty from 'Common/Types/Database/DatabaseProperty';
import { FindOperator, FindOptionsWhereProperty } from 'typeorm';

View File

@ -1,7 +1,7 @@
import Select from './Select';
import Populate from './Populate';
import PositiveNumber from 'Common/Types/PositiveNumber';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
export default interface SearchBy<TBaseModel extends BaseModel> {

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import PositiveNumber from 'Common/Types/PositiveNumber';
export default interface SearchResult<TBaseModel extends BaseModel> {

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseProperty from 'Common/Types/Database/DatabaseProperty';
import { FindOptionsSelectProperty } from 'typeorm';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import DatabaseProperty from 'Common/Types/Database/DatabaseProperty';
import { FindOptionsOrderProperty, FindOptionsOrderValue } from 'typeorm';
import SortOrder from 'Common/Types/Database/SortOrder';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import UpdateOneBy from './UpdateOneBy';
type UpdateBy<TBaseModel extends BaseModel> = UpdateOneBy<TBaseModel>;

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import ObjectID from 'Common/Types/ObjectID';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps';
import Query from './Query';

View File

@ -12,7 +12,7 @@ import Exception from 'Common/Types/Exception/Exception';
import ListData from 'Common/Types/ListData';
import PositiveNumber from 'Common/Types/PositiveNumber';
import URL from 'Common/Types/API/URL';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import EmptyResponse from 'Common/Types/API/EmptyResponse';
export default class Response {

View File

@ -18,9 +18,9 @@
"@types/react-toggle": "^4.0.3",
"bootstrap": "^5.2.0-beta1",
"Common": "file:../Common",
"Model": "file:../Model",
"formik": "^2.2.9",
"history": "^5.3.0",
"Model": "file:../Model",
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react-color": "^2.19.3",
@ -71,6 +71,7 @@
"ts-jest": "^27.1.4"
}
},
"../Model": {},
"node_modules/@ailibs/feather-react-ts": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@ailibs/feather-react-ts/-/feather-react-ts-3.0.3.tgz",
@ -1253,6 +1254,10 @@
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
"integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
},
"node_modules/Model": {
"resolved": "../Model",
"link": true
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -2672,6 +2677,9 @@
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
"integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
},
"Model": {
"version": "file:../Model"
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",

View File

@ -1,6 +1,6 @@
import React, { MutableRefObject, ReactElement } from 'react';
import { FormikErrors, FormikProps, FormikValues } from 'formik';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import FormValues from './Types/FormValues';
import Fields from './Types/Fields';
import BasicForm, { DefaultValidateFunction } from './BasicForm';

View File

@ -5,7 +5,7 @@ import React, {
useState,
} from 'react';
import { FormikErrors, FormikProps, FormikValues } from 'formik';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import FormValues from './Types/FormValues';
import Fields from './Types/Fields';
import BasicModelForm from './BasicModelForm';

View File

@ -3,7 +3,7 @@ import URL from 'Common/Types/API/URL';
import FormFieldSchemaType from './FormFieldSchemaType';
import SelectFormFields from '../../../Types/SelectEntityField';
import { DropdownOption } from '../../Dropdown/Dropdown';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
export default interface Field<TEntity> {
title?: string;

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse';
import { JSONObject } from 'Common/Types/JSON';
import ObjectID from 'Common/Types/ObjectID';

View File

@ -10,7 +10,7 @@ import Card, {
ComponentProps as CardProps,
} from '../Card/Card';
import ModelDetail, { ComponentProps as ModeDetailProps } from './ModelDetail';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import { ButtonStyleType } from '../Button/Button';
import { IconProp } from '../Icon/Icon';
import ModelFromModal from '../ModelFormModal/ModelFormModal';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import Route from 'Common/Types/API/Route';
import URL from 'Common/Types/API/URL';
import Select from '../../Utils/ModelAPI/Select';

View File

@ -1,5 +1,5 @@
import React, { ReactElement, useEffect, useState } from 'react';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import { JSONObject } from 'Common/Types/JSON';
import ModelAPI from '../../Utils/ModelAPI/ModelAPI';
import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse';

View File

@ -4,7 +4,7 @@ import Modal from '../Modal/Modal';
import ModelForm, {
ComponentProps as ModelFormComponentProps,
} from '../Forms/ModelForm';
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import ButtonType from '../Button/ButtonTypes';
import { JSONObjectOrArray } from 'Common/Types/JSON';
import { FormikProps, FormikValues } from 'formik';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import React, { ReactElement, useEffect, useState } from 'react';
import Columns from './Columns';
import Table from '../Table/Table';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import ObjectID from 'Common/Types/ObjectID';
import Query from './Query';
import Select from './Select';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
type Populate<TBaseModel extends BaseModel> = {
[P in keyof TBaseModel]?: boolean;

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import Search from 'Common/Types/Database/Search';
import { JSONValue } from 'Common/Types/JSON';

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
type Select<TBaseModel extends BaseModel> = {
[P in keyof TBaseModel]?: boolean;

View File

@ -1,4 +1,4 @@
import BaseModel from 'Model/Models/BaseModel';
import BaseModel from 'Common/Models/BaseModel';
import SortOrder from 'Common/Types/Database/SortOrder';
type Query<TBaseModel extends BaseModel> = {

72
Model/package-lock.json generated Normal file
View File

@ -0,0 +1,72 @@
{
"name": "model",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "model",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"Common": "file:../Common"
}
},
"../Common": {
"name": "common",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@types/crypto-js": "^4.1.1",
"@types/nanoid-dictionary": "^4.2.0",
"@types/uuid": "^8.3.4",
"axios": "^0.26.1",
"crypto-js": "^4.1.1",
"moment": "^2.29.2",
"nanoid": "^3.3.2",
"nanoid-dictionary": "^4.3.0",
"process": "^0.11.10",
"reflect-metadata": "^0.1.13",
"slugify": "^1.6.5",
"typeorm": "^0.3.6",
"uuid": "^8.3.2"
},
"devDependencies": {
"@faker-js/faker": "^6.3.1",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.22",
"jest": "^27.5.1",
"ts-jest": "^27.1.4"
}
},
"node_modules/Common": {
"resolved": "../Common",
"link": true
}
},
"dependencies": {
"Common": {
"version": "file:../Common",
"requires": {
"@faker-js/faker": "^6.3.1",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^27.4.1",
"@types/nanoid-dictionary": "^4.2.0",
"@types/node": "^17.0.22",
"@types/uuid": "^8.3.4",
"axios": "^0.26.1",
"crypto-js": "^4.1.1",
"jest": "^27.5.1",
"moment": "^2.29.2",
"nanoid": "^3.3.2",
"nanoid-dictionary": "^4.3.0",
"process": "^0.11.10",
"reflect-metadata": "^0.1.13",
"slugify": "^1.6.5",
"ts-jest": "^27.1.4",
"typeorm": "^0.3.6",
"uuid": "^8.3.2"
}
}
}
}

14
Model/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "model",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"Common": "file:../Common"
},
"author": "",
"license": "ISC"
}

106
Model/tsconfig.json Normal file
View File

@ -0,0 +1,106 @@
{
"compilerOptions": {
"experimentalDecorators": true,
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react", /* Specify what JSX code is generated. */ /* Enable experimental support for TC39 stage 2 draft decorators. */
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
// "module": "es2022" /* Specify what module code is generated. */,
// "rootDir": "./" /* Specify the root folder within your source files. */,
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./node_modules/@types"
] /* Specify multiple folders that act like `./node_modules/@types`. */,
"types": [
"node",
"jest"
] /* Specify type package names to be included without being referenced in a source file. */,
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./build/dist" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */,
"strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */,
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
"strictBindCallApply": true /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */,
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
"noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */,
"useUnknownInCatchVariables": true /* Type catch clause variables as 'unknown' instead of 'any'. */,
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
"exactOptionalPropertyTypes": true /* Interpret optional property types as written, rather than adding 'undefined'. */,
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
"noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */,
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
"noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type */,
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@ -53,11 +53,13 @@ services:
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
saml:
image: kenchan0130/simplesamlphp
@ -101,11 +103,13 @@ services:
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
dashboard:
ports:
@ -124,15 +128,15 @@ services:
- accounts
volumes:
- ./Dashboard:/usr/src/app
# Use node modules of the container and not host system.
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# data-ingestor:
# ports:
@ -157,11 +161,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# - /usr/src/Model/node_modules/
# realtime:
# ports:
@ -182,11 +188,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# - /usr/src/Model/node_modules/
# helmchart:
# ports:
@ -206,11 +214,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# - /usr/src/Model/node_modules/
# probe-api:
@ -232,11 +242,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# - /usr/src/Model/node_modules/
# # There can only be one probe in developer docker compose.
# probe:
@ -260,11 +272,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# api-docs:
# ports:
@ -284,11 +298,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# script-runner:
@ -310,11 +326,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
dashboard-api:
ports:
@ -343,11 +361,13 @@ services:
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
identity:
ports:
@ -376,11 +396,13 @@ services:
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# alert:
# ports:
@ -404,11 +426,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# - /usr/src/Model/node_modules/
# integration:
# ports:
@ -432,11 +456,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
home:
ports:
@ -457,11 +483,13 @@ services:
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./Model:/usr/src/Model
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# status-page:
# ports:
@ -481,11 +509,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# admin-dashboard:
# ports:
@ -505,11 +535,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# http-test-server:
# ports:
@ -530,11 +562,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# licensing:
# ports:
@ -555,11 +589,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# application-scanner:
# ports:
@ -580,11 +616,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# container-scanner:
# ports:
@ -605,11 +643,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
# lighthouse-runner:
# ports:
@ -630,11 +670,13 @@ services:
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
- ./Model:/usr/src/Model
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
nginx:
depends_on:
- identity