@7365admin1/core 3.32.2-staging.4 → 3.32.2-staging.6

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 CHANGED
@@ -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(): {
@@ -7295,6 +7296,7 @@ declare function usePostFavoriteRepo(): {
7295
7296
  getById: (_id: string | ObjectId) => Promise<mongodb.WithId<TPostFavorite>>;
7296
7297
  getByPostId: (postId: string | ObjectId) => Promise<mongodb.WithId<TPostFavorite>>;
7297
7298
  updateById: (_id: string | ObjectId, userId: string | ObjectId, session?: any) => Promise<"removed" | "added">;
7299
+ createIndexes: () => Promise<string>;
7298
7300
  };
7299
7301
 
7300
7302
  declare function usePostFavoriteService(): {
@@ -7648,7 +7650,7 @@ declare function useFormEntryRepo(): {
7648
7650
  items: any[];
7649
7651
  pages: number;
7650
7652
  pageRange: string;
7651
- } | TFormEntry>;
7653
+ }>;
7652
7654
  };
7653
7655
 
7654
7656
  declare function useFormEntryController(): {
package/dist/index.js CHANGED
@@ -67073,6 +67073,26 @@ function usePostPrelovedRepo() {
67073
67073
  }
67074
67074
  };
67075
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
+ }
67076
67096
  function buildSortObj(filter) {
67077
67097
  switch (filter) {
67078
67098
  case "price-low-high":
@@ -67405,7 +67425,8 @@ function usePostPrelovedRepo() {
67405
67425
  getByOwnerId,
67406
67426
  updateById,
67407
67427
  deleteById,
67408
- updateStatus
67428
+ updateStatus,
67429
+ createIndexes
67409
67430
  };
67410
67431
  }
67411
67432
 
@@ -67481,6 +67502,16 @@ function usePostFavoriteRepo() {
67481
67502
  }
67482
67503
  const FAVORITE_COLLECTION = "post-favorites";
67483
67504
  const collection = db.collection(FAVORITE_COLLECTION);
67505
+ async function createIndexes() {
67506
+ try {
67507
+ await collection.createIndexes([{ key: { postId: 1 }, unique: true }]);
67508
+ return `Successfully created indexes for ${FAVORITE_COLLECTION}.`;
67509
+ } catch (error) {
67510
+ throw new import_node_server_utils238.InternalServerError(
67511
+ "Failed to create indexes on post-favorites."
67512
+ );
67513
+ }
67514
+ }
67484
67515
  async function addFavorite(value, session) {
67485
67516
  try {
67486
67517
  const doc = MPostFavorite(value);
@@ -67549,7 +67580,8 @@ function usePostFavoriteRepo() {
67549
67580
  addFavorite,
67550
67581
  getById,
67551
67582
  getByPostId,
67552
- updateById
67583
+ updateById,
67584
+ createIndexes
67553
67585
  };
67554
67586
  }
67555
67587
 
@@ -69812,15 +69844,6 @@ function useFormEntryRepo() {
69812
69844
  const user = new import_mongodb153.ObjectId(userId);
69813
69845
  const siteId = new import_mongodb153.ObjectId(site);
69814
69846
  const orgId = new import_mongodb153.ObjectId(org);
69815
- const cacheOptions = {
69816
- page,
69817
- limit,
69818
- sort: JSON.stringify(sort),
69819
- userId: user,
69820
- site: siteId,
69821
- org: orgId,
69822
- ...search && { search }
69823
- };
69824
69847
  const query = {
69825
69848
  userId: user,
69826
69849
  site: siteId,
@@ -69832,15 +69855,6 @@ function useFormEntryRepo() {
69832
69855
  { unitNumber: { $regex: search, $options: "i" } }
69833
69856
  ];
69834
69857
  }
69835
- const cacheKey = (0, import_node_server_utils256.makeCacheKey)(
69836
- online_forms_namespace_collection,
69837
- cacheOptions
69838
- );
69839
- const cachedData = await getCache(cacheKey);
69840
- if (cachedData) {
69841
- import_node_server_utils256.logger.info(`Cache hit for key: ${cacheKey}`);
69842
- return cachedData;
69843
- }
69844
69858
  try {
69845
69859
  const items = await collection.aggregate([
69846
69860
  { $match: query },
@@ -69850,11 +69864,6 @@ function useFormEntryRepo() {
69850
69864
  ]).toArray();
69851
69865
  const length = await collection.countDocuments(query);
69852
69866
  const data = (0, import_node_server_utils256.paginate)(items, page, limit, length);
69853
- setCache(cacheKey, data, 15 * 60).then(() => {
69854
- import_node_server_utils256.logger.info(`Cache set for key: ${cacheKey}`);
69855
- }).catch((err) => {
69856
- import_node_server_utils256.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
69857
- });
69858
69867
  return data;
69859
69868
  } catch (error) {
69860
69869
  throw error;