-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Duna-System/feat/ProjectsValidation
testeValidation DB
- Loading branch information
Showing
58 changed files
with
3,154 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Format and Build | ||
|
||
on: | ||
push: | ||
branches: ['master'] | ||
pull_request: | ||
branches: ['master'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm install | ||
- run: npx prettier -c . | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export declare function connectToDatabase(url: string): Promise<void>; | ||
export declare function connectToDatabase(url: string, databaseName: string): Promise<void>; | ||
export declare function checkConnectionStatus(): void; | ||
export declare function subscribeToDatabaseEvents(): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// <reference types="mongoose/types/aggregate" /> | ||
/// <reference types="mongoose/types/callback" /> | ||
/// <reference types="mongoose/types/collection" /> | ||
/// <reference types="mongoose/types/connection" /> | ||
/// <reference types="mongoose/types/cursor" /> | ||
/// <reference types="mongoose/types/document" /> | ||
/// <reference types="mongoose/types/error" /> | ||
/// <reference types="mongoose/types/expressions" /> | ||
/// <reference types="mongoose/types/helpers" /> | ||
/// <reference types="mongoose/types/middlewares" /> | ||
/// <reference types="mongoose/types/indexes" /> | ||
/// <reference types="mongoose/types/models" /> | ||
/// <reference types="mongoose/types/mongooseoptions" /> | ||
/// <reference types="mongoose/types/pipelinestage" /> | ||
/// <reference types="mongoose/types/populate" /> | ||
/// <reference types="mongoose/types/query" /> | ||
/// <reference types="mongoose/types/schemaoptions" /> | ||
/// <reference types="mongoose/types/schematypes" /> | ||
/// <reference types="mongoose/types/session" /> | ||
/// <reference types="mongoose/types/types" /> | ||
/// <reference types="mongoose/types/utility" /> | ||
/// <reference types="mongoose/types/validation" /> | ||
/// <reference types="mongoose/types/virtuals" /> | ||
/// <reference types="mongoose" /> | ||
/// <reference types="mongoose/types/inferschematype" /> | ||
import { IEntityDb } from '../../interfaces'; | ||
export declare class EntityService { | ||
protected model: import("mongoose").Model<IEntityDb, {}, {}, {}, import("mongoose").Document<unknown, {}, IEntityDb> & IEntityDb & Required<{ | ||
_id: string; | ||
}>, any>; | ||
protected configure(): void; | ||
insert(entity: IEntityDb): Promise<IEntityDb>; | ||
get(entity_id: string): Promise<IEntityDb>; | ||
getByName(project_id: string, entity_name: string): Promise<IEntityDb>; | ||
update(entity: IEntityDb): Promise<IEntityDb>; | ||
remove(entity_id: string): Promise<void>; | ||
removeAllFromUser(user_id: string): Promise<void>; | ||
exists(entity_id: string): Promise<boolean>; | ||
existsWithName(project_id: string, entity_name: string): Promise<boolean>; | ||
listAllFromProject(project_id: string): Promise<IEntityDb[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EntityService = void 0; | ||
const duna_web_platform_error_defs_1 = require("duna-web-platform-error-defs"); | ||
const connection_1 = require("../../connection"); | ||
const validationEntityModel_1 = require("../validationEntityModel"); | ||
class EntityService { | ||
constructor() { | ||
this.model = validationEntityModel_1.entityModel; | ||
} | ||
configure() { } | ||
insert(entity) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const entity_record = new this.model(entity); | ||
yield entity_record.save(); | ||
return entity_record.toJSON(); | ||
}); | ||
} | ||
get(entity_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const entity_record = yield this.model.findById(entity_id).lean().exec(); | ||
if (!entity_record) { | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.EntityDoesNotExist; | ||
throw err; | ||
} | ||
return entity_record; | ||
}); | ||
} | ||
getByName(project_id, entity_name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const entity_record = yield this.model | ||
.findOne({ projectId: project_id, name: entity_name }) | ||
.lean() | ||
.exec(); | ||
if (!entity_record) { | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.EntityDoesNotExist; | ||
throw err; | ||
} | ||
return entity_record; | ||
}); | ||
} | ||
update(entity) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const entity_record = yield this.model | ||
.findByIdAndUpdate(entity._id, entity, { | ||
new: true, | ||
}) | ||
.lean() | ||
.exec(); | ||
if (!entity_record) { | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.EntityDoesNotExist; | ||
throw err; | ||
} | ||
return entity_record; | ||
}); | ||
} | ||
remove(entity_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const exists = yield this.exists(entity_id); | ||
if (!exists) { | ||
const err = duna_web_platform_error_defs_1.ErrorMessages.EntityDoesNotExist; | ||
throw err; | ||
} | ||
yield this.model.findByIdAndRemove(entity_id); | ||
}); | ||
} | ||
removeAllFromUser(user_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
yield this.model.deleteMany({ user_id: user_id }); | ||
}); | ||
} | ||
exists(entity_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const exists = (yield this.model.exists({ _id: entity_id }).lean().exec()) != null; | ||
return exists; | ||
}); | ||
} | ||
existsWithName(project_id, entity_name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const project = yield this.model | ||
.findOne({ projectId: project_id, name: entity_name }) | ||
.lean() | ||
.exec(); | ||
return project != null; | ||
}); | ||
} | ||
listAllFromProject(project_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
//Check if mongoDB is connected | ||
(0, connection_1.checkConnectionStatus)(); | ||
const entities = yield this.model | ||
.find({ proje: project_id }) | ||
.lean() | ||
.exec(); | ||
return entities; | ||
}); | ||
} | ||
} | ||
exports.EntityService = EntityService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
import { createUserCollectionWithValidation } from './users/validationDbUsers'; | ||
import { UserModel } from './users/validationUserModel'; | ||
import { IUsers } from './interfaces'; | ||
import { IMemberDb, IUser, IUsers } from './interfaces'; | ||
import { connectToDatabase, checkConnectionStatus, subscribeToDatabaseEvents } from './connection'; | ||
import { IEntityDb } from './interfaces'; | ||
import { IProjectDb } from './interfaces'; | ||
import { IOrganizationDb } from './interfaces'; | ||
import { entityModel } from './entity/validationEntityModel'; | ||
import { projectModel } from './projects/validationProjectsModel'; | ||
import { organizationModel } from './organizations/validationOrgModel'; | ||
import { createEntityCollectionWithValidation } from './entity/validationEntityDb'; | ||
export { createUserCollectionWithValidation, connectToDatabase, checkConnectionStatus, subscribeToDatabaseEvents, createEntityCollectionWithValidation, UserModel, entityModel, IUsers, IEntityDb }; | ||
import { createProjectCollectionWithValidation } from './projects/validationProjectsDb'; | ||
import { createOrganizationCollectionWithValidation } from './organizations/validationOrgDb'; | ||
import { createUserService } from './users/services/createUserService'; | ||
import { getUserByEmail } from './users/services/loginService'; | ||
import { deleteUserService } from './users/services/deleteUserService'; | ||
import { getOneUserService } from './users/services/getOneUserService'; | ||
import { getUsersService } from './users/services/getUsersService'; | ||
import { EntityService } from './entity/services/EntityService'; | ||
import { ProjectService } from './projects/services/ProjectService'; | ||
import { OrganizationService } from './organizations/services/OrganizationService'; | ||
import { updateUserService } from './users/services/updateUserService'; | ||
import { UserService } from './usersProject/UserService'; | ||
export { createUserCollectionWithValidation, connectToDatabase, checkConnectionStatus, subscribeToDatabaseEvents, createEntityCollectionWithValidation, createProjectCollectionWithValidation, createOrganizationCollectionWithValidation, deleteUserService, getOneUserService, getUsersService, createUserService, updateUserService, getUserByEmail, UserService, OrganizationService, EntityService, ProjectService, UserModel, entityModel, organizationModel, IUsers, IUser, IEntityDb, IProjectDb, projectModel, IOrganizationDb, IMemberDb, }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EntityType = exports.ShareGroupType = exports.ProjectAccessType = exports.ProjectStatus = exports.OrganizationMemberRole = void 0; | ||
var OrganizationMemberRole; | ||
(function (OrganizationMemberRole) { | ||
OrganizationMemberRole["VIEWER"] = "VIEWER"; | ||
OrganizationMemberRole["EDITOR"] = "EDITOR"; | ||
OrganizationMemberRole["ADMIN"] = "ADMIN"; | ||
OrganizationMemberRole["OWNER"] = "OWNER"; | ||
})(OrganizationMemberRole || (exports.OrganizationMemberRole = OrganizationMemberRole = {})); | ||
var ProjectStatus; | ||
(function (ProjectStatus) { | ||
ProjectStatus["IN_PROGRESS"] = "IN_PROGRESS"; | ||
ProjectStatus["FINISHED"] = "FINISHED"; | ||
})(ProjectStatus || (exports.ProjectStatus = ProjectStatus = {})); | ||
var ProjectAccessType; | ||
(function (ProjectAccessType) { | ||
ProjectAccessType["INTERNAL"] = "INTERNAL"; | ||
ProjectAccessType["PRIVATE"] = "PRIVATE"; | ||
})(ProjectAccessType || (exports.ProjectAccessType = ProjectAccessType = {})); | ||
var ShareGroupType; | ||
(function (ShareGroupType) { | ||
ShareGroupType["Public"] = "public"; | ||
ShareGroupType["Private"] = "private"; | ||
})(ShareGroupType || (exports.ShareGroupType = ShareGroupType = {})); | ||
var EntityType; | ||
(function (EntityType) { | ||
EntityType["PointCloud"] = "clouds"; | ||
EntityType["Image"] = "images"; | ||
EntityType["BIM"] = "bim"; | ||
EntityType["Unknown"] = "unknown"; | ||
})(EntityType || (exports.EntityType = EntityType = {})); |
Oops, something went wrong.