@ozdao/prometheus-framework 0.2.82 → 0.2.83
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/credentials.schema-B-KD_ozQ.js +9 -0
- package/dist/credentials.schema-C9dmNy7o.mjs +10 -0
- package/dist/orders.server.js +592 -0
- package/dist/orders.server.mjs +593 -0
- package/dist/organizations.server.js +4 -3
- package/dist/organizations.server.mjs +2 -1
- package/dist/profile.schema-24ZpZQJe.mjs +25 -0
- package/dist/profile.schema-CkOhhf37.js +24 -0
- package/dist/prometheus-framework/src/modules/chats/components/blocks/ChatMessage.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/blocks/ChatMessage.vue.js +28 -0
- package/dist/prometheus-framework/src/modules/chats/components/pages/ChatPage.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/pages/ChatPage.vue.js +26 -0
- package/dist/prometheus-framework/src/modules/chats/components/pages/ChatPage.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/pages/ChatPage.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/sections/ChatWindow.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/sections/ChatWindow.vue.js +77 -0
- package/dist/prometheus-framework/src/modules/chats/components/sections/ChatWindow.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/components/sections/ChatWindow.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/chats/store/chat.store.cjs +1 -0
- package/dist/prometheus-framework/src/modules/chats/store/chat.store.js +40 -0
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -5
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +0 -66
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +5 -1
- package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +66 -0
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/icons/navigation/IconCheckmark.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/navigation/IconCheckmark.vue.js +29 -0
- package/dist/prometheus-framework/src/modules/icons/placeholders/PlaceholderChat.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/placeholders/PlaceholderChat.vue.js +30 -0
- package/dist/prometheus-framework/src/modules/orders/components/blocks/CardOrder.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/blocks/CardOrder.vue.js +121 -1
- package/dist/prometheus-framework/src/modules/orders/components/blocks/CardOrder.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/blocks/CardOrder.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/blocks/StatusHistory.vue.cjs +3 -0
- package/dist/prometheus-framework/src/modules/orders/components/blocks/StatusHistory.vue.js +92 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/Order.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/Order.vue.js +202 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/Order.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/Order.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreate.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreate.vue.js +127 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreate.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreate.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/partials/ShopCart.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/partials/ShopCart.vue.js +89 -0
- package/dist/prometheus-framework/src/modules/orders/components/partials/ShopCart.vue2.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/partials/ShopCart.vue2.js +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/AskToLogin.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/AskToLogin.vue.js +24 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/EmptyState.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/EmptyState.vue.js +13 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/Succes.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/Succes.vue.js +25 -0
- package/dist/prometheus-framework/src/modules/orders/orders.client.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/orders.client.js +56 -0
- package/dist/prometheus-framework/src/modules/orders/router/orders.router.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/router/orders.router.js +58 -0
- package/dist/prometheus-framework/src/modules/orders/store/shopcart.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/store/shopcart.js +5 -1
- package/dist/style.css +1 -1
- package/dist/users.server.js +7 -27
- package/dist/users.server.mjs +5 -25
- package/package.json +1 -1
- package/src/modules/chats/components/blocks/ChatMessage.vue +1 -1
- package/src/modules/orders/models/application.model.js +25 -25
- package/src/modules/orders/models/testimonial.model.js +22 -23
- package/src/modules/orders/orders.server.js +4 -0
@@ -0,0 +1,593 @@
|
|
1
|
+
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
|
2
|
+
import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
|
3
|
+
import { p as profile_schema } from "./profile.schema-24ZpZQJe.mjs";
|
4
|
+
import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";
|
5
|
+
import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
|
6
|
+
import { q as queryProcessor } from "./queryProcessor-BJdKh0Ow.mjs";
|
7
|
+
import { s as server } from "./index-B6a1mPgp.mjs";
|
8
|
+
import require$$0 from "node-cache";
|
9
|
+
const applyOwnershipSchema$1 = ownership_schema;
|
10
|
+
var order_model = (db) => {
|
11
|
+
const OrderSchema = new db.mongoose.Schema({
|
12
|
+
customer: {
|
13
|
+
type: {
|
14
|
+
type: String,
|
15
|
+
required: true
|
16
|
+
},
|
17
|
+
target: {
|
18
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
19
|
+
refPath: "customer.type",
|
20
|
+
required: true
|
21
|
+
}
|
22
|
+
},
|
23
|
+
positions: {
|
24
|
+
type: Array
|
25
|
+
},
|
26
|
+
referralCode: {
|
27
|
+
type: String
|
28
|
+
},
|
29
|
+
status: {
|
30
|
+
type: String
|
31
|
+
},
|
32
|
+
status_history: [{
|
33
|
+
status: {
|
34
|
+
type: String,
|
35
|
+
trim: true
|
36
|
+
},
|
37
|
+
changedBy: {
|
38
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
39
|
+
ref: "User"
|
40
|
+
},
|
41
|
+
timestamp: {
|
42
|
+
type: Date,
|
43
|
+
default: Date.now
|
44
|
+
},
|
45
|
+
comment: {
|
46
|
+
type: String,
|
47
|
+
trim: true
|
48
|
+
}
|
49
|
+
}],
|
50
|
+
comment: {
|
51
|
+
type: String,
|
52
|
+
trim: true
|
53
|
+
},
|
54
|
+
payment: {
|
55
|
+
type: {
|
56
|
+
type: String,
|
57
|
+
trim: true
|
58
|
+
},
|
59
|
+
status: {
|
60
|
+
type: String,
|
61
|
+
trim: true
|
62
|
+
}
|
63
|
+
},
|
64
|
+
delivery: {
|
65
|
+
type: {
|
66
|
+
type: String,
|
67
|
+
trim: true
|
68
|
+
},
|
69
|
+
address: {
|
70
|
+
type: String,
|
71
|
+
trim: true
|
72
|
+
},
|
73
|
+
status: {
|
74
|
+
type: String,
|
75
|
+
trim: true
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}, {
|
79
|
+
timestamps: {
|
80
|
+
currentTime: () => Date.now()
|
81
|
+
}
|
82
|
+
});
|
83
|
+
applyOwnershipSchema$1(OrderSchema, db);
|
84
|
+
const Order = db.mongoose.model("Order", OrderSchema);
|
85
|
+
return Order;
|
86
|
+
};
|
87
|
+
const applyOwnershipSchema = ownership_schema;
|
88
|
+
const applyProfileSchema = profile_schema;
|
89
|
+
const applyCredentialsSchema = credentials_schema;
|
90
|
+
var customer_model = (db) => {
|
91
|
+
const CustomerSchema = new db.mongoose.Schema({
|
92
|
+
identity: {
|
93
|
+
type: {
|
94
|
+
type: String,
|
95
|
+
enum: ["Visitor", "User", "Organization"],
|
96
|
+
required: true
|
97
|
+
},
|
98
|
+
target: {
|
99
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
100
|
+
refPath: "target.type"
|
101
|
+
}
|
102
|
+
},
|
103
|
+
referral: {
|
104
|
+
code: {
|
105
|
+
type: String
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}, {
|
109
|
+
timestamps: {
|
110
|
+
currentTime: () => Date.now()
|
111
|
+
}
|
112
|
+
});
|
113
|
+
applyCredentialsSchema(CustomerSchema);
|
114
|
+
applyProfileSchema(CustomerSchema);
|
115
|
+
applyOwnershipSchema(CustomerSchema, db);
|
116
|
+
CustomerSchema.index({
|
117
|
+
owner: 1,
|
118
|
+
email: 1
|
119
|
+
}, {
|
120
|
+
unique: true,
|
121
|
+
partialFilterExpression: {
|
122
|
+
email: { $exists: true, $ne: "" }
|
123
|
+
}
|
124
|
+
});
|
125
|
+
CustomerSchema.index({
|
126
|
+
owner: 1,
|
127
|
+
phone: 1
|
128
|
+
}, {
|
129
|
+
unique: true,
|
130
|
+
partialFilterExpression: {
|
131
|
+
phone: { $exists: true, $ne: "" }
|
132
|
+
}
|
133
|
+
});
|
134
|
+
CustomerSchema.index({
|
135
|
+
owner: 1,
|
136
|
+
identity: 1
|
137
|
+
}, {
|
138
|
+
unique: true,
|
139
|
+
partialFilterExpression: {
|
140
|
+
identity: { $exists: true, $ne: "" }
|
141
|
+
}
|
142
|
+
});
|
143
|
+
const Customer = db.mongoose.model("Customer", CustomerSchema);
|
144
|
+
return Customer;
|
145
|
+
};
|
146
|
+
var testimonial_model = (db) => {
|
147
|
+
const testimonialSchema = new db.mongoose.Schema({
|
148
|
+
source: {
|
149
|
+
type: String
|
150
|
+
},
|
151
|
+
author: {
|
152
|
+
type: Schema.Types.ObjectId,
|
153
|
+
ref: "User",
|
154
|
+
required: true
|
155
|
+
},
|
156
|
+
rating: {
|
157
|
+
type: String,
|
158
|
+
required: true
|
159
|
+
},
|
160
|
+
description: {
|
161
|
+
type: String,
|
162
|
+
required: true
|
163
|
+
}
|
164
|
+
});
|
165
|
+
const Testimonial = db.mongoose.model("Testimonial", testimonialSchema);
|
166
|
+
return Testimonial;
|
167
|
+
};
|
168
|
+
var application_model = (db) => {
|
169
|
+
const ApplicationSchema = new db.mongoose.Schema({
|
170
|
+
status: {
|
171
|
+
type: String,
|
172
|
+
default: "created"
|
173
|
+
},
|
174
|
+
type: {
|
175
|
+
type: String,
|
176
|
+
default: "newsletter"
|
177
|
+
},
|
178
|
+
contacts: {
|
179
|
+
name: {
|
180
|
+
type: String
|
181
|
+
},
|
182
|
+
phone: {
|
183
|
+
type: String
|
184
|
+
},
|
185
|
+
email: {
|
186
|
+
type: String
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}, {
|
190
|
+
timestamps: { currentTime: () => Date.now() }
|
191
|
+
});
|
192
|
+
const Application = db.mongoose.model("Application", ApplicationSchema);
|
193
|
+
return Application;
|
194
|
+
};
|
195
|
+
const { sendChatMessageTelegram } = mailing;
|
196
|
+
const queryProcessorGlobals = queryProcessor;
|
197
|
+
function formatPositions(positions) {
|
198
|
+
return positions.map((pos) => `🔹 ${pos.name} - Price: $${pos.price}, Quantity: ${pos.quantity}`).join("\n");
|
199
|
+
}
|
200
|
+
function formatOrderMessage(order) {
|
201
|
+
return `
|
202
|
+
🆕 New Order Received!
|
203
|
+
👤 Customer: ${order.customer?.name} (${order.customer?.phone?.number ? order.customer?.phone?.number : "No phone"})
|
204
|
+
💬 Messenger: ${order.customer?.messenger ? order.customer?.messenger?.type + " " + order.customer?.messenger?.value : "None"}
|
205
|
+
🏢 Organization: ${order.organization}
|
206
|
+
📦 Positions:
|
207
|
+
${formatPositions(order.positions)}
|
208
|
+
📝 Comment: ${order.comment ? order.comment : "No comment"}
|
209
|
+
💳 Payment: ${order.payment?.type}
|
210
|
+
🚚 Delivery: ${order.delivery?.type} to ${order.delivery?.address}
|
211
|
+
📌 Status: ${order.status}
|
212
|
+
🧑 Agent: ${order.referralCode}
|
213
|
+
`;
|
214
|
+
}
|
215
|
+
function initializeOrder(orderData, userId) {
|
216
|
+
orderData.status = "created";
|
217
|
+
orderData.status_history = orderData.status_history || [];
|
218
|
+
orderData.status_history.push({
|
219
|
+
status: orderData.status,
|
220
|
+
changedBy: userId,
|
221
|
+
timestamp: /* @__PURE__ */ new Date(),
|
222
|
+
comment: ""
|
223
|
+
});
|
224
|
+
}
|
225
|
+
async function findOrCreateCustomer(Customer, customerInfo, orderOwner, visitor) {
|
226
|
+
let searchCriteria = {};
|
227
|
+
if (customerInfo.phone) {
|
228
|
+
searchCriteria.phone = customerInfo.phone;
|
229
|
+
}
|
230
|
+
if (customerInfo.email) {
|
231
|
+
searchCriteria.email = customerInfo.email;
|
232
|
+
}
|
233
|
+
let customer = null;
|
234
|
+
if (Object.keys(searchCriteria).length > 0) {
|
235
|
+
customer = await Customer.findOne({ $or: [searchCriteria] });
|
236
|
+
}
|
237
|
+
if (!customer) {
|
238
|
+
const newCustomerData = {
|
239
|
+
...customerInfo,
|
240
|
+
owner: orderOwner,
|
241
|
+
creator: customerInfo.creator || { type: "Visitor", target: visitor || orderOwner.target },
|
242
|
+
identity: customerInfo.indentity || { type: "Visitor", target: visitor || orderOwner.target }
|
243
|
+
};
|
244
|
+
customer = await Customer.create(newCustomerData);
|
245
|
+
}
|
246
|
+
return customer;
|
247
|
+
}
|
248
|
+
async function sendOrderMessage(orderData) {
|
249
|
+
try {
|
250
|
+
const formattedMessage = formatOrderMessage(orderData);
|
251
|
+
await sendChatMessageTelegram(process.env.TELEGRAM_BOT_USERS.split(","), formattedMessage);
|
252
|
+
} catch (err) {
|
253
|
+
console.error(err);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
const controllerFactory$1 = (db) => {
|
257
|
+
const Order = db.order;
|
258
|
+
const Customer = db.customer;
|
259
|
+
const create = async (req, res) => {
|
260
|
+
const orderData = req.body;
|
261
|
+
const userId = req.userId;
|
262
|
+
initializeOrder(orderData, userId);
|
263
|
+
try {
|
264
|
+
if (!orderData.customer.target) {
|
265
|
+
let customer = await findOrCreateCustomer(Customer, orderData.customer, orderData.owner, orderData.visitor);
|
266
|
+
orderData.customer = { type: "Customer", target: customer._id };
|
267
|
+
if (!orderData.creator?.target) {
|
268
|
+
orderData.creator = { type: "Customer", target: customer._id };
|
269
|
+
}
|
270
|
+
}
|
271
|
+
await sendOrderMessage(orderData);
|
272
|
+
const order = await Order.create(orderData);
|
273
|
+
res.status(201).send(order);
|
274
|
+
} catch (err) {
|
275
|
+
console.error(err);
|
276
|
+
res.status(500).send({ errorCode: "CREATE_ORDER_FAILED", message: "Error occurred while creating the order.", error: err });
|
277
|
+
}
|
278
|
+
};
|
279
|
+
const read = async (req, res) => {
|
280
|
+
stages = [
|
281
|
+
...queryProcessorGlobals.getBasicOptions(
|
282
|
+
req.query
|
283
|
+
),
|
284
|
+
// For customer
|
285
|
+
{
|
286
|
+
$lookup: {
|
287
|
+
from: "customers",
|
288
|
+
localField: "customer.target",
|
289
|
+
foreignField: "_id",
|
290
|
+
as: "customerTarget"
|
291
|
+
}
|
292
|
+
},
|
293
|
+
{
|
294
|
+
$addFields: {
|
295
|
+
"customer.target": { $arrayElemAt: ["$customerTarget", 0] }
|
296
|
+
}
|
297
|
+
},
|
298
|
+
// For creator
|
299
|
+
queryProcessorGlobals.getCreatorUserLookupStage(),
|
300
|
+
queryProcessorGlobals.getCreatorOrganizationLookupStage(),
|
301
|
+
queryProcessorGlobals.getCreatorCustomerLookupStage(),
|
302
|
+
// For owner
|
303
|
+
queryProcessorGlobals.getOwnerUserLookupStage(),
|
304
|
+
queryProcessorGlobals.getOwnerOrganizationLookupStage(),
|
305
|
+
queryProcessorGlobals.getAddFieldsCreatorOwnerStage(),
|
306
|
+
// Pagination
|
307
|
+
...queryProcessorGlobals.getSortingOptions(
|
308
|
+
req.query.sortParam,
|
309
|
+
req.query.sortOrder
|
310
|
+
),
|
311
|
+
...queryProcessorGlobals.getPaginationOptions(
|
312
|
+
req.query.skip,
|
313
|
+
req.query.limit
|
314
|
+
)
|
315
|
+
];
|
316
|
+
try {
|
317
|
+
const orders = await Order.aggregate(stages);
|
318
|
+
if (!orders) {
|
319
|
+
return res.status(404).send({ errorCode: "ORDER_NOT_FOUND", message: "Orders not found." });
|
320
|
+
}
|
321
|
+
res.status(200).send(orders);
|
322
|
+
} catch (err) {
|
323
|
+
console.log(err);
|
324
|
+
res.status(500).send({ errorCode: "GET_ORDERS_FAILED", message: "Error occurred while fetching orders.", error: err });
|
325
|
+
}
|
326
|
+
};
|
327
|
+
const update = async (req, res) => {
|
328
|
+
const order = await Order.findById(new db.mongoose.Schema.Types.ObjectId(req.body._id));
|
329
|
+
if (!order) {
|
330
|
+
return res.status(404).send({ errorCode: "ORDER_NOT_FOUND", message: "Order not found." });
|
331
|
+
}
|
332
|
+
if (req.body.status && req.body.status !== order.status) {
|
333
|
+
order.status = req.body.status;
|
334
|
+
order.status_history.push({
|
335
|
+
status: req.body.status,
|
336
|
+
changedBy: req.userId,
|
337
|
+
timestamp: /* @__PURE__ */ new Date(),
|
338
|
+
comment: ""
|
339
|
+
});
|
340
|
+
}
|
341
|
+
try {
|
342
|
+
await order.save();
|
343
|
+
res.status(200).send(order);
|
344
|
+
} catch (err) {
|
345
|
+
res.status(500).send({ errorCode: "UPDATE_ORDER_FAILED", message: "Error occurred while updating the order.", error: err });
|
346
|
+
}
|
347
|
+
};
|
348
|
+
const changePaymentStatus = async (req, res) => {
|
349
|
+
try {
|
350
|
+
const order = await Order.findOneAndUpdate(
|
351
|
+
{ _id: req.params._id },
|
352
|
+
{ status: "Оплачен", payment: { type: "Наличные", status: "Оплачено" } },
|
353
|
+
{ new: true }
|
354
|
+
).exec();
|
355
|
+
if (!order) {
|
356
|
+
return res.status(404).send({ errorCode: "PAYMENT_STATUS_CHANGE_FAILED", message: "Failed to change the payment status." });
|
357
|
+
}
|
358
|
+
res.status(200).send(order);
|
359
|
+
} catch (err) {
|
360
|
+
res.status(500).send({ errorCode: "CHANGE_PAYMENT_STATUS_FAILED", message: "Error occurred while changing the payment status.", error: err });
|
361
|
+
}
|
362
|
+
};
|
363
|
+
const deleteOrder = async (req, res) => {
|
364
|
+
try {
|
365
|
+
const order = await Order.findOneAndDelete({ _id: req.params._id }).exec();
|
366
|
+
if (!order) {
|
367
|
+
return res.status(404).send({ errorCode: "ORDER_DELETE_FAILED", message: "Failed to delete the order." });
|
368
|
+
}
|
369
|
+
res.status(200).send(order);
|
370
|
+
} catch (err) {
|
371
|
+
res.status(500).send({ errorCode: "DELETE_ORDER_FAILED", message: "Error occurred while deleting the order.", error: err });
|
372
|
+
}
|
373
|
+
};
|
374
|
+
return {
|
375
|
+
create,
|
376
|
+
read,
|
377
|
+
update,
|
378
|
+
changePaymentStatus,
|
379
|
+
deleteOrder
|
380
|
+
};
|
381
|
+
};
|
382
|
+
var orders_controller = controllerFactory$1;
|
383
|
+
const controllerFactory = orders_controller;
|
384
|
+
const middlewareFactory = server;
|
385
|
+
var orders_routes = function(app, db, origins, publicPath) {
|
386
|
+
const controller = controllerFactory(db);
|
387
|
+
const middleware = middlewareFactory(db);
|
388
|
+
app.post(
|
389
|
+
"/api/orders/create",
|
390
|
+
controller.create
|
391
|
+
);
|
392
|
+
app.get(
|
393
|
+
"/api/orders/read",
|
394
|
+
controller.read
|
395
|
+
);
|
396
|
+
app.post(
|
397
|
+
"/api/orders/update",
|
398
|
+
[
|
399
|
+
middleware.authJwt.verifyToken
|
400
|
+
],
|
401
|
+
controller.update
|
402
|
+
);
|
403
|
+
app.post(
|
404
|
+
"/api/orders/delete",
|
405
|
+
controller.deleteOrder
|
406
|
+
);
|
407
|
+
};
|
408
|
+
const NodeCache = require$$0;
|
409
|
+
const stdTTL = 60 * 5;
|
410
|
+
class Cache {
|
411
|
+
constructor(ttlSeconds = stdTTL) {
|
412
|
+
this.cache = new NodeCache({ stdTTL: ttlSeconds });
|
413
|
+
}
|
414
|
+
async get(key) {
|
415
|
+
return this.cache.get(key);
|
416
|
+
}
|
417
|
+
async set(key, value) {
|
418
|
+
return this.cache.set(key, value);
|
419
|
+
}
|
420
|
+
async del(keys) {
|
421
|
+
return this.cache.del(keys);
|
422
|
+
}
|
423
|
+
async flush() {
|
424
|
+
this.cache.flushAll();
|
425
|
+
}
|
426
|
+
}
|
427
|
+
var globals_cashe = Cache;
|
428
|
+
let Logger$1 = class Logger {
|
429
|
+
static logModel = null;
|
430
|
+
constructor(db) {
|
431
|
+
if (!Logger.logModel) {
|
432
|
+
const logSchema = new db.mongoose.Schema({
|
433
|
+
timestamp: { type: Date, default: Date.now },
|
434
|
+
level: String,
|
435
|
+
message: String
|
436
|
+
}, { versionKey: false });
|
437
|
+
Logger.logModel = db.mongoose.model("Log", logSchema);
|
438
|
+
}
|
439
|
+
this.LogModel = Logger.logModel;
|
440
|
+
}
|
441
|
+
async log(level, message) {
|
442
|
+
const logEntry = new Logger.logModel({
|
443
|
+
level,
|
444
|
+
message
|
445
|
+
});
|
446
|
+
try {
|
447
|
+
await logEntry.save();
|
448
|
+
console.info(`Logged: ${level} - ${message}`);
|
449
|
+
} catch (err) {
|
450
|
+
console.error("Logging error:", err);
|
451
|
+
}
|
452
|
+
}
|
453
|
+
// Удобные методы для различных уровней логирования
|
454
|
+
async info(message) {
|
455
|
+
await this.log("info", message);
|
456
|
+
}
|
457
|
+
async error(message) {
|
458
|
+
await this.log("error", message);
|
459
|
+
}
|
460
|
+
};
|
461
|
+
var globals_logger = Logger$1;
|
462
|
+
const globalsQuery = queryProcessor;
|
463
|
+
const Cashe = globals_cashe;
|
464
|
+
const Logger2 = globals_logger;
|
465
|
+
let CRUD$1 = class CRUD {
|
466
|
+
constructor(basePath, app, db, model) {
|
467
|
+
this.model = model;
|
468
|
+
this.cache = new Cashe();
|
469
|
+
this.logger = new Logger2(db);
|
470
|
+
this.app = app;
|
471
|
+
this.basePath = basePath;
|
472
|
+
this.registerRoutes();
|
473
|
+
}
|
474
|
+
registerRoutes() {
|
475
|
+
this.app.post(`${this.basePath}/create`, this.create.bind(this));
|
476
|
+
this.app.get(`${this.basePath}/read`, this.read.bind(this));
|
477
|
+
this.app.put(`${this.basePath}/update`, this.update.bind(this));
|
478
|
+
this.app.delete(`${this.basePath}/delete`, this.delete.bind(this));
|
479
|
+
}
|
480
|
+
async create(req, res) {
|
481
|
+
try {
|
482
|
+
const createdData = await this.model.create(req.body);
|
483
|
+
await this.cache.flush();
|
484
|
+
res.status(201).json(createdData);
|
485
|
+
} catch (error) {
|
486
|
+
console.log(error);
|
487
|
+
this.logger.error("Ошибка создания данных", error);
|
488
|
+
res.status(500).json({ error: error.message });
|
489
|
+
}
|
490
|
+
}
|
491
|
+
async read(req, res) {
|
492
|
+
try {
|
493
|
+
let stages2 = [];
|
494
|
+
stages2 = [
|
495
|
+
...globalsQuery.getBasicOptions(
|
496
|
+
req.query
|
497
|
+
),
|
498
|
+
// For creator
|
499
|
+
globalsQuery.getCreatorUserLookupStage(),
|
500
|
+
globalsQuery.getCreatorOrganizationLookupStage(),
|
501
|
+
// For owner
|
502
|
+
globalsQuery.getOwnerUserLookupStage(),
|
503
|
+
globalsQuery.getOwnerOrganizationLookupStage(),
|
504
|
+
globalsQuery.getAddFieldsCreatorOwnerStage(),
|
505
|
+
// Pagination
|
506
|
+
...globalsQuery.getSortingOptions(
|
507
|
+
req.query.sortParam,
|
508
|
+
req.query.sortOrder
|
509
|
+
),
|
510
|
+
...globalsQuery.getPaginationOptions(
|
511
|
+
req.query.skip,
|
512
|
+
req.query.limit
|
513
|
+
),
|
514
|
+
globalsQuery.removeTempPropeties()
|
515
|
+
];
|
516
|
+
const cacheKey = JSON.stringify({ stages: stages2 });
|
517
|
+
let data = await this.cache.get(cacheKey);
|
518
|
+
if (!data) {
|
519
|
+
data = await this.model.aggregate(stages2).exec();
|
520
|
+
await this.cache.set(cacheKey, data);
|
521
|
+
}
|
522
|
+
res.json(data);
|
523
|
+
} catch (error) {
|
524
|
+
this.logger.error(error);
|
525
|
+
res.status(500).json({ error: error.message });
|
526
|
+
}
|
527
|
+
}
|
528
|
+
async update(req, res) {
|
529
|
+
try {
|
530
|
+
const updatedData = await this.model.findOneAndUpdate(
|
531
|
+
{ _id: req.body._id },
|
532
|
+
req.body,
|
533
|
+
{ new: true, runValidators: true }
|
534
|
+
);
|
535
|
+
if (!updatedData) {
|
536
|
+
throw new Error("Документ не найден.");
|
537
|
+
}
|
538
|
+
await this.cache.flush();
|
539
|
+
res.json(updatedData);
|
540
|
+
} catch (error) {
|
541
|
+
this.logger.error("Ошибка обновления данных", error);
|
542
|
+
res.status(404).json({ error: error.message });
|
543
|
+
}
|
544
|
+
}
|
545
|
+
async delete(req, res) {
|
546
|
+
try {
|
547
|
+
const deletedData = await this.model.findOneAndDelete({ _id: req.body._id });
|
548
|
+
if (!deletedData) {
|
549
|
+
throw new Error("Документ не найден.");
|
550
|
+
}
|
551
|
+
await this.cache.flush();
|
552
|
+
res.status(204).send();
|
553
|
+
} catch (error) {
|
554
|
+
this.logger.error("Ошибка удаления данных", error);
|
555
|
+
res.status(404).json({ error: error.message });
|
556
|
+
}
|
557
|
+
}
|
558
|
+
};
|
559
|
+
var globals_crud = CRUD$1;
|
560
|
+
const ModelOrder = order_model;
|
561
|
+
const ModelCustomer = customer_model;
|
562
|
+
const ModelTestimonial = testimonial_model;
|
563
|
+
const ModelApplication = application_model;
|
564
|
+
const RoutesOrder = orders_routes;
|
565
|
+
const FactoryOrder = orders_controller;
|
566
|
+
const CRUD2 = globals_crud;
|
567
|
+
function initializeOrders(app, db, origins, publicPath) {
|
568
|
+
db.order = ModelOrder(db);
|
569
|
+
db.customer = ModelCustomer(db);
|
570
|
+
db.testimonial = ModelTestimonial(db);
|
571
|
+
db.application = ModelApplication(db);
|
572
|
+
if (app) {
|
573
|
+
RoutesOrder(app, db);
|
574
|
+
}
|
575
|
+
new CRUD2("/api/customers", app, db, db.customer);
|
576
|
+
}
|
577
|
+
var orders_server = {
|
578
|
+
initialize: initializeOrders,
|
579
|
+
models: {
|
580
|
+
ModelOrder,
|
581
|
+
ModelCustomer
|
582
|
+
},
|
583
|
+
routes: {
|
584
|
+
RoutesOrder
|
585
|
+
},
|
586
|
+
controllers: {
|
587
|
+
FactoryOrder
|
588
|
+
}
|
589
|
+
};
|
590
|
+
const orders_server$1 = /* @__PURE__ */ getDefaultExportFromCjs(orders_server);
|
591
|
+
export {
|
592
|
+
orders_server$1 as default
|
593
|
+
};
|
@@ -6,11 +6,12 @@ require("bcryptjs");
|
|
6
6
|
const require$$3 = require("uuidv4");
|
7
7
|
const require$$0 = require("mongoose");
|
8
8
|
const require$$5 = require("@googlemaps/google-maps-services-js");
|
9
|
-
const
|
9
|
+
const addMembersQuantity$1 = require("./addMembersQuantity-B8UgqlUM.js");
|
10
10
|
const mailing = require("./mailing-BX0q8DIs.js");
|
11
11
|
const index = require("./index-BCCiEK_u.js");
|
12
12
|
const require$$0$2 = require("mongodb");
|
13
13
|
const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
|
14
|
+
const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
|
14
15
|
const controllerFactory$6 = (db) => {
|
15
16
|
const Department = db.department;
|
16
17
|
const readOne = (req, res2) => {
|
@@ -86,8 +87,8 @@ const jwt = require$$0$1;
|
|
86
87
|
const ObjectId$2 = require$$0.Types.ObjectId;
|
87
88
|
const { Client } = require$$5;
|
88
89
|
const client = new Client({});
|
89
|
-
const addUserStatusFields =
|
90
|
-
const addMembersQuantity =
|
90
|
+
const addUserStatusFields = addMembersQuantity$1.addUserStatusFields_1;
|
91
|
+
const addMembersQuantity = addMembersQuantity$1.addMembersQuantity_1;
|
91
92
|
const controllerFactory$5 = (db) => {
|
92
93
|
const Organization = db.organization;
|
93
94
|
const Membership = db.membership;
|
@@ -5,11 +5,12 @@ import "bcryptjs";
|
|
5
5
|
import require$$3 from "uuidv4";
|
6
6
|
import require$$0 from "mongoose";
|
7
7
|
import require$$5 from "@googlemaps/google-maps-services-js";
|
8
|
-
import { a as addUserStatusFields_1, b as addMembersQuantity_1
|
8
|
+
import { a as addUserStatusFields_1, b as addMembersQuantity_1 } from "./addMembersQuantity-BXp_LeQd.mjs";
|
9
9
|
import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
|
10
10
|
import { s as server } from "./index-B6a1mPgp.mjs";
|
11
11
|
import require$$0$2 from "mongodb";
|
12
12
|
import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
|
13
|
+
import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";
|
13
14
|
const controllerFactory$6 = (db) => {
|
14
15
|
const Department = db.department;
|
15
16
|
const readOne = (req, res2) => {
|
@@ -0,0 +1,25 @@
|
|
1
|
+
var profile_schema = function applyProfileSchema(schema, db) {
|
2
|
+
schema.add({
|
3
|
+
profile: {
|
4
|
+
photo: {
|
5
|
+
type: String,
|
6
|
+
default: null
|
7
|
+
},
|
8
|
+
name: {
|
9
|
+
type: String,
|
10
|
+
default: null
|
11
|
+
},
|
12
|
+
description: {
|
13
|
+
type: String,
|
14
|
+
default: null
|
15
|
+
},
|
16
|
+
birthday: {
|
17
|
+
type: Date,
|
18
|
+
default: null
|
19
|
+
}
|
20
|
+
}
|
21
|
+
});
|
22
|
+
};
|
23
|
+
export {
|
24
|
+
profile_schema as p
|
25
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var profile_schema = function applyProfileSchema(schema, db) {
|
3
|
+
schema.add({
|
4
|
+
profile: {
|
5
|
+
photo: {
|
6
|
+
type: String,
|
7
|
+
default: null
|
8
|
+
},
|
9
|
+
name: {
|
10
|
+
type: String,
|
11
|
+
default: null
|
12
|
+
},
|
13
|
+
description: {
|
14
|
+
type: String,
|
15
|
+
default: null
|
16
|
+
},
|
17
|
+
birthday: {
|
18
|
+
type: Date,
|
19
|
+
default: null
|
20
|
+
}
|
21
|
+
}
|
22
|
+
});
|
23
|
+
};
|
24
|
+
exports.profile_schema = profile_schema;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("../../../../../../_virtual/_plugin-vue_export-helper.cjs"),n={props:{message:{type:Object,required:!0}}},r={class:"flex-v-center gap-thin flex-nowrap flex w-100 p-small"},o={class:"mn-r-auto"},l={class:"t-semi"},c={class:"t-transp"};function i(s,u,t,m,p,_){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["pd-small",{"bg-main-nano":t.message.username==="Weeder Support"}])},[e.createElementVNode("p",r,[e.createElementVNode("strong",o,[e.createElementVNode("span",l,e.toDisplayString(t.message.username),1),e.createTextVNode(),e.createElementVNode("span",c,e.toDisplayString(s.formatDate(t.message.createdAt)),1)])]),e.createElementVNode("p",null,e.toDisplayString(t.message.text),1)],2)}const d=a.default(n,[["render",i]]);exports.default=d;
|