@7365admin1/core 2.64.0 → 2.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +215 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12314,6 +12314,33 @@ function useServiceProviderRepo() {
|
|
|
12314
12314
|
throw error;
|
|
12315
12315
|
}
|
|
12316
12316
|
}
|
|
12317
|
+
async function updateStatusById(_id, status) {
|
|
12318
|
+
try {
|
|
12319
|
+
_id = new ObjectId34(_id);
|
|
12320
|
+
} catch (error) {
|
|
12321
|
+
throw new BadRequestError54("Invalid service provider ID format.");
|
|
12322
|
+
}
|
|
12323
|
+
try {
|
|
12324
|
+
const result = await collection.updateOne(
|
|
12325
|
+
{ _id },
|
|
12326
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
12327
|
+
);
|
|
12328
|
+
if (!result.matchedCount) {
|
|
12329
|
+
throw new NotFoundError14("Service provider not found.");
|
|
12330
|
+
}
|
|
12331
|
+
delNamespace().then(() => {
|
|
12332
|
+
logger40.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
12333
|
+
}).catch((err) => {
|
|
12334
|
+
logger40.error(
|
|
12335
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
12336
|
+
err
|
|
12337
|
+
);
|
|
12338
|
+
});
|
|
12339
|
+
return result;
|
|
12340
|
+
} catch (error) {
|
|
12341
|
+
throw error;
|
|
12342
|
+
}
|
|
12343
|
+
}
|
|
12317
12344
|
return {
|
|
12318
12345
|
createTextIndex,
|
|
12319
12346
|
createUniqueIndex,
|
|
@@ -12323,7 +12350,8 @@ function useServiceProviderRepo() {
|
|
|
12323
12350
|
getServiceProviderTypes,
|
|
12324
12351
|
getServiceProviderById,
|
|
12325
12352
|
getByServiceProviderOrgIdType,
|
|
12326
|
-
getByEmail
|
|
12353
|
+
getByEmail,
|
|
12354
|
+
updateStatusById
|
|
12327
12355
|
};
|
|
12328
12356
|
}
|
|
12329
12357
|
|
|
@@ -13102,7 +13130,8 @@ function useServiceProviderController() {
|
|
|
13102
13130
|
getServiceProviderTypes: _getServiceProviderTypes,
|
|
13103
13131
|
getServiceProviderById: _getServiceProviderById,
|
|
13104
13132
|
getServiceProviders: _getServiceProviders,
|
|
13105
|
-
getByServiceProviderOrgIdType: _getByServiceProviderOrgIdType
|
|
13133
|
+
getByServiceProviderOrgIdType: _getByServiceProviderOrgIdType,
|
|
13134
|
+
updateStatusById: _updateStatusById
|
|
13106
13135
|
} = useServiceProviderRepo();
|
|
13107
13136
|
const { createServiceProvider: _createServiceProvider } = useServiceProviderService();
|
|
13108
13137
|
const { createServiceProvider: _add } = useServiceProviderRepo();
|
|
@@ -13316,6 +13345,30 @@ function useServiceProviderController() {
|
|
|
13316
13345
|
return;
|
|
13317
13346
|
}
|
|
13318
13347
|
}
|
|
13348
|
+
async function updateStatusById(req, res, next) {
|
|
13349
|
+
const validation = Joi31.object({
|
|
13350
|
+
id: Joi31.string().hex().required(),
|
|
13351
|
+
status: Joi31.string().valid("active", "inactive").required()
|
|
13352
|
+
});
|
|
13353
|
+
const { error, value } = validation.validate({
|
|
13354
|
+
id: req.params.id,
|
|
13355
|
+
status: req.body.status
|
|
13356
|
+
});
|
|
13357
|
+
if (error) {
|
|
13358
|
+
logger43.log({ level: "error", message: error.message });
|
|
13359
|
+
next(new BadRequestError60(error.message));
|
|
13360
|
+
return;
|
|
13361
|
+
}
|
|
13362
|
+
try {
|
|
13363
|
+
await _updateStatusById(value.id, value.status);
|
|
13364
|
+
res.json({ message: "Service provider status updated successfully." });
|
|
13365
|
+
return;
|
|
13366
|
+
} catch (error2) {
|
|
13367
|
+
logger43.log({ level: "error", message: error2.message });
|
|
13368
|
+
next(error2);
|
|
13369
|
+
return;
|
|
13370
|
+
}
|
|
13371
|
+
}
|
|
13319
13372
|
return {
|
|
13320
13373
|
createServiceProvider,
|
|
13321
13374
|
getServiceProviders,
|
|
@@ -13324,7 +13377,8 @@ function useServiceProviderController() {
|
|
|
13324
13377
|
getServiceProviderTypes,
|
|
13325
13378
|
getServiceProviderById,
|
|
13326
13379
|
getByServiceProviderOrgIdType,
|
|
13327
|
-
add
|
|
13380
|
+
add,
|
|
13381
|
+
updateStatusById
|
|
13328
13382
|
};
|
|
13329
13383
|
}
|
|
13330
13384
|
|
|
@@ -53714,6 +53768,7 @@ import Joi132 from "joi";
|
|
|
53714
53768
|
import { ObjectId as ObjectId129 } from "mongodb";
|
|
53715
53769
|
var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
|
|
53716
53770
|
PostStatus2["PUBLISHED"] = "published";
|
|
53771
|
+
PostStatus2["RESERVED"] = "reserved";
|
|
53717
53772
|
PostStatus2["SOLD"] = "sold";
|
|
53718
53773
|
PostStatus2["DELETED"] = "deleted";
|
|
53719
53774
|
return PostStatus2;
|
|
@@ -53746,6 +53801,17 @@ var schemaPost = Joi132.object({
|
|
|
53746
53801
|
updatedAt: Joi132.date().optional().allow(null),
|
|
53747
53802
|
deletedAt: Joi132.date().optional().allow(null)
|
|
53748
53803
|
});
|
|
53804
|
+
var schemaUpdatePost = Joi132.object({
|
|
53805
|
+
_id: Joi132.string().hex().required(),
|
|
53806
|
+
title: Joi132.string().optional().allow("", null),
|
|
53807
|
+
description: Joi132.string().optional().allow("", null),
|
|
53808
|
+
attachments: Joi132.array().items(Joi132.string().hex().optional()).optional().allow(null),
|
|
53809
|
+
category: Joi132.array().items(Joi132.string().hex().optional()).optional().allow(null),
|
|
53810
|
+
currency: Joi132.string().optional().allow("", null),
|
|
53811
|
+
price: Joi132.number().optional(),
|
|
53812
|
+
status: Joi132.string().valid(...Object.values(PostStatus)).optional().allow(null),
|
|
53813
|
+
reserverId: Joi132.string().hex().optional().allow("", null)
|
|
53814
|
+
});
|
|
53749
53815
|
function MPost(value) {
|
|
53750
53816
|
const { error } = schemaPost.validate(value);
|
|
53751
53817
|
if (error) {
|
|
@@ -53969,10 +54035,79 @@ function usePostPrelovedRepo() {
|
|
|
53969
54035
|
throw error;
|
|
53970
54036
|
}
|
|
53971
54037
|
}
|
|
54038
|
+
async function updateById(_id, value, session) {
|
|
54039
|
+
try {
|
|
54040
|
+
_id = new ObjectId130(_id);
|
|
54041
|
+
} catch {
|
|
54042
|
+
throw new BadRequestError210("Invalid post ID format.");
|
|
54043
|
+
}
|
|
54044
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
54045
|
+
try {
|
|
54046
|
+
const res = await collection.updateOne(
|
|
54047
|
+
{ _id },
|
|
54048
|
+
{ $set: value },
|
|
54049
|
+
{ session }
|
|
54050
|
+
);
|
|
54051
|
+
if (res.modifiedCount === 0) {
|
|
54052
|
+
throw new InternalServerError74("Unable to update post.");
|
|
54053
|
+
}
|
|
54054
|
+
return res;
|
|
54055
|
+
} catch (error) {
|
|
54056
|
+
throw error;
|
|
54057
|
+
}
|
|
54058
|
+
}
|
|
54059
|
+
async function deleteById(_id, session) {
|
|
54060
|
+
try {
|
|
54061
|
+
_id = new ObjectId130(_id);
|
|
54062
|
+
} catch {
|
|
54063
|
+
throw new BadRequestError210("Invalid post ID format.");
|
|
54064
|
+
}
|
|
54065
|
+
try {
|
|
54066
|
+
const res = await collection.updateOne(
|
|
54067
|
+
{ _id },
|
|
54068
|
+
{
|
|
54069
|
+
$set: {
|
|
54070
|
+
status: "deleted" /* DELETED */,
|
|
54071
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
54072
|
+
deletedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
54073
|
+
}
|
|
54074
|
+
},
|
|
54075
|
+
{ session }
|
|
54076
|
+
);
|
|
54077
|
+
if (res.modifiedCount === 0) {
|
|
54078
|
+
throw new InternalServerError74("Unable to delete post.");
|
|
54079
|
+
}
|
|
54080
|
+
return res.modifiedCount;
|
|
54081
|
+
} catch (error) {
|
|
54082
|
+
throw error;
|
|
54083
|
+
}
|
|
54084
|
+
}
|
|
54085
|
+
async function updateStatus(_id, status, session) {
|
|
54086
|
+
try {
|
|
54087
|
+
_id = new ObjectId130(_id);
|
|
54088
|
+
} catch {
|
|
54089
|
+
throw new BadRequestError210("Invalid post ID format.");
|
|
54090
|
+
}
|
|
54091
|
+
try {
|
|
54092
|
+
const res = await collection.updateOne(
|
|
54093
|
+
{ _id },
|
|
54094
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
54095
|
+
{ session }
|
|
54096
|
+
);
|
|
54097
|
+
if (res.modifiedCount === 0)
|
|
54098
|
+
throw new InternalServerError74("Unable to update post status.");
|
|
54099
|
+
return res;
|
|
54100
|
+
} catch (error) {
|
|
54101
|
+
throw error;
|
|
54102
|
+
}
|
|
54103
|
+
}
|
|
53972
54104
|
return {
|
|
53973
54105
|
add,
|
|
53974
54106
|
getById,
|
|
53975
|
-
getAll
|
|
54107
|
+
getAll,
|
|
54108
|
+
updateById,
|
|
54109
|
+
deleteById,
|
|
54110
|
+
updateStatus
|
|
53976
54111
|
};
|
|
53977
54112
|
}
|
|
53978
54113
|
|
|
@@ -53983,7 +54118,10 @@ function usePostPrelovedController() {
|
|
|
53983
54118
|
const {
|
|
53984
54119
|
add: _add,
|
|
53985
54120
|
getById: _getById,
|
|
53986
|
-
getAll: _getAll
|
|
54121
|
+
getAll: _getAll,
|
|
54122
|
+
updateById: _updateById,
|
|
54123
|
+
deleteById: _deleteById,
|
|
54124
|
+
updateStatus: _updateStatus
|
|
53987
54125
|
} = usePostPrelovedRepo();
|
|
53988
54126
|
async function add(req, res, next) {
|
|
53989
54127
|
const { error, value } = schemaPost.validate(req.body, {
|
|
@@ -54066,10 +54204,79 @@ function usePostPrelovedController() {
|
|
|
54066
54204
|
return;
|
|
54067
54205
|
}
|
|
54068
54206
|
}
|
|
54207
|
+
async function updateById(req, res, next) {
|
|
54208
|
+
const _id = req.params.id;
|
|
54209
|
+
const payload = { _id, ...req.body };
|
|
54210
|
+
const { error } = schemaUpdatePost.validate(payload, {
|
|
54211
|
+
abortEarly: false
|
|
54212
|
+
});
|
|
54213
|
+
if (error) {
|
|
54214
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
54215
|
+
logger186.log({ level: "error", message: messages });
|
|
54216
|
+
next(new BadRequestError211(messages));
|
|
54217
|
+
return;
|
|
54218
|
+
}
|
|
54219
|
+
try {
|
|
54220
|
+
const data = await _updateById(_id, req.body);
|
|
54221
|
+
res.status(200).json(data);
|
|
54222
|
+
return;
|
|
54223
|
+
} catch (error2) {
|
|
54224
|
+
logger186.log({ level: "error", message: error2.message });
|
|
54225
|
+
next(error2);
|
|
54226
|
+
return;
|
|
54227
|
+
}
|
|
54228
|
+
}
|
|
54229
|
+
async function deleteById(req, res, next) {
|
|
54230
|
+
const schema2 = Joi133.object({
|
|
54231
|
+
_id: Joi133.string().hex().length(24).required()
|
|
54232
|
+
});
|
|
54233
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
54234
|
+
if (error) {
|
|
54235
|
+
logger186.log({ level: "error", message: error.message });
|
|
54236
|
+
next(new BadRequestError211(error.message));
|
|
54237
|
+
return;
|
|
54238
|
+
}
|
|
54239
|
+
try {
|
|
54240
|
+
const data = await _deleteById(value._id);
|
|
54241
|
+
res.status(200).json({ message: "Successfully deleted post." });
|
|
54242
|
+
return;
|
|
54243
|
+
} catch (error2) {
|
|
54244
|
+
logger186.log({ level: "error", message: error2.message });
|
|
54245
|
+
next(error2);
|
|
54246
|
+
return;
|
|
54247
|
+
}
|
|
54248
|
+
}
|
|
54249
|
+
async function updateStatus(req, res, next) {
|
|
54250
|
+
const schema2 = Joi133.object({
|
|
54251
|
+
_id: Joi133.string().hex().length(24).required(),
|
|
54252
|
+
status: Joi133.string().valid(...Object.values(PostStatus)).required()
|
|
54253
|
+
});
|
|
54254
|
+
const { error, value } = schema2.validate({
|
|
54255
|
+
_id: req.params.id,
|
|
54256
|
+
status: req.body.status
|
|
54257
|
+
});
|
|
54258
|
+
if (error) {
|
|
54259
|
+
logger186.log({ level: "error", message: error.message });
|
|
54260
|
+
next(new BadRequestError211(error.message));
|
|
54261
|
+
return;
|
|
54262
|
+
}
|
|
54263
|
+
try {
|
|
54264
|
+
const data = await _updateStatus(value._id, value.status);
|
|
54265
|
+
res.status(200).json(data);
|
|
54266
|
+
return;
|
|
54267
|
+
} catch (error2) {
|
|
54268
|
+
logger186.log({ level: "error", message: error2.message });
|
|
54269
|
+
next(error2);
|
|
54270
|
+
return;
|
|
54271
|
+
}
|
|
54272
|
+
}
|
|
54069
54273
|
return {
|
|
54070
54274
|
add,
|
|
54071
54275
|
getById,
|
|
54072
|
-
getAll
|
|
54276
|
+
getAll,
|
|
54277
|
+
updateById,
|
|
54278
|
+
deleteById,
|
|
54279
|
+
updateStatus
|
|
54073
54280
|
};
|
|
54074
54281
|
}
|
|
54075
54282
|
export {
|
|
@@ -54296,6 +54503,7 @@ export {
|
|
|
54296
54503
|
schemaUpdatePatrolQuestion,
|
|
54297
54504
|
schemaUpdatePatrolRoute,
|
|
54298
54505
|
schemaUpdatePerson,
|
|
54506
|
+
schemaUpdatePost,
|
|
54299
54507
|
schemaUpdateServiceProviderBilling,
|
|
54300
54508
|
schemaUpdateSiteBillingConfiguration,
|
|
54301
54509
|
schemaUpdateSiteBillingItem,
|