bugs cleared for the testing purpose

This commit is contained in:
2025-06-02 16:48:44 +05:30
parent 17727c1281
commit 09ea99098f
41 changed files with 117 additions and 163 deletions

View File

@@ -3,7 +3,7 @@ import MainModel from "../../connect/mongoose.ts";
import { User } from "./userAuthModel.ts";
export interface Token extends Document {
userId: User["_id"];
isArchive: Boolean;
isArchive: boolean;
refreshToken: string;
resetTokenExpiry?: Date;
resetToken: string;

View File

@@ -13,14 +13,14 @@ export interface Camera extends Document {
z: number;
};
target: {
x: { type: Number; required: true };
y: { type: Number; required: true };
z: { type: Number; required: true };
x: { type: number; required: true };
y: { type: number; required: true };
z: { type: number; required: true };
};
rotation: {
x: { type: Number; required: true };
y: { type: Number; required: true };
z: { type: Number; required: true };
x: { type: number; required: true };
y: { type: number; required: true };
z: { type: number; required: true };
};
}

View File

@@ -125,12 +125,12 @@ interface StorageEventSchema extends AssetEventSchema {
point: StoragePointSchema;
}
interface IPointModel extends Document {
modelUuid: String;
modelName: String;
position: String;
rotation: String;
state: String;
productId: String;
modelUuid: string;
modelName: string;
position: [number];
rotation: [number];
state: string;
productId: string;
isArchive: boolean;
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
speed: number;

View File

@@ -6,7 +6,7 @@ import MainModel from "../../connect/mongoose.ts";
interface IComment {
userId: User["_id"];
comment: string;
timestamp:Number
timestamp:number
}
export interface IThread extends Document {
projectId: Project["_id"];

View File

@@ -1,4 +1,4 @@
import { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
import { Zone } from "../Builder/zoneModel.ts";
export interface Widget3d extends Document {
@@ -8,7 +8,7 @@ export interface Widget3d extends Document {
position: [];
rotation: [];
isArchive: boolean;
zoneId: string;
zoneId: Zone["_id"];
Data: {
measurements: {};
duration: string;
@@ -21,7 +21,7 @@ const Widget3dSchema: Schema = new Schema(
widgetName: { type: String, default: "Widget3D" },
position: { type: Array },
rotation: { type: Array },
zoneId: { type: String },
zoneId:{ type: Schema.Types.ObjectId, ref: "Zone" },
Data: {
measurements: { type: Object, default: {} },
duration: { type: String, default: "1h" },

View File

@@ -1,5 +1,5 @@
import { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
import { Zone } from "../Builder/zoneModel.ts";
export interface FloatingWidget extends Document {
className: string;
@@ -10,7 +10,7 @@ export interface FloatingWidget extends Document {
per: string;
value: string;
isArchive: boolean;
zoneId: string;
zoneId: Zone["_id"];
Data: {
measurements: {};
duration: string;
@@ -25,7 +25,7 @@ const floatingWidgetSchema: Schema = new Schema(
position: { type: Object },
per: { type: String },
value: { type: String },
zoneId: { type: String },
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
Data: {
measurements: { type: Object, default: {} },
duration: { type: String, default: "1h" },

View File

@@ -2,14 +2,14 @@ import mongoose, { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
import { Zone } from "../Builder/zoneModel.ts";
export interface Panel extends Document {
zoneId: string;
zoneId: Zone["_id"];
panelName: string;
widgets: [mongoose.Types.ObjectId];
isArchive: boolean;
}
const panelSchema: Schema = new Schema(
{
zoneId: { type: String },
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
panelName: { type: String },
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
isArchive: { type: Boolean, default: false },

View File

@@ -1,7 +1,7 @@
import mongoose, { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
import { Zone } from "../Builder/zoneModel.ts";
export interface widget extends Document {
export interface Widget extends Document {
widgetName: string;
widgetside: string;
widgetID: string;
@@ -17,7 +17,7 @@ export interface widget extends Document {
measurements: {};
duration: string;
};
zoneId: string;
zoneId: Zone["_id"];
}
const widgetSchema: Schema = new Schema(
{
@@ -36,7 +36,7 @@ const widgetSchema: Schema = new Schema(
fontWeight: { type: String },
isArchive: { type: Boolean, default: false },
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
zoneId: { type: String },
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
},
{ timestamps: true }
);

View File

@@ -1,5 +1,4 @@
import mongoose, { Schema, Connection, Model } from "mongoose";
import { Client } from "minio";
interface ConnectionCache {
[key: string]: Connection;
}

View File

@@ -1,4 +1,4 @@
import { Response, Request, NextFunction } from "express";
import { Response, NextFunction } from "express";
import { AuthenticatedRequest } from "../../shared/utils/token.ts";
type Role = "Admin" | "User";
const authorizedRoles = (...allowedRoles: Role[]) => {

View File

@@ -20,7 +20,7 @@ interface IThread {
}
export const createThread = async (data: IThread) => {
try {
const { projectId, versionId, state, userId, position, rotation, comments, organization, threadId } = data
const { projectId, state, userId, position, rotation, comments, organization } = data
const userExisting = await existingUser(userId, organization);
if (!userExisting) {
return {
@@ -38,7 +38,6 @@ export const createThread = async (data: IThread) => {
}
const newThread = await ThreadModel(organization).create({
projectId,
versionId,
state,
createdBy: userId,
position,
@@ -58,7 +57,7 @@ export const createThread = async (data: IThread) => {
}
export const deleteThread = async (data: IThread) => {
try {
const { projectId, versionId, state, userId, organization, threadId } = data
const { projectId, userId, organization, threadId } = data
const userExisting = await existingUser(userId, organization);
if (!userExisting) {
return {
@@ -92,7 +91,7 @@ export const deleteThread = async (data: IThread) => {
}
export const addComments = async (data: IThread) => {
try {
const { projectId, versionId, userId, comments, organization, threadId } = data
const { projectId, userId, comments, organization, threadId } = data
const userExisting = await existingUser(userId, organization);
if (!userExisting) {
return {
@@ -125,7 +124,7 @@ export const addComments = async (data: IThread) => {
}
export const deleteComments = async (data: IThread) => {
try {
const { projectId, versionId, userId, commentId, organization, threadId } = data
const { projectId, userId, commentId, organization, threadId } = data
const userExisting = await existingUser(userId, organization);
if (!userExisting) {
return {

View File

@@ -64,7 +64,7 @@ export const AuthSignup = async (
Email: caseChange,
Password: hashPassword,
});
const UserDatas = await UsersDataModel(organization).create({
await UsersDataModel(organization).create({
userId: newuser._id,
role: role,
isShare: isShare,
@@ -449,7 +449,7 @@ async function handleTokenCache(
isArchive: false,
});
if (!tokenDoc) {
tokenDoc = await tokenType(organization).create({ userId, refreshToken });
await tokenType(organization).create({ userId, refreshToken });
} else {
await tokenType(organization).findByIdAndUpdate(
tokenDoc._id,

View File

@@ -6,7 +6,7 @@ import {
existingUser,
} from "../helpers/v1projecthelperFns.ts";
interface setAssetInput {
interface SetAssetInput {
modelUuid: string;
modelName: string;
position: [];
@@ -50,7 +50,7 @@ interface ReplaceEventInput {
modelUuid: string;
}
export const setAssetModel = async (
data: setAssetInput
data: SetAssetInput
): Promise<{ status: string; data?: Object }> => {
try {
const {
@@ -286,7 +286,7 @@ export const deleteAssetModel = async (
status: "Failed to archive asset",
};
}
const updatedEvents = await EventsDataModel(organization).updateMany(
await EventsDataModel(organization).updateMany(
{ modelUuid, productId: projectId },
{ $set: { isArchive: true } }
);
@@ -342,7 +342,7 @@ export const replaceEventDatas = async (
{ modelUuid, projectId, isArchive: false },
{
points: typedEventData?.points,
type: typedEventData?.type || existingModel?.type,
type: typedEventData?.type ?? existingModel?.type,
},
{ new: true }
);

View File

@@ -11,7 +11,6 @@ interface IcameraData {
rotation: Object;
organization: string;
projectId: string;
versionId: string;
}
interface IgetCameras {
organization: string;
@@ -32,8 +31,7 @@ export const SetCamera = async (
target,
rotation,
organization,
projectId,
versionId,
projectId
} = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
@@ -52,7 +50,6 @@ export const SetCamera = async (
{
userId: userId,
projectId: projectId,
versionId: versionId,
isArchive: false,
},
{ position: position, target: target, rotation: rotation },
@@ -66,7 +63,6 @@ export const SetCamera = async (
const newCamera = await cameraModel(organization).create({
userId,
projectId,
versionId,
position,
target,
rotation,

View File

@@ -14,7 +14,7 @@ interface IProject {
createdAt: Date;
isViewed?: number;
}
interface searchProjectInterface {
interface SearchProjectInterface {
searchName: string;
userId: string;
organization: string;
@@ -50,7 +50,7 @@ export const RecentlyAdded = async (data: IRecentData) => {
return { status: error };
}
};
export const searchProject = async (data: searchProjectInterface) => {
export const searchProject = async (data: SearchProjectInterface) => {
try {
const { userId, organization, searchName } = data;
const userExisting = await existingUser(userId, organization);
@@ -66,7 +66,7 @@ export const searchProject = async (data: searchProjectInterface) => {
return { status: error };
}
};
export const searchTrashProject = async (data: searchProjectInterface) => {
export const searchTrashProject = async (data: SearchProjectInterface) => {
try {
const { userId, organization, searchName } = data;
const userExisting = await existingUser(userId, organization);

View File

@@ -4,7 +4,6 @@ import versionModel from "../../model/version/versionModel.ts";
import {
existingProject,
existingUser,
archiveProject,
previousVersion,
generateUntitledProjectName,
} from "../helpers/ProjecthelperFn.ts";
@@ -16,7 +15,7 @@ interface CreateProjectInput {
sharedUsers?: string[];
organization: string;
}
interface updateProjectInput {
interface UpdateProjectInput {
projectName: string;
projectId: string;
userId: string;
@@ -130,7 +129,7 @@ export const DeleteProject = async (data: ProjectInterface) => {
return { status: error };
}
};
export const updateProject = async (data: updateProjectInput) => {
export const updateProject = async (data: UpdateProjectInput) => {
try {
const { projectId, organization, userId, projectName, thumbnail } = data;
const ExistingUser = await existingUser(userId, organization);
@@ -141,8 +140,8 @@ export const updateProject = async (data: updateProjectInput) => {
isArchive: false,
});
if (!existingProject) return { status: "Project not found" };
if (projectName !== undefined) projectName;
if (thumbnail !== undefined) thumbnail;
if (projectName !== undefined) existingProject.projectName=projectName;
if (thumbnail !== undefined) existingProject.thumbnail=thumbnail;
const updateProject = await projectModel(organization)
.findOneAndUpdate(
{ _id: projectId, isArchive: false },

View File

@@ -12,8 +12,8 @@ interface Iproduct {
eventDatas: {
modelUuid: string;
modelName: string;
position: [Number];
rotation: [Number];
position: [number];
rotation: [number];
type: string;
speed: string;
point: Mixed;

View File

@@ -1,5 +1,4 @@
import projectModel from "../../model/project/project-model.ts";
import { existingUser } from "../helpers/v1projecthelperFns.ts";
interface IOrg {
organization: string;
}

View File

@@ -3,7 +3,6 @@ import versionModel from "../../V1Models/Version/versionModel.ts";
import {
existingProject,
existingUser,
archiveProject,
previousVersion,
generateUntitledProjectName,
} from "../helpers/v1projecthelperFns.ts";
@@ -11,7 +10,7 @@ import UsersDataModel from "../../V1Models/Auth/user.ts";
interface CreateProjectInput {
projectName: string;
projectUuid: string;
userId: string;
userId: string;
thumbnail?: string;
sharedUsers?: string[];
organization: string;
@@ -19,15 +18,15 @@ interface CreateProjectInput {
interface IProjectDuplicate {
projectName: string;
projectUuid: string;
userId: string;
userId: string;
thumbnail?: string;
sharedUsers?: string[];
organization: string;
}
interface updateProjectInput {
interface UpdateProjectInput {
projectName: string;
projectId: string;
userId: string;
userId: string;
thumbnail?: string;
sharedUsers?: string[];
organization: string;
@@ -112,7 +111,7 @@ export const createProject = async (data: CreateProjectInput) => {
export const GetAllProjects = async (data: GetProjectsInterface) => {
try {
const { userId, organization, role } = data;
const { userId, organization } = data;
await existingUser(userId, organization);
if (!existingUser) return { status: "User not found" };
let filter = { isArchive: false } as RoleFilter;
@@ -147,9 +146,9 @@ export const DeleteProject = async (data: ProjectDelInterface) => {
return { status: error };
}
};
export const updateProject = async (data: updateProjectInput) => {
export const updateProject = async (data: UpdateProjectInput) => {
try {
const { projectId, organization, userId, projectName, thumbnail, role } =
const { projectId, organization, userId, projectName, thumbnail } =
data;
const ExistingUser = await existingUser(userId, organization);
if (!ExistingUser) return { status: "User not found" };
@@ -157,8 +156,8 @@ export const updateProject = async (data: updateProjectInput) => {
const existingProject = await projectModel(organization).findOne(filter);
if (!existingProject) return { status: "Project not found" };
if (projectName !== undefined) projectName;
if (thumbnail !== undefined) thumbnail;
if (projectName !== undefined) existingProject.projectName = projectName;
if (thumbnail !== undefined) existingProject.thumbnail = thumbnail;
const updateProject = await projectModel(organization)
.findOneAndUpdate(
filter,
@@ -231,7 +230,7 @@ export const DuplicateProject = async (data: IProjectDuplicate) => {
const maxLength: number = 6;
export const viewProject = async (data: ProjectInterface) => {
try {
const { projectId, organization, userId, role } = data;
const { projectId, organization, userId } = data;
const userExisting = await existingUser(userId, organization);
if (!userExisting) return { status: "User not found" };
const RecentUserDoc = await UsersDataModel(organization).findOne({
@@ -257,7 +256,7 @@ export const viewProject = async (data: ProjectInterface) => {
newArr.pop();
}
}
const datas = await UsersDataModel(organization).findOneAndUpdate(
await UsersDataModel(organization).findOneAndUpdate(
{ userId: userId, isArchive: false },
{ recentlyViewed: newArr },
{ new: true }

View File

@@ -15,18 +15,14 @@ interface IProject {
createdAt: Date;
isViewed?: number;
}
interface searchProjectInterface {
interface SearchProjectInterface {
searchName: string;
userId: string;
organization: string;
}
interface RoleFilter {
isArchive: boolean;
createdBy?: string;
}
export const RecentlyAdded = async (data: IRecentData) => {
try {
const { userId, organization, role } = data;
const { userId, organization } = data;
const userExisting = await existingUser(userId, organization);
if (!userExisting) return { status: "User not found" };
const userRecentData = await UsersDataModel(organization)
@@ -54,7 +50,7 @@ export const RecentlyAdded = async (data: IRecentData) => {
return { status: error };
}
};
export const searchProject = async (data: searchProjectInterface) => {
export const searchProject = async (data: SearchProjectInterface) => {
try {
const { userId, organization, searchName } = data;
const userExisting = await existingUser(userId, organization);
@@ -70,7 +66,7 @@ export const searchProject = async (data: searchProjectInterface) => {
return { status: error };
}
};
export const searchTrashProject = async (data: searchProjectInterface) => {
export const searchTrashProject = async (data: SearchProjectInterface) => {
try {
const { userId, organization, searchName } = data;
const userExisting = await existingUser(userId, organization);

View File

@@ -17,7 +17,7 @@ interface RoleFilter {
}
export const TrashDatas = async (data: IOrg) => {
try {
const { organization, role, userId } = data;
const { organization, userId } = data;
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
const UserExists = await existingUser(userId, organization);
@@ -56,7 +56,7 @@ export const TrashDatas = async (data: IOrg) => {
};
export const RestoreTrashData = async (data: IRestore) => {
try {
const { projectId, organization, role, userId } = data;
const { projectId, organization, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
let filter = { isArchive: true, _id: projectId } as RoleFilter;

View File

@@ -171,13 +171,13 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
try {
const { organization, floatWidgetID, zoneId, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
if (!UserExists) { return { status: "User not found" } }
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) return { status: "Project not found" };
if (!LivingProject) { return { status: "Project not found" } }
const existingZone = await zoneModel(organization).findOne({
zoneId: zoneId,
isArchive: false,
@@ -224,13 +224,13 @@ export const DuplicateFloat = async (
try {
const { organization, widget, zoneId, index, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
if (!UserExists) {return { status: "User not found" }};
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) return { status: "Project not found" };
if (!LivingProject) {return { status: "Project not found" }};
const existingZone = await zoneModel(organization).findOne({
zoneId: zoneId,
isArchive: false,
@@ -332,13 +332,13 @@ export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
try {
const { organization, zoneId, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
if (!UserExists) {return { status: "User not found" }}
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) return { status: "Project not found" };
if (!LivingProject) {return { status: "Project not found" }};
const existingZone = await zoneModel(organization).findOne({
zoneId: zoneId,
isArchive: false,
@@ -388,7 +388,7 @@ export const SingleFloatWidget = async (
const { organization, floatWidgetID, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const widgetData = await floatWidgetModel(organization)
.findOne({
floatWidgetID: floatWidgetID,

View File

@@ -88,7 +88,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
if (!zoneAndPanelData) {
return zoneAndPanelData;
}
return { status: "Success", data: zoneAndPanelData };
return { status: "Success", data: createdPanels };
} catch (error: unknown) {
if (error instanceof Error) {
return {

View File

@@ -47,13 +47,13 @@ export const AddTemplate = async (data: IAddTemplate): Promise<IResult> => {
try {
const { organization, template, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
if (!UserExists) {return { status: "User not found" }};
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) return { status: "Project not found" };
if (!LivingProject) {return { status: "Project not found" }};
const existingTemplate = await templateModel(organization).findOne({
templateID: template.id,
isArchive: false,

View File

@@ -16,7 +16,6 @@ export default async function mongoAdminCreation() {
.findOne({ user: user.user });
if (userExists) {
console.log(`User ${user} already exists`);
return;
}