@7365admin1/core 3.32.2-staging.3 → 3.32.2-staging.5
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/dist/index.d.ts +3 -2
- package/dist/index.js +56 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2965,7 +2965,7 @@ declare function useVisitorTransactionRepo(): {
|
|
|
2965
2965
|
pageRange: string;
|
|
2966
2966
|
}>;
|
|
2967
2967
|
getOpenByPlateNumber: (plateNumber: string, site: string | ObjectId) => Promise<TVisitorTransaction | null | undefined>;
|
|
2968
|
-
updateById: (_id: string | ObjectId, value: Partial<TVisitorTransaction>, session?: ClientSession, isManualCheckOut?: boolean) => Promise<mongodb.UpdateResult<bson.Document
|
|
2968
|
+
updateById: (_id: string | ObjectId, value: Partial<TVisitorTransaction>, session?: ClientSession, isManualCheckOut?: boolean) => Promise<mongodb.UpdateResult<bson.Document> | undefined>;
|
|
2969
2969
|
deleteVisitorTransaction: (_id: string | ObjectId) => Promise<number>;
|
|
2970
2970
|
createTextIndex: () => Promise<void>;
|
|
2971
2971
|
getDeliveryPickupTransactions: () => Promise<mongodb.WithId<bson.Document>[]>;
|
|
@@ -7261,6 +7261,7 @@ declare function usePostPrelovedRepo(): {
|
|
|
7261
7261
|
updateById: (_id: string | ObjectId, value: Partial<TPost>, session?: any) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
7262
7262
|
deleteById: (_id: string | ObjectId, session?: any) => Promise<number>;
|
|
7263
7263
|
updateStatus: (_id: string | ObjectId, status: PostStatus, session?: any) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
7264
|
+
createIndexes: () => Promise<string>;
|
|
7264
7265
|
};
|
|
7265
7266
|
|
|
7266
7267
|
declare function usePostPrelovedController(): {
|
|
@@ -7648,7 +7649,7 @@ declare function useFormEntryRepo(): {
|
|
|
7648
7649
|
items: any[];
|
|
7649
7650
|
pages: number;
|
|
7650
7651
|
pageRange: string;
|
|
7651
|
-
}
|
|
7652
|
+
}>;
|
|
7652
7653
|
};
|
|
7653
7654
|
|
|
7654
7655
|
declare function useFormEntryController(): {
|
package/dist/index.js
CHANGED
|
@@ -22137,7 +22137,14 @@ function useVisitorTransactionRepo() {
|
|
|
22137
22137
|
}
|
|
22138
22138
|
});
|
|
22139
22139
|
if (Array.isArray(value.visitorPass)) {
|
|
22140
|
-
|
|
22140
|
+
const visitorPassMap = /* @__PURE__ */ new Map();
|
|
22141
|
+
value.visitorPass.forEach((item) => {
|
|
22142
|
+
if (item.keyId) {
|
|
22143
|
+
visitorPassMap.set(item.keyId.toString(), item);
|
|
22144
|
+
}
|
|
22145
|
+
});
|
|
22146
|
+
const uniqueVisitorPass = Array.from(visitorPassMap.values());
|
|
22147
|
+
uniqueVisitorPass.forEach((item, index) => {
|
|
22141
22148
|
if (item.add === true) {
|
|
22142
22149
|
const { add: add2, ...cleanItem } = item;
|
|
22143
22150
|
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Pass Id");
|
|
@@ -22150,8 +22157,7 @@ function useVisitorTransactionRepo() {
|
|
|
22150
22157
|
Object.keys(item).forEach((itemKey) => {
|
|
22151
22158
|
if (itemKey !== "keyId") {
|
|
22152
22159
|
const typedItemKey = itemKey;
|
|
22153
|
-
|
|
22154
|
-
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
22160
|
+
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = item[typedItemKey];
|
|
22155
22161
|
}
|
|
22156
22162
|
});
|
|
22157
22163
|
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
@@ -22159,7 +22165,14 @@ function useVisitorTransactionRepo() {
|
|
|
22159
22165
|
});
|
|
22160
22166
|
}
|
|
22161
22167
|
if (Array.isArray(value.passKeys)) {
|
|
22162
|
-
|
|
22168
|
+
const passKeysMap = /* @__PURE__ */ new Map();
|
|
22169
|
+
value.passKeys.forEach((item) => {
|
|
22170
|
+
if (item.keyId) {
|
|
22171
|
+
passKeysMap.set(item.keyId.toString(), item);
|
|
22172
|
+
}
|
|
22173
|
+
});
|
|
22174
|
+
const uniquePassKeys = Array.from(passKeysMap.values());
|
|
22175
|
+
uniquePassKeys.forEach((item, index) => {
|
|
22163
22176
|
if (item.add === true) {
|
|
22164
22177
|
const { add: add2, ...cleanItem } = item;
|
|
22165
22178
|
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Key Id");
|
|
@@ -22172,32 +22185,34 @@ function useVisitorTransactionRepo() {
|
|
|
22172
22185
|
Object.keys(item).forEach((itemKey) => {
|
|
22173
22186
|
if (itemKey !== "keyId") {
|
|
22174
22187
|
const typedItemKey = itemKey;
|
|
22175
|
-
|
|
22176
|
-
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
22188
|
+
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = item[typedItemKey];
|
|
22177
22189
|
}
|
|
22178
22190
|
});
|
|
22179
22191
|
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
22180
22192
|
}
|
|
22181
22193
|
});
|
|
22182
22194
|
}
|
|
22183
|
-
|
|
22195
|
+
let result;
|
|
22184
22196
|
if (Object.keys(updateFields).length > 0) {
|
|
22185
|
-
|
|
22197
|
+
result = await collection.updateOne(
|
|
22198
|
+
{ _id: new import_mongodb41.ObjectId(_id) },
|
|
22199
|
+
{ $set: updateFields },
|
|
22200
|
+
{
|
|
22201
|
+
...arrayFilters.length > 0 && { arrayFilters },
|
|
22202
|
+
session
|
|
22203
|
+
}
|
|
22204
|
+
);
|
|
22186
22205
|
}
|
|
22187
22206
|
if (Object.keys(pushFields).length > 0) {
|
|
22188
|
-
|
|
22207
|
+
result = await collection.updateOne(
|
|
22208
|
+
{ _id: new import_mongodb41.ObjectId(_id) },
|
|
22209
|
+
{ $push: pushFields },
|
|
22210
|
+
{ session }
|
|
22211
|
+
);
|
|
22189
22212
|
}
|
|
22190
|
-
const result = await collection.updateOne(
|
|
22191
|
-
{ _id: new import_mongodb41.ObjectId(_id) },
|
|
22192
|
-
updatePayload,
|
|
22193
|
-
{
|
|
22194
|
-
...arrayFilters.length > 0 && { arrayFilters },
|
|
22195
|
-
// Only pass if not empty
|
|
22196
|
-
session
|
|
22197
|
-
}
|
|
22198
|
-
);
|
|
22199
22213
|
return result;
|
|
22200
22214
|
} catch (error) {
|
|
22215
|
+
console.log("Error in updateById visitor transaction repo", error);
|
|
22201
22216
|
throw error;
|
|
22202
22217
|
}
|
|
22203
22218
|
}
|
|
@@ -35469,7 +35484,7 @@ function useVisitorTransactionService() {
|
|
|
35469
35484
|
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
35470
35485
|
status = item.status;
|
|
35471
35486
|
} else {
|
|
35472
|
-
throw new Error("Invalid
|
|
35487
|
+
throw new Error("Invalid Key Status");
|
|
35473
35488
|
}
|
|
35474
35489
|
await KeyRepo.updateKeyById(
|
|
35475
35490
|
item.keyId,
|
|
@@ -67058,6 +67073,26 @@ function usePostPrelovedRepo() {
|
|
|
67058
67073
|
}
|
|
67059
67074
|
};
|
|
67060
67075
|
const collection = db.collection(POST_COLLECTION);
|
|
67076
|
+
async function createIndexes() {
|
|
67077
|
+
try {
|
|
67078
|
+
await collection.createIndexes([
|
|
67079
|
+
// getAll: site browse filtered by status, sorted by recency (default sort)
|
|
67080
|
+
{ key: { site: 1, status: 1, createdAt: -1 } },
|
|
67081
|
+
// getAll: global browse (no site) sorted by recency
|
|
67082
|
+
{ key: { status: 1, createdAt: -1 } },
|
|
67083
|
+
// getByOwnerId: a user's own posts, sorted by recency
|
|
67084
|
+
{ key: { createdBy: 1, status: 1, createdAt: -1 } },
|
|
67085
|
+
// category / subcategory faceted filtering
|
|
67086
|
+
{ key: { category: 1, status: 1 } },
|
|
67087
|
+
{ key: { subcategory: 1, status: 1 } }
|
|
67088
|
+
]);
|
|
67089
|
+
return `Successfully created indexes for ${POST_COLLECTION}.`;
|
|
67090
|
+
} catch (error) {
|
|
67091
|
+
throw new import_node_server_utils237.InternalServerError(
|
|
67092
|
+
"Failed to create indexes on post-preloved."
|
|
67093
|
+
);
|
|
67094
|
+
}
|
|
67095
|
+
}
|
|
67061
67096
|
function buildSortObj(filter) {
|
|
67062
67097
|
switch (filter) {
|
|
67063
67098
|
case "price-low-high":
|
|
@@ -67390,7 +67425,8 @@ function usePostPrelovedRepo() {
|
|
|
67390
67425
|
getByOwnerId,
|
|
67391
67426
|
updateById,
|
|
67392
67427
|
deleteById,
|
|
67393
|
-
updateStatus
|
|
67428
|
+
updateStatus,
|
|
67429
|
+
createIndexes
|
|
67394
67430
|
};
|
|
67395
67431
|
}
|
|
67396
67432
|
|
|
@@ -69797,15 +69833,6 @@ function useFormEntryRepo() {
|
|
|
69797
69833
|
const user = new import_mongodb153.ObjectId(userId);
|
|
69798
69834
|
const siteId = new import_mongodb153.ObjectId(site);
|
|
69799
69835
|
const orgId = new import_mongodb153.ObjectId(org);
|
|
69800
|
-
const cacheOptions = {
|
|
69801
|
-
page,
|
|
69802
|
-
limit,
|
|
69803
|
-
sort: JSON.stringify(sort),
|
|
69804
|
-
userId: user,
|
|
69805
|
-
site: siteId,
|
|
69806
|
-
org: orgId,
|
|
69807
|
-
...search && { search }
|
|
69808
|
-
};
|
|
69809
69836
|
const query = {
|
|
69810
69837
|
userId: user,
|
|
69811
69838
|
site: siteId,
|
|
@@ -69817,15 +69844,6 @@ function useFormEntryRepo() {
|
|
|
69817
69844
|
{ unitNumber: { $regex: search, $options: "i" } }
|
|
69818
69845
|
];
|
|
69819
69846
|
}
|
|
69820
|
-
const cacheKey = (0, import_node_server_utils256.makeCacheKey)(
|
|
69821
|
-
online_forms_namespace_collection,
|
|
69822
|
-
cacheOptions
|
|
69823
|
-
);
|
|
69824
|
-
const cachedData = await getCache(cacheKey);
|
|
69825
|
-
if (cachedData) {
|
|
69826
|
-
import_node_server_utils256.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
69827
|
-
return cachedData;
|
|
69828
|
-
}
|
|
69829
69847
|
try {
|
|
69830
69848
|
const items = await collection.aggregate([
|
|
69831
69849
|
{ $match: query },
|
|
@@ -69835,11 +69853,6 @@ function useFormEntryRepo() {
|
|
|
69835
69853
|
]).toArray();
|
|
69836
69854
|
const length = await collection.countDocuments(query);
|
|
69837
69855
|
const data = (0, import_node_server_utils256.paginate)(items, page, limit, length);
|
|
69838
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
69839
|
-
import_node_server_utils256.logger.info(`Cache set for key: ${cacheKey}`);
|
|
69840
|
-
}).catch((err) => {
|
|
69841
|
-
import_node_server_utils256.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
69842
|
-
});
|
|
69843
69856
|
return data;
|
|
69844
69857
|
} catch (error) {
|
|
69845
69858
|
throw error;
|