Latest Project, Trash and setting API and sockets along with the Model clearance

This commit is contained in:
2025-05-17 10:12:18 +05:30
parent c64e5ea8b5
commit 0b30a8aeaa
66 changed files with 1109 additions and 2351 deletions

View File

@@ -1,57 +1,35 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose.ts';
import { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface floorItenms extends Document {
export interface FloorItems extends Document {
modelUuid: string;
modelfileID: string;
modelName: string
isLocked:boolean
isVisible:boolean
position: []
modelName: string;
isLocked: boolean;
isVisible: boolean;
position: [];
rotation: {
x: number;
y: number;
z: number;
};
}
// Define the Mongoose Schema
const floorItemsSchema: Schema = new Schema({
modelUuid: { type: String },
modelfileID: { type: String },
modelName: { type: String },
position: { type: Array},
isLocked:{type:Boolean},
isVisible:{type:Boolean},
position: { type: Array },
isLocked: { type: Boolean },
isVisible: { type: Boolean },
rotation: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true }
}
z: { type: Number, required: true },
},
});
// Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel;
// const floorItemsModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set');
// }
// // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000,
// });
// return dbConnection.model<floorItenms>('floorItenms', floorItenmsSchema,`floorItenms`);
// }
// export default floorItemsModel;
const floorItemsModel = (db:string) => {
return MainModel(db, "floorItems", floorItemsSchema, "floorItems")
const floorItemsModel = (db: string) => {
return MainModel(db, "floorItems", floorItemsSchema, "floorItems");
};
export default floorItemsModel;
export default floorItemsModel;

View File

@@ -1,48 +0,0 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface wallitems extends Document {
modelUuid: string;
modelName: string
modelfileID: string;
type: string
csgposition: []
csgscale: []
position: []
quaternion: []
scale: []
}
// Define the Mongoose Schema
const wallItemsSchema: Schema = new Schema({
modelUuid: { type: String},
modelfileID: { type: String},
modelName: { type: String},
type: { type: String },
csgposition: { type: Array},
csgscale: { type: Array,},
position: { type: Array },
quaternion: { type: Array},
scale: { type: Array}
});
// const wallItenmModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set');
// }
// // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000,
// });
// return dbConnection.model<wallitenms>('wallitenms', wallItenmsSchema, `wallitenms`);
// }
// export default wallItenmModel;
const wallItenmModel = (db:string) => {
return MainModel(db, "wallitems", wallItemsSchema, "wallitems")
};
export default wallItenmModel;

View File

@@ -1,4 +1,4 @@
import mongoose, { Document, Schema } from "mongoose";
import { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
interface ICommonBase {
@@ -18,7 +18,7 @@ interface IPoint extends ICommonBase {
rotation: [number, number, number];
};
}
export interface assetData extends Document {
export interface AssetData extends Document {
modelUuid: string;
modelfileID: string;
modelName: string;
@@ -43,7 +43,6 @@ const assetDataSchema: Schema = new Schema({
modelfileID: { type: String },
modelName: { type: String },
type: { type: String },
// points: { type: Schema.Types.Mixed },
position: { type: Array },
rotation: {
x: { type: Number },
@@ -58,101 +57,7 @@ const assetDataSchema: Schema = new Schema({
},
});
// export default floorItemsModel;
const assetModel = (db: string) => {
return MainModel(db, "Assets", assetDataSchema, "Assets");
};
export default assetModel;
// import mongoose, { Document, Schema } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// export interface assetData extends Document {
// modelUuid: string;
// modelfileID: string;
// modelName: string;
// isLocked: boolean;
// type: string;
// isVisible: boolean;
// isArchive: false;
// // position: [];
// // rotation: {
// // x: number;
// // y: number;
// // z: number;
// // };
// points: {
// uuid: string;
// position: [];
// rotation: [];
// actions: [mongoose.Types.ObjectId];
// triggers: [mongoose.Types.ObjectId];
// connections: {
// source: {
// modelUUID: string;
// pointUUID: string;
// };
// targets: [
// {
// modelUUID: string;
// pointUUID: string;
// }
// ];
// }[];
// }[];
// position: [];
// // rotation: [];
// rotation: {
// x: number;
// y: number;
// z: number;
// };
// speed: number | string;
// }
// // Define the Mongoose Schema
// const assetDataSchema: Schema = new Schema({
// isArchive: { type: Boolean, default: false },
// modelUuid: { type: String },
// modelfileID: { type: String },
// modelName: { type: String },
// type: { type: String },
// // assetPosition: { type: Array },
// points: [
// {
// uuid: { type: String },
// position: { type: Array },
// rotation: { type: Array },
// actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
// triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
// connections: {
// source: {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// targets: [
// {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// ],
// },
// },
// ],
// position: { type: Array },
// // rotation: { type: Array},
// rotation: {
// x: { type: Number },
// y: { type: Number },
// z: { type: Number },
// },
// speed: { type: Schema.Types.Mixed },
// isLocked: { type: Boolean },
// isVisible: { type: Boolean },
// });
// // export default floorItemsModel;
// const assetModel = (db: string) => {
// return MainModel(db, "Assets", assetDataSchema, "Assets");
// };
// export default assetModel;

View File

@@ -1,31 +1,6 @@
import mongoose, { Schema, Document } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
// Common Interfaces
// interface ITriggerConveyor {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// bufferTime: number;
// }
// interface ITriggerVehicle {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// }
// interface IConnectionConveyor {
// source: { modelUUID: string; pointUUID: string };
// targets: { modelUUID: string; pointUUID: string }[];
// }
// interface IConnectionVehicle {
// source: { modelUUID: string; pointUUID: string };
// targets: { modelUUID: string; pointUUID: string }[];
// }
// Point Types
interface IPointBase {
uuid: string;
position: number[];
@@ -127,322 +102,8 @@ const PointSchema = new Schema<IPointModel>(
{ timestamps: true }
);
// Model Creation
const pointModel = (db: string) => {
return MainModel(db, "Points", PointSchema, "Points");
};
export default pointModel;
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// import mongoose, { Schema, Document } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// interface IActionConveyor {
// uuid: string;
// name: string;
// type: string;
// material: string;
// delay: number | string;
// spawnInterval: number | string;
// spawnMaterial: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// interface ITriggers {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// bufferTime: number;
// }
// interface IConnection {
// source: { modelUUID: string; pointUUID: string };
// targets: { modelUUID: string; pointUUID: string }[];
// }
// interface IActionVehicle {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// interface IPointConveyor {
// uuid: string;
// position: number[];
// rotation: number[];
// actions: IActionConveyor[];
// triggers: ITriggers[];
// connections: IConnection;
// }
// interface IPointVehicle {
// uuid: string;
// position: number[];
// actions: IActionVehicle[];
// triggers: ITriggers[];
// connections: IConnection;
// }
// interface IBaseModel extends Document {
// modelfileID: string;
// type: "Conveyor" | "Vehicle";
// points: IPointConveyor[] | IPointVehicle;
// }
// const PointconveyorSchema = new Schema<IPointConveyor>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// rotation: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// material: { type: String },
// delay: { type: Schema.Types.Mixed },
// spawnInterval: { type: Schema.Types.Mixed },
// spawnMaterial: { type: String },
// isUsed: { type: Boolean },
// },
// ],
// triggers: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// bufferTime: { type: Number },
// isUsed: { type: Boolean },
// },
// ],
// connections: {
// source: {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// targets: [
// {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// ],
// },
// });
// const PointvehicleSchema = new Schema<IPointVehicle>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// isUsed: { type: Boolean },
// hitCount: { type: String },
// start: { type: String },
// end: { type: String },
// buffer: { type: String },
// },
// ],
// triggers: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// bufferTime: { type: Number },
// isUsed: { type: Boolean },
// },
// ],
// connections: {
// source: {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// targets: [
// {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// ],
// },
// });
// const BaseSchema = new Schema<IBaseModel>(
// {
// modelfileID: { type: String },
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
// points: {
// type: Schema.Types.Mixed,
// required: true,
// },
// },
// { discriminatorKey: "type", timestamps: true }
// );
// const pointModel = (db: string) => {
// const BasePointModel = MainModel(db, "Points", BaseSchema, "Points");
// const ConveyorModel = BasePointModel.discriminator(
// "Conveyor",
// new Schema({
// points: [PointconveyorSchema],
// })
// );
// const VehicleModel = BasePointModel.discriminator(
// "Vehicle",
// new Schema({
// points: PointvehicleSchema,
// })
// );
// return { ConveyorModel, VehicleModel };
// };
// export default pointModel;
// ===
// const pointModel = (db: string) => {
// const BasePointModel =
// mongoose.models.Points || MainModel(db, "Points", BaseSchema, "Points");
// if (!BasePointModel.discriminators?.Conveyor) {
// BasePointModel.discriminator(
// "Conveyor",
// new Schema({
// points: [PointconveyorSchema],
// })
// );
// }
// if (!BasePointModel.discriminators?.Vehicle) {
// BasePointModel.discriminator(
// "Vehicle",
// new Schema({
// points: PointvehicleSchema,
// })
// );
// }
// const ConveyorModel =
// mongoose.models.Conveyor || BasePointModel.discriminators?.Conveyor;
// const VehicleModel =
// mongoose.models.Vehicle || BasePointModel.discriminators?.Vehicle;
// return { ConveyorModel, VehicleModel, BasePointModel };
// };
// export default pointModel;
// ===========================================
// ===
// import mongoose, { Schema, Document } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// interface IAction {
// uuid: string;
// name: string;
// type: string;
// material: string;
// delay: number | string;
// spawnInterval: number | string;
// spawnMaterial: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// interface ITriggers {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// bufferTime: number;
// }
// interface IConnection {
// source: { modelUUID: string; pointUUID: string };
// targets: { modelUUID: string; pointUUID: string }[];
// }
// interface IPoint {
// uuid: string;
// position: number[];
// rotation: number[];
// actions: IAction[];
// triggers: ITriggers[];
// connections: IConnection;
// }
// interface IBaseModel extends Document {
// modelfileID: string;
// type: "Conveyor" | "Vehicle";
// points: IPoint[] | IPoint;
// }
// const PointSchema = new Schema<IPoint>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// rotation: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// material: { type: String },
// delay: { type: String },
// spawnInterval: { type: String },
// spawnMaterial: { type: String },
// isUsed: { type: Boolean },
// hitCount: { type: String },
// start: { type: String },
// end: { type: String },
// buffer: { type: String },
// },
// ],
// triggers: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// bufferTime: { type: Number },
// isUsed: { type: Boolean },
// },
// ],
// connections: {
// source: {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// targets: [
// {
// modelUUID: { type: String },
// pointUUID: { type: String },
// },
// ],
// },
// });
// // Base Schema
// const BaseSchema = new Schema<IBaseModel>(
// {
// modelfileID: { type: String },
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
// points: {
// type: Schema.Types.Mixed,
// required: true,
// },
// },
// { discriminatorKey: "type", timestamps: true }
// );
// const pointModel = (db: string) => {
// return MainModel(db, "Points", BaseSchema, "Points");
// };
// export default pointModel;

View File

@@ -1,7 +1,6 @@
import mongoose, { Document, Schema } from "mongoose";
import { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface wallitems extends Document {
export interface WallItems extends Document {
modelUuid: string;
modelName: string;
type: string;
@@ -12,7 +11,6 @@ export interface wallitems extends Document {
scale: [];
}
// Define the Mongoose Schema
const wallItemsSchema: Schema = new Schema({
modelUuid: { type: String, unique: true },
modelName: { type: String },
@@ -24,8 +22,7 @@ const wallItemsSchema: Schema = new Schema({
scale: { type: Array },
});
// export default wallItenmModel;
const wallItenmModel = (db: string) => {
const wallItemModel = (db: string) => {
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
};
export default wallItenmModel;
export default wallItemModel;

View File

@@ -1,7 +1,6 @@
import mongoose, { Document, Schema } from "mongoose";
import { Document, Schema } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface Camera extends Document {
userId: string;
position: {
@@ -21,7 +20,6 @@ export interface Camera extends Document {
};
}
// Define the Mongoose Schema
const cameraSchema: Schema = new Schema({
userId: { type: String },
position: {
@@ -41,7 +39,6 @@ const cameraSchema: Schema = new Schema({
},
});
// export default cameraModel
const cameraModel = (db: string) => {
return MainModel(db, "Camera", cameraSchema, "Camera");
};

View File

@@ -1,24 +0,0 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../../connect/mongoose.ts';
// Interface for TypeScript with PascalCase
export interface environment extends Document {
userId: string;
roofVisibility: boolean
wallVisibility: boolean
}
// Define the Mongoose Schema
const environmentSchema: Schema = new Schema({
userId: { type: String, unique: true },
roofVisibility: { type: Boolean, default: false },
wallVisibility: { type: Boolean, default: false },
shadowVisibility: { type: Boolean, default: false },
});
// export default environmentModel;
const environmentModel = (db: string) => {
return MainModel(db, "environments", environmentSchema, "environments")
};
export default environmentModel;

View File

@@ -1,4 +1,4 @@
import mongoose, { Document, Schema } from "mongoose";
import mongoose from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
const positionSchema = new mongoose.Schema({
x: { type: Number }, // Optional position fields
@@ -6,20 +6,17 @@ const positionSchema = new mongoose.Schema({
z: { type: Number },
});
// Define a schema for the individual line
const Vector3 = new mongoose.Schema({
position: { type: positionSchema, required: false }, // Optional position
uuid: { type: String, required: false }, // Optional uuid
});
// Define the main schema
const LineSchema = new mongoose.Schema({
layer: { type: Number, required: true }, // Layer is mandatory
line: { type: [Vector3], required: true }, // Array of line objects
type: { type: String, required: false }, // Optional type
});
// export default lineModel;
const lineModel = (db: string) => {
return MainModel(db, "lines", LineSchema, "lines");
};

View File

@@ -1,40 +1,5 @@
// import mongoose, { Schema, Document, model } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// export interface Zone extends Document {
// zoneName: string;
// // zoneUUID: string;
// zonePoints: [];
// centerPoints: [];
// isArchive: boolean;
// createdBy: string;
// sceneID: string;
// // createdBy: mongoose.Types.ObjectId;
// // sceneID: mongoose.Types.ObjectId;
// layer: number;
// }
// const zoneSchema: Schema = new Schema(
// {
// zoneName: { type: String },
// // zoneUUID: { type: String },
// createdBy: { type: String },
// sceneID: { type: String },
// layer: { type: Number },
// centerPoints: { type: Array },
// zonePoints: { type: Array },
// isArchive: { type: Boolean, default: false },
// // createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
// // sceneID: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
// },
// { timestamps: true }
// );
// const dataModel = (db: any) => {
// return MainModel(db, "Zones", zoneSchema, "Zones");
// };
// export default dataModel;
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
export interface Zone extends Document {

View File

@@ -1,87 +1,45 @@
import mongoose, { Document, Schema } from 'mongoose';
import MainModel from '../../connect/mongoose.ts';
import { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface Camera extends Document {
userId: string;
position: {
x: number;
y: number;
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 };
};
}
// Define the Mongoose Schema
const cameraSchema: Schema = new Schema({
userId: { type: String },
position: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true }
z: { type: Number, required: true },
},
target: {
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { 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 }
}
z: { type: Number, required: true },
},
});
// Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel;
// const cameraModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set');
// }
// // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000,
// });
// return dbConnection.model<Camera>('Camera', cameraSchema,`Camera`);
// }
// export default cameraModel;
// const cameraModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set');
// }
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db,
// serverSelectionTimeoutMS: 60000, // Increased timeout
// });
// dbConnection.on('error', (err) => {
// console.error(`MongoDB connection error for database ${db}:`, err);
// });
// dbConnection.once('open', () => {
// console.log(`Connected to MongoDB database: ${db}`);
// });
// return dbConnection.model<Camera>('Camera', cameraSchema, 'Camera');
// };
// export default cameraModel
const cameraModel = (db:string) => {
return MainModel(db, "Camera", cameraSchema, "Camera")
const cameraModel = (db: string) => {
return MainModel(db, "Camera", cameraSchema, "Camera");
};
export default cameraModel;
export default cameraModel;

View File

@@ -1,7 +1,7 @@
import mongoose, { Document, Schema } from "mongoose";
import { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
// Interface for TypeScript with PascalCase
export interface environment extends Document {
export interface Environment extends Document {
userId: string;
roofVisibility: boolean;
wallVisibility: boolean;
@@ -10,7 +10,6 @@ export interface environment extends Document {
limitDistance: boolean;
}
// Define the Mongoose Schema
const environmentSchema: Schema = new Schema({
userId: { type: String, unique: true },
roofVisibility: { type: Boolean, default: false },
@@ -20,24 +19,6 @@ const environmentSchema: Schema = new Schema({
limitDistance: { type: Boolean, default: true },
});
// Model for MongoDB collection
// const cameraModel = model<Camera>("Camera", cameraSchema);
// export default cameraModel;
// const environmentModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || '';
// if (!mongoUrl) {
// throw new Error('MONGO_URI environment variable is not set');
// }
// // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000,
// });
// return dbConnection.model<environment>('environments', environmentSchema,`environments`);
// }
// export default environmentModel;
const environmentModel = (db: string) => {
return MainModel(db, "environments", environmentSchema, "environments");
};

View File

@@ -18,7 +18,7 @@ export interface Project extends Document {
const projectSchema: Schema = new Schema(
{
projectUuid: { type: String },
projectName: { type: String },
projectName: { type: String },
thumbnail: { type: String },
isArchive: { type: Boolean, default: false },
createdBy: { type: Schema.Types.ObjectId, ref: "user" },

View File

@@ -1,12 +1,9 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Action extends Document {
pointsUUID: string;
// actionUUID: string;
isArchive: string;
// sceneID: string;
// eventData: {
uuid: string;
name: string;
type: string;
@@ -19,13 +16,11 @@ export interface Action extends Document {
start: string;
end: string;
buffer: number;
// };
}
const actionSchema: Schema = new Schema(
{
pointsUUID: { type: String },
isArchive: { type: Boolean, default: false },
// actionUUID: { type: String },
uuid: { type: String, default: "" },
name: { type: String },
type: { type: String },

View File

@@ -1,179 +1,182 @@
// models/Product.ts
import mongoose, { Schema, Document, Types } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
interface AssetEventSchema {
modelUuid: string;
modelName: string;
position: [number, number, number];
rotation: [number, number, number];
state: "idle" | "running" | "stopped" | "disabled" | "error";
};
modelUuid: string;
modelName: string;
position: [number, number, number];
rotation: [number, number, number];
state: "idle" | "running" | "stopped" | "disabled" | "error";
}
interface TriggerSchema {
triggerUuid: string;
triggerName: string;
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
delay: number;
triggeredAsset: {
triggeredModel: { modelName: string, modelUuid: string };
triggeredPoint: { pointName: string, pointUuid: string };
triggeredAction: { actionName: string, actionUuid: string };
} | null;
triggerUuid: string;
triggerName: string;
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
delay: number;
triggeredAsset: {
triggeredModel: { modelName: string; modelUuid: string };
triggeredPoint: { pointName: string; pointUuid: string };
triggeredAction: { actionName: string; actionUuid: string };
} | null;
}
interface ConveyorPointSchema {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "default" | "spawn" | "swap" | "despawn";
material: string;
delay: number | "inherit";
spawnInterval: number | "inherit";
spawnCount: number | "inherit";
triggers: TriggerSchema[];
};
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "default" | "spawn" | "swap" | "despawn";
material: string;
delay: number | "inherit";
spawnInterval: number | "inherit";
spawnCount: number | "inherit";
triggers: TriggerSchema[];
};
}
interface VehiclePointSchema {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "travel";
material: string | null;
unLoadDuration: number;
loadCapacity: number;
pickUpPoint: { x: number; y: number, z: number } | null;
unLoadPoint: { x: number; y: number, z: number } | null;
triggers: TriggerSchema[];
};
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "travel";
material: string | null;
unLoadDuration: number;
loadCapacity: number;
pickUpPoint: { x: number; y: number; z: number } | null;
unLoadPoint: { x: number; y: number; z: number } | null;
triggers: TriggerSchema[];
};
}
interface RoboticArmPointSchema {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
actions: {
actionUuid: string;
actionName: string;
actionType: "pickAndPlace";
process: { startPoint: [number, number, number]; endPoint: [number, number, number] };
triggers: TriggerSchema[];
}[];
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
actions: {
actionUuid: string;
actionName: string;
actionType: "pickAndPlace";
process: {
startPoint: [number, number, number];
endPoint: [number, number, number];
};
triggers: TriggerSchema[];
}[];
}
interface MachinePointSchema {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "process";
processTime: number;
swapMaterial: string;
triggers: TriggerSchema[];
};
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "process";
processTime: number;
swapMaterial: string;
triggers: TriggerSchema[];
};
}
interface StoragePointSchema {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "storage";
materials: { materialName: string; materialId: string; }[];
storageCapacity: number;
};
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
action: {
actionUuid: string;
actionName: string;
actionType: "storage";
materials: { materialName: string; materialId: string }[];
storageCapacity: number;
};
}
interface ConveyorEventSchema extends AssetEventSchema {
type: "transfer";
speed: number;
points: ConveyorPointSchema[];
type: "transfer";
speed: number;
points: ConveyorPointSchema[];
}
interface VehicleEventSchema extends AssetEventSchema {
type: "vehicle";
speed: number;
point: VehiclePointSchema;
type: "vehicle";
speed: number;
point: VehiclePointSchema;
}
interface RoboticArmEventSchema extends AssetEventSchema {
type: "roboticArm";
speed: number;
point: RoboticArmPointSchema;
type: "roboticArm";
speed: number;
point: RoboticArmPointSchema;
}
interface MachineEventSchema extends AssetEventSchema {
type: "machine";
// speed: number;
point: MachinePointSchema;
type: "machine";
// speed: number;
point: MachinePointSchema;
}
interface StorageEventSchema extends AssetEventSchema {
type: "storageUnit";
// speed: number;
point: StoragePointSchema;
type: "storageUnit";
// speed: number;
point: StoragePointSchema;
}
interface IPointModel extends Document {
modelUuid:String,
modelName:String,
position:String,
rotation:String,
state:String,
productId:String,
isArchive:boolean,
type: "transfer" | "vehicle" | "roboticArm" | "machine" |"storageUnit";
modelUuid: String;
modelName: String;
position: String;
rotation: String;
state: String;
productId: String;
isArchive: boolean;
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
speed: number;
point: VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema
points: ConveyorEventSchema[]
point:
| VehicleEventSchema
| RoboticArmEventSchema
| MachineEventSchema
| StorageEventSchema;
points: ConveyorEventSchema[];
}
// type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;
const BaseEventSchema = new Schema<IPointModel>(
{
modelUuid: { type: String, required: true },
modelName: { type: String, required: true },
position: { type: [Number], required: true },
rotation: { type: [Number], required: true },
speed: { type: Number,},
state: {
type: String,
enum: ["idle", "running", "stopped", "disabled", "error"],
default: "idle"
},
type: {
type: String,
required: true,
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"]
},
point:{
type:Schema.Types.Mixed,
},
points:{
type:Schema.Types.Mixed,
},
productId: { type:String,required: true },
isArchive: { type: Boolean, default: false }
{
modelUuid: { type: String, required: true },
modelName: { type: String, required: true },
position: { type: [Number], required: true },
rotation: { type: [Number], required: true },
speed: { type: Number },
state: {
type: String,
enum: ["idle", "running", "stopped", "disabled", "error"],
default: "idle",
},
{ discriminatorKey: "type", timestamps: true }
);
const EventsDataModel = (db: string) => {
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
};
export default EventsDataModel;
type: {
type: String,
required: true,
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
},
point: {
type: Schema.Types.Mixed,
},
points: {
type: Schema.Types.Mixed,
},
productId: { type: String, required: true },
isArchive: { type: Boolean, default: false },
},
{ discriminatorKey: "type", timestamps: true }
);
const EventsDataModel = (db: string) => {
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
};
export default EventsDataModel;

View File

@@ -1,97 +0,0 @@
// import mongoose, { Schema, Document, model } from "mongoose";
// import MainModel from "../../connect/mongoose.ts";
// export interface ProductFlow extends Document {
// productName: string;
// ProductData: [
// {
// AssetName: string;
// Assetuuid: string;
// paths: {
// Points: [
// {
// pointuuid: string;
// actions: [mongoose.Types.ObjectId];
// triggers: [mongoose.Types.ObjectId];
// position: [];
// rotation: [number];
// connections: {
// source: {
// // modelUUID: { type: String };
// pointUUID: string;
// };
// targets: [
// {
// // modelUUID: { type: String };
// pointUUID: string;
// }
// ];
// };
// }
// ];
// // endPoint: {
// // pointuuid: string;
// // actions: [mongoose.Types.ObjectId];
// // triggers: [mongoose.Types.ObjectId];
// // position: [];
// // rotation: [];
// // };
// };
// isArchive: false;
// }
// ];
// isArchive: false;
// }
// const productFlowSchema: Schema = new Schema(
// {
// productName: { type: String },
// ProductData: [
// {
// AssetName: { type: String },
// Assetuuid: { type: String },
// paths: {
// Points: [
// {
// pointuuid: { type: String },
// actions: [
// { type: mongoose.Schema.Types.ObjectId, ref: "Actions" },
// ],
// triggers: [
// { type: mongoose.Schema.Types.ObjectId, ref: "Triggers" },
// ],
// connections: {
// source: {
// // modelUUID: { type: String };
// pointUUID: { type: String },
// },
// targets: [
// {
// // modelUUID: { type: String };
// pointUUID: { type: String },
// },
// ],
// },
// position: { type: Array },
// rotation: {
// type: [Number],
// validate: {
// validator: function (value: number[]) {
// return value && value.length > 0; // Ensures it's only stored if it has values
// },
// message: "Rotation array should not be empty",
// },
// },
// },
// ],
// },
// isArchive: { type: Boolean, default: false },
// },
// ],
// },
// { timestamps: true }
// );
// const productFlowModel = (db: any) => {
// return MainModel(db, "ProductFlow", productFlowSchema, "ProductFlow");
// };
// export default productFlowModel;

View File

@@ -1,24 +1,20 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface product extends Document {
export interface Product extends Document {
productName: string;
productId: string;
eventsData: [];
isArchive: boolean;
}
// Product Schema
const ProductSchema = new Schema({
productName: { type: String, required: true },
productId: { type: String, required: true },
isArchive: { type: Boolean, default: false },
});
const ProductModel = (db: string) => {
return MainModel(db, "Product", ProductSchema, "Product");
};
export default ProductModel;
export default ProductModel;

View File

@@ -1,4 +1,4 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Trigger extends Document {

View File

@@ -1,4 +1,4 @@
import mongoose, { Document, Schema } from "mongoose";
import { Document, Schema } from "mongoose";
import MainModel from "../connect/mongoose.ts";
export interface User extends Document {
userName: String;
@@ -48,24 +48,8 @@ const signupschema: Schema = new Schema({
default: [],
},
});
// const userModel = (db: string) => {
// const mongoUrl = process.env.MONGO_URI || "";
// if (!mongoUrl) {
// throw new Error("MONGO_URI environment variable is not set");
// }
// // Connect to the database
// const dbConnection = mongoose.createConnection(mongoUrl, {
// dbName: db, // Specify the database name here
// serverSelectionTimeoutMS: 30000,
// });
// // Return the model
// return dbConnection.model("Users", signupschema, "Users");
// };
// export default userModel;
const userModel = (db: string) => {
return MainModel(db, "Users", signupschema, "Users");
const userModel = (db:string) => {
return MainModel(db, "Users", signupschema, "Users")
};
export default userModel;

View File

@@ -1,4 +1,4 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Widget3d extends Document {

View File

@@ -1,7 +1,7 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document, model } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface floatingWidget extends Document {
export interface FloatingWidget extends Document {
className: string;
iconName: string;
header: string;

View File

@@ -1,8 +1,7 @@
import mongoose, { Schema, Document, model } from "mongoose";
import mongoose, { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Panel extends Document {
// zoneId: mongoose.Types.ObjectId;
zoneId: string;
panelName: string;
widgets: [mongoose.Types.ObjectId];
@@ -10,7 +9,6 @@ export interface Panel extends Document {
}
const panelSchema: Schema = new Schema(
{
// zoneId: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
zoneId: { type: String },
panelName: { type: String },
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],

View File

@@ -1,4 +1,4 @@
import mongoose, { Schema, Document, model } from "mongoose";
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface Template extends Document {

View File

@@ -1,4 +1,4 @@
import mongoose, { Schema, Document, model } from "mongoose";
import mongoose, { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface widget extends Document {

View File

@@ -1,6 +1,5 @@
import projectModel from "../../model/project/project-model.ts";
import userModel from "../../model/user-Model.ts";
import { Types } from "mongoose";
import versionModel from "../../model/version/versionModel.ts";
import {
existingProject,

View File

@@ -0,0 +1,115 @@
import { Request, Response } from "express";
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
interface IWallSetupData {
modelUuid: string;
modelName: string;
type: string;
csgposition: [];
csgscale: [];
position: [];
quaternion: [];
scale: [];
organization: string;
}
interface IWallItemResult {
data: {};
state: string;
}
export class WallItems {
static async setWallItems(data: IWallSetupData): Promise<IWallItemResult> {
try {
const {
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
organization,
} = data;
const findvalue = await wallItemModel(organization).findOne({
modelUuid: modelUuid,
});
if (findvalue) {
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
{ modelUuid: modelUuid },
{
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
},
{ new: true } // Return the updated document
);
return {
state: "Updated successfully",
data: updatevalue,
};
// res.status(201).json(updatevalue);
} else {
const newValue = await wallItemModel(organization).create({
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
});
return {
state: "wall Item created successfully",
data: newValue,
};
// res.status(201).json(newValue);
}
// Send response with the created document
} catch (error:unknown) {
const err = error as Error;
console.error("Error creating wallitems:", error);
return { state: "Failed to create wallitems", data: { message: err.message } };
// return { state: "Failed to create wallitems", data: error } };
// res.status(500).json({ message: "Failed to create wallitems" });
}
}
static async getWallItems(req: Request, res: Response) {
try {
const { organization } = req.params;
const findValue = await wallItemModel(organization).find();
if (!findValue) {
res.status(200).json("wallitems not found");
} else {
res.status(201).json(findValue);
}
} catch (error) {
console.error("Error get wallitems:", error);
res.status(500).json({ error: "Failed to get wallitems" });
}
}
static async deleteWallItems(req: Request, res: Response) {
try {
const { modelUuid, modelName, organization } = req.body;
const findValue = await wallItemModel(organization).findOneAndDelete({
modelUuid: modelUuid,
modelName: modelName,
});
if (!findValue) {
res.status(200).json("user not found");
} else {
res.status(201).json(findValue);
}
} catch (error) {
console.error("Error get wallitems:", error);
res.status(500).json({ error: "Failed to get wallitems" });
}
}
}