zoneModel updated Structure modified for the API
This commit is contained in:
parent
7a67405d2a
commit
7555eb5c9c
|
@ -0,0 +1,6 @@
|
||||||
|
LOCAL_MONGO_URI=mongodb://127.0.0.1:27017/
|
||||||
|
MONGO_USER=adminForever
|
||||||
|
MONGO_PASSWORD=Pass@2025@admin
|
||||||
|
DOCKER_MONGO_URI=mongodb://mongo/
|
||||||
|
JWT_SECRET=your_jwt_secret
|
||||||
|
PORT=2001
|
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "dwinzo-beta-backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "nodemon --exec tsx src/API/main.ts"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^16.4.7",
|
||||||
|
"express": "^4.21.2",
|
||||||
|
"mongoose": "^8.13.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/cors": "^2.8.17",
|
||||||
|
"@types/express": "^5.0.1",
|
||||||
|
"@types/node": "^22.13.13",
|
||||||
|
"nodemon": "^3.1.9",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"typescript": "^5.8.2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import express from "express";
|
||||||
|
import cors from "cors";
|
||||||
|
import zoneRouter from "../API/routes/zoneRoutes.ts";
|
||||||
|
const app = express();
|
||||||
|
app.use("/api/v1", zoneRouter);
|
||||||
|
export default app;
|
|
@ -0,0 +1,11 @@
|
||||||
|
import express from "express";
|
||||||
|
import cors from "cors";
|
||||||
|
import approutes from "./app.ts";
|
||||||
|
const app = express();
|
||||||
|
app.use(express.json());
|
||||||
|
app.use(approutes);
|
||||||
|
app.use(cors());
|
||||||
|
const port = 2000;
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Server is running in the port ${port}`);
|
||||||
|
});
|
|
@ -0,0 +1,6 @@
|
||||||
|
import * as express from "express";
|
||||||
|
import { Zoneservice } from "../service/zoneService.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/zonecreate", Zoneservice.addandUpdateZone); //Zone create and update for the points
|
||||||
|
//archive all the zones based on the sceneID
|
||||||
|
export default router;
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
import zoneSchema from "../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
export class Zoneservice {
|
||||||
|
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
||||||
|
const organization = req.body.organization;
|
||||||
|
console.log("organization: ", organization);
|
||||||
|
const zoneDatas = req.body.zonesdata;
|
||||||
|
console.log("zoneDatas: ", zoneDatas);
|
||||||
|
try {
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
_id: zoneDatas.zoneID,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone) {
|
||||||
|
const newZone = await zoneSchema(organization).create({
|
||||||
|
zoneName: zoneDatas.zonename,
|
||||||
|
// zoneUUID: zoneDatas.uuid,
|
||||||
|
zonePoints: zoneDatas.points,
|
||||||
|
centerPoints: zoneDatas.centerPoints,
|
||||||
|
createdBy: zoneDatas.userid,
|
||||||
|
sceneID: zoneDatas.sceneid,
|
||||||
|
});
|
||||||
|
if (newZone)
|
||||||
|
return res.send({
|
||||||
|
message: "Zone created successfully",
|
||||||
|
zoneData: {
|
||||||
|
zoneName: newZone.zoneName,
|
||||||
|
points: newZone.zonePoints,
|
||||||
|
centerPoints: newZone.centerPoints,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
|
||||||
|
{ _id: zoneDatas.zoneID, isArchive: false },
|
||||||
|
{
|
||||||
|
zonePoints: zoneDatas.zonePoints,
|
||||||
|
centerPoints: zoneDatas.centerPoints,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
if (!replaceZone) return res.send({ message: "Zone not updated" });
|
||||||
|
else
|
||||||
|
return res.send({
|
||||||
|
message: "updated successfully",
|
||||||
|
zoneData: {
|
||||||
|
zoneName: replaceZone.zoneName,
|
||||||
|
points: replaceZone.zonePoints,
|
||||||
|
centerPoints: replaceZone.centerPoints,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
import mongoose, { Schema, Connection, Model } from "mongoose";
|
import mongoose, { Schema, Connection, Model } from "mongoose";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
interface ConnectionCache {
|
interface ConnectionCache {
|
||||||
[key: string]: Connection;
|
[key: string]: Connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const connections: ConnectionCache = {};
|
const connections: ConnectionCache = {};
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
const MainModel = <T>(
|
const MainModel = <T>(
|
||||||
db: string,
|
db: string,
|
||||||
|
@ -12,11 +13,11 @@ const MainModel = <T>(
|
||||||
schema: Schema<T>,
|
schema: Schema<T>,
|
||||||
collectionName: string
|
collectionName: string
|
||||||
): Model<T> => {
|
): Model<T> => {
|
||||||
const db1_url = `${process.env.MONGO_URI}${db}`;
|
const db1_url = `${process.env.LOCAL_MONGO_URI}${db}`;
|
||||||
const authOptions = {
|
const authOptions = {
|
||||||
user: process.env.MONGO_USER, // Correct username environment variable
|
user: process.env.MONGO_USER,
|
||||||
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
pass: process.env.MONGO_PASSWORD,
|
||||||
authSource: process.env.MONGO_AUTH_DB || 'admin', // Default to 'admin' if not provided
|
authSource: process.env.MONGO_AUTH_DB || "admin",
|
||||||
maxPoolSize: 50,
|
maxPoolSize: 50,
|
||||||
};
|
};
|
||||||
// Check if the connection already exists
|
// Check if the connection already exists
|
||||||
|
@ -30,13 +31,15 @@ const MainModel = <T>(
|
||||||
// Cache the connection
|
// Cache the connection
|
||||||
connections[db] = db1;
|
connections[db] = db1;
|
||||||
|
|
||||||
// Log connection success or handle errors
|
|
||||||
db1.on("connected", () => {
|
db1.on("connected", () => {
|
||||||
console.log(`Connected to MongoDB database: ${db}`);
|
console.log(`Connected to MongoDB database: ${db}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
db1.on("error", (err) => {
|
db1.on("error", (err) => {
|
||||||
console.error(`MongoDB connection error for database ${db}:`, err.message);
|
console.error(
|
||||||
|
`MongoDB connection error for database ${db}:`,
|
||||||
|
err.message
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return db1.model<T>(modelName, schema, collectionName);
|
return db1.model<T>(modelName, schema, collectionName);
|
||||||
|
@ -47,4 +50,3 @@ const MainModel = <T>(
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MainModel;
|
export default MainModel;
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
import mongoose, { Document, Schema } from 'mongoose';
|
|
||||||
import MainModel from '../../connect/mongoose';
|
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface wallitems extends Document {
|
|
||||||
modeluuid: string;
|
|
||||||
modelname: string
|
|
||||||
type: string
|
|
||||||
csgposition: []
|
|
||||||
csgscale: []
|
|
||||||
position: []
|
|
||||||
quaternion: []
|
|
||||||
scale: []
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const wallItemsSchema: Schema = new Schema({
|
|
||||||
modeluuid: { type: String, unique: true },
|
|
||||||
modelname: { type: String },
|
|
||||||
type: { type: String },
|
|
||||||
csgposition: { type: Array },
|
|
||||||
csgscale: { type: Array, },
|
|
||||||
position: { type: Array },
|
|
||||||
quaternion: { type: Array },
|
|
||||||
scale: { type: Array }
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// export default wallItenmModel;
|
|
||||||
const wallItenmModel = (db: string) => {
|
|
||||||
return MainModel(db, "wallitems", wallItemsSchema, "wallitems")
|
|
||||||
};
|
|
||||||
export default wallItenmModel;
|
|
|
@ -1,21 +1,19 @@
|
||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose';
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
// Interface for TypeScript with PascalCase
|
||||||
export interface floorItenms extends Document {
|
export interface floorItenms extends Document {
|
||||||
modeluuid: string;
|
modeluuid: string;
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
modelname: string
|
modelname: string;
|
||||||
isLocked: boolean
|
isLocked: boolean;
|
||||||
isVisible: boolean
|
isVisible: boolean;
|
||||||
position: []
|
position: [];
|
||||||
rotation: {
|
rotation: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
z: number;
|
z: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
|
@ -29,13 +27,12 @@ const floorItemsSchema: Schema = new Schema({
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// export default floorItemsModel;
|
// export default floorItemsModel;
|
||||||
const floorItemsModel = (db: string) => {
|
const floorItemsModel = (db: string) => {
|
||||||
return MainModel(db, "floorItems", floorItemsSchema, "floorItems")
|
return MainModel(db, "floorItems", floorItemsSchema, "floorItems");
|
||||||
};
|
};
|
||||||
export default floorItemsModel;
|
export default floorItemsModel;
|
|
@ -0,0 +1,31 @@
|
||||||
|
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;
|
||||||
|
type: string;
|
||||||
|
csgposition: [];
|
||||||
|
csgscale: [];
|
||||||
|
position: [];
|
||||||
|
quaternion: [];
|
||||||
|
scale: [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define the Mongoose Schema
|
||||||
|
const wallItemsSchema: Schema = new Schema({
|
||||||
|
modeluuid: { type: String, unique: true },
|
||||||
|
modelname: { type: String },
|
||||||
|
type: { type: String },
|
||||||
|
csgposition: { type: Array },
|
||||||
|
csgscale: { type: Array },
|
||||||
|
position: { type: Array },
|
||||||
|
quaternion: { type: Array },
|
||||||
|
scale: { type: Array },
|
||||||
|
});
|
||||||
|
|
||||||
|
// export default wallItenmModel;
|
||||||
|
const wallItenmModel = (db: string) => {
|
||||||
|
return MainModel(db, "wallitems", wallItemsSchema, "wallitems");
|
||||||
|
};
|
||||||
|
export default wallItenmModel;
|
|
@ -1,5 +1,5 @@
|
||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose';
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
// Interface for TypeScript with PascalCase
|
||||||
export interface Camera extends Document {
|
export interface Camera extends Document {
|
||||||
|
@ -8,17 +8,17 @@ export interface Camera extends Document {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
z: number;
|
z: number;
|
||||||
}
|
};
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number; required: true };
|
||||||
y: { type: Number, required: true },
|
y: { type: Number; required: true };
|
||||||
z: { type: Number, required: true }
|
z: { type: Number; required: true };
|
||||||
}
|
};
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number; required: true };
|
||||||
y: { type: Number, required: true },
|
y: { type: Number; required: true };
|
||||||
z: { type: Number, required: true }
|
z: { type: Number; required: true };
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
|
@ -27,23 +27,22 @@ const cameraSchema: Schema = new Schema({
|
||||||
position: {
|
position: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
},
|
},
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
},
|
},
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number, required: true },
|
x: { type: Number, required: true },
|
||||||
y: { type: Number, required: true },
|
y: { type: Number, required: true },
|
||||||
z: { type: Number, required: true }
|
z: { type: Number, required: true },
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// export default cameraModel
|
// export default cameraModel
|
||||||
const cameraModel = (db: string) => {
|
const cameraModel = (db: string) => {
|
||||||
return MainModel(db, "Camera", cameraSchema, "Camera")
|
return MainModel(db, "Camera", cameraSchema, "Camera");
|
||||||
};
|
};
|
||||||
export default cameraModel;
|
export default cameraModel;
|
|
@ -1,5 +1,5 @@
|
||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import mongoose, { Document, Schema } from 'mongoose';
|
||||||
import MainModel from '../../connect/mongoose';
|
import MainModel from '../../../connect/mongoose.ts';
|
||||||
// Interface for TypeScript with PascalCase
|
// Interface for TypeScript with PascalCase
|
||||||
export interface environment extends Document {
|
export interface environment extends Document {
|
||||||
userId: string;
|
userId: string;
|
|
@ -1,8 +1,8 @@
|
||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
const positionSchema = new mongoose.Schema({
|
const positionSchema = new mongoose.Schema({
|
||||||
x: { type: Number, }, // Optional position fields
|
x: { type: Number }, // Optional position fields
|
||||||
y: { type: Number, },
|
y: { type: Number },
|
||||||
z: { type: Number },
|
z: { type: Number },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,10 +19,8 @@ const LineSchema = new mongoose.Schema({
|
||||||
type: { type: String, required: false }, // Optional type
|
type: { type: String, required: false }, // Optional type
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// export default lineModel;
|
// export default lineModel;
|
||||||
const lineModel = (db: string) => {
|
const lineModel = (db: string) => {
|
||||||
return MainModel(db, "lines", LineSchema, "lines")
|
return MainModel(db, "lines", LineSchema, "lines");
|
||||||
};
|
};
|
||||||
export default lineModel;
|
export default lineModel;
|
|
@ -0,0 +1,35 @@
|
||||||
|
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;
|
|
@ -1,26 +0,0 @@
|
||||||
import mongoose, { Document, ObjectId, Schema } from "mongoose";
|
|
||||||
import MainModel from "../../connect/mongoose";
|
|
||||||
export interface zoneSchema extends Document {
|
|
||||||
zoneId: string;
|
|
||||||
zoneName: string
|
|
||||||
createBy: mongoose.Types.ObjectId
|
|
||||||
points: []
|
|
||||||
layer: Number
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
|
||||||
const zoneSchema: Schema = new Schema({
|
|
||||||
zoneId: { type: String },
|
|
||||||
zoneName: { type: String },
|
|
||||||
createBy: { type: Schema.Types.ObjectId, ref: "Users", },
|
|
||||||
points: { type: Array },
|
|
||||||
layer: { type: Number, required: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// export default zoneModel;
|
|
||||||
const zoneModel = (db: string) => {
|
|
||||||
return MainModel(db, "zones", zoneSchema, "zones")
|
|
||||||
};
|
|
||||||
export default zoneModel;
|
|
|
@ -1,5 +1,5 @@
|
||||||
import mongoose, { Document, Schema } from "mongoose";
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../connect/mongoose";
|
import MainModel from "../connect/mongoose.ts";
|
||||||
export interface User extends Document {
|
export interface User extends Document {
|
||||||
userName: String;
|
userName: String;
|
||||||
email: String;
|
email: String;
|
||||||
|
@ -7,9 +7,8 @@ export interface User extends Document {
|
||||||
|
|
||||||
role: String;
|
role: String;
|
||||||
profilePicture: String;
|
profilePicture: String;
|
||||||
isShare: Boolean,
|
isShare: Boolean;
|
||||||
activeStatus: string
|
activeStatus: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
const signupschema: Schema = new Schema({
|
const signupschema: Schema = new Schema({
|
||||||
userName: {
|
userName: {
|
||||||
|
@ -37,19 +36,17 @@ const signupschema: Schema = new Schema({
|
||||||
},
|
},
|
||||||
isShare: {
|
isShare: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false,
|
||||||
},
|
},
|
||||||
activeStatus: {
|
activeStatus: {
|
||||||
type: String,
|
type: String,
|
||||||
enum: ["online", "offline"],
|
enum: ["online", "offline"],
|
||||||
default: "offline"
|
default: "offline",
|
||||||
}
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// export default userModel;
|
// export default userModel;
|
||||||
const userModel = (db: string) => {
|
const userModel = (db: string) => {
|
||||||
return MainModel(db, "Users", signupschema, "Users")
|
return MainModel(db, "Users", signupschema, "Users");
|
||||||
};
|
};
|
||||||
export default userModel;
|
export default userModel;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import mongoose, { Schema, Document, model } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
export interface Panel extends Document {
|
||||||
|
panelOriginalOrder: string[];
|
||||||
|
panelOrder: [
|
||||||
|
{
|
||||||
|
panelName: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
panelSide: string[];
|
||||||
|
lockedPanel: string[];
|
||||||
|
sceneID: string;
|
||||||
|
zoneID: mongoose.Types.ObjectId;
|
||||||
|
isArchive: boolean;
|
||||||
|
createdBy: string;
|
||||||
|
// createdBy: mongoose.Types.ObjectId;
|
||||||
|
}
|
||||||
|
const panelSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
panelOriginalOrder: {
|
||||||
|
type: [String],
|
||||||
|
enum: ["left", "right", "up", "down"],
|
||||||
|
},
|
||||||
|
panelOrder: [
|
||||||
|
{ panelName: String, isArchive: { type: Boolean, default: false } },
|
||||||
|
],
|
||||||
|
panelSide: { type: [String], enum: ["left", "right", "up", "down"] },
|
||||||
|
lockedPanel: { type: [String], enum: ["left", "right", "up", "down"] },
|
||||||
|
sceneID: { type: String },
|
||||||
|
zoneID: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
createdBy: { type: String },
|
||||||
|
// createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const dataModel = (db: any) => {
|
||||||
|
return MainModel(db, "Panel", panelSchema, "Panel");
|
||||||
|
};
|
||||||
|
export default dataModel;
|
|
@ -0,0 +1,31 @@
|
||||||
|
import mongoose, { Schema, Document, model } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
export interface widget extends Document {
|
||||||
|
widgetName: string;
|
||||||
|
widgetType: string;
|
||||||
|
panelorderID: mongoose.Types.ObjectId;
|
||||||
|
isArchive: boolean;
|
||||||
|
// zoneID: string;
|
||||||
|
zoneID: mongoose.Types.ObjectId;
|
||||||
|
sceneID: string;
|
||||||
|
// sceneID: mongoose.Types.ObjectId;
|
||||||
|
Data: string[];
|
||||||
|
}
|
||||||
|
const widgetSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
widgetName: { type: String },
|
||||||
|
widgetType: { type: String },
|
||||||
|
Data: { type: Array },
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
panelorderID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||||
|
zoneID: { type: mongoose.Schema.Types.ObjectId, ref: "Zone" },
|
||||||
|
sceneID: { type: String },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const dataModel = (db: any) => {
|
||||||
|
return MainModel(db, "Widget", widgetSchema, "Widget");
|
||||||
|
};
|
||||||
|
export default dataModel;
|
|
@ -0,0 +1,113 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||||
|
|
||||||
|
/* Projects */
|
||||||
|
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||||
|
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||||
|
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||||
|
// "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": "ESNext", /* 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": "preserve", /* Specify what JSX code is generated. */
|
||||||
|
// "libReplacement": true, /* Enable lib replacement. */
|
||||||
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental 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. */
|
||||||
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
|
/* Modules */
|
||||||
|
"module": "NodeNext", /* Specify what module code is generated. */
|
||||||
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||||
|
"moduleResolution": "NodeNext", /* 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": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||||
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||||
|
"allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||||
|
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
||||||
|
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||||
|
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||||
|
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||||
|
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
||||||
|
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||||
|
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||||
|
// "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. */
|
||||||
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||||
|
"noEmit": true, /* Disable emitting files from a compilation. */
|
||||||
|
// "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": "./", /* Specify an output folder for all emitted files. */
|
||||||
|
// "removeComments": true, /* Disable emitting comments. */
|
||||||
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||||
|
// "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. */
|
||||||
|
// "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. */
|
||||||
|
|
||||||
|
/* Interop Constraints */
|
||||||
|
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||||
|
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||||
|
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
||||||
|
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
||||||
|
// "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. */
|
||||||
|
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
||||||
|
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||||
|
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||||
|
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||||
|
// "noUnusedLocals": true, /* Enable error reporting when 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, /* Add 'undefined' to a type when accessed using an index. */
|
||||||
|
// "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. */
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue