@7365admin1/core 3.32.2-staging.72 → 3.32.2-staging.74

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
@@ -9520,10 +9520,26 @@ declare function MNotification(value: TNotification): {
9520
9520
  declare function useNotificationRepo(): {
9521
9521
  createIndexes: () => Promise<string>;
9522
9522
  addMany: (userIds: string[], base: Omit<TNotification, "_id" | "userId">) => Promise<number>;
9523
+ getByUserId: ({ userId, appSlug, page, limit, hasRead, siteId, search, }: {
9524
+ userId: string;
9525
+ appSlug?: string | undefined;
9526
+ page?: number | undefined;
9527
+ limit?: number | undefined;
9528
+ hasRead?: boolean | undefined;
9529
+ siteId?: string | undefined;
9530
+ search?: string | undefined;
9531
+ }) => Promise<{
9532
+ items: any[];
9533
+ pages: number;
9534
+ pageRange: string;
9535
+ }>;
9536
+ markAsReadById: (_id: string, userId: string) => Promise<mongodb.WithId<TNotification>>;
9523
9537
  };
9524
9538
 
9525
9539
  declare function useNotificationController(): {
9526
9540
  add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9541
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9542
+ markAsRead: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9527
9543
  };
9528
9544
 
9529
9545
  export { ANPRMode, AccessTypeProps, AppServiceType, AssignCardConfig, BidStatus, BidType, BuildingLevelStatus, BuildingStatus, BulkCardUpdate, BulletinOrder, BulletinRecipient, BulletinSort, BulletinStatus, BulletinVideoOrder, BulletinVideoSort, CAMERA_ANPR_PERMISSIONS, CAMERA_CAPABILITIES, CAMERA_CAPABILITY_REASONS, CAMERA_NOT_PATROL_OR_CCTV, CAMERA_PTZ_PERMISSIONS, CAMERA_REQUEST_TIMEOUT_MS, CAMERA_RTSP_TIMEOUT_MS, CAMERA_SETUP_PERMISSIONS, CAMERA_SNAPSHOT_CACHE_SECONDS, CAMERA_SNAPSHOT_MAX_BYTES, CAMERA_TEST_MIN_INTERVAL_SECONDS, CAMERA_TEST_ROUND_LIMIT, CAMERA_TEST_ROUND_SECONDS, CAMERA_TYPE_ANPR, CAMERA_TYPE_IP, CAMERA_VIEW_PERMISSIONS, CLOCK_DRIFT_WARN_SECONDS, CURRENT_TIME_ENDPOINT, Camera, CameraAddressInput, CameraCapability, CameraCapabilityContext, CameraCapabilityDescriptor, CameraCapabilityEntry, CameraCapabilityReason, CameraCapabilityState, CameraCapabilityTrace, CameraDevice, CameraMembership, CameraTestStatus, CameraTransport, CameraType, DEVICE_STATUS, DOBStatus, DayOfWeek, DeviceHttpTarget, DeviceProbeResult, DynamicFormFields, EAccessCardTypes, EAccessCardUserTypes, EmailSender, EntryOrder, EntrySort, EventOrder, EventSort, EventStatus, EventType, FacilitySort, FacilityStatus, FormEntryStatus, GuestSort, GuestStatus, HID_PERMISSION_CATEGORIES, IAccessCard, IAccessCardTransaction, MAX_CAMERA_CHANNEL, MAccessCard, MAccessCardTransaction, MAddress, MAttendance, MAttendanceSettings, MBidPreloved, MBillingConfiguration, MBillingItem, MBuilding, MBuildingLevel, MBuildingUnit, MBulletinBoard, MBulletinVideo, MCategoryPreloved, MChannelPreloved, MChat, MChatPreloved, MCustomer, MCustomerSite, MDocumentManagement, MEntryPassSettings, MEventManagement, MFeedback, MFile, MFormEntry, MGuestManagement, MHidAmicoEvent, MHidAmicoIdentity, MHidAmicoReader, MHidSipAccount, MHidSitePermissions, MIncidentReport, MManpowerDesignations, MManpowerMonitoring, MManpowerRemarks, MManpowerSites, MMember, MNfcPatrolLog, MNfcPatrolRoute, MNfcPatrolSettings, MNfcPatrolSettingsUpdate, MNfcPatrolTag, MNotification, MOccurrenceBook, MOccurrenceEntry, MOccurrenceSubject, MOnlineForm, MOrg, MOvernightParkingApprovalHours, MOvernightParkingRequest, MPatrolLog, MPatrolQuestion, MPatrolRoute, MPerson, MPost, MPostFavorite, MPromoCode, MRobot, MRole, MRoleV2, MServiceProvider, MServiceProviderBilling, MSession, MSite, MSiteCamera, MSiteFacility, MSiteFacilityBooking, MStatementOfAccount, MSubcategoryPreloved, MSubscription, MUnitBilling, MUser, MVehicle, MVehicleTransaction, MVerification, MVerificationV2, MVisitorTransaction, MWorkOrder, NotificationAppSlug, NotificationModule, OrgNature, OvernightParkingRequestSort, OvernightParkingRequestStatus, PATROL_CCTV_CAMERA_FILTER, PERSON_TYPES, PStatus, PTZ_ALLOWED_ACTIONS, PTZ_ALLOWED_CODES, Period, PersonStatus, PersonType, PersonTypes, PostOrder, PostSort, PostStatus, QrTagProps, ResidentAppModuleKey, SOFTWARE_VERSION_ENDPOINT, SiteAddress, SiteCategories, SiteStatus, SortFields, SortOrder, Status, SubjectOrder, SubjectSort, SubscriptionType, TAccessMngmntSettings, TActionStatus, TAddress, TAffectedEntities, TAffectedInjured, TAppServiceType, TApprovedBy, TApprover, TAttendance, TAttendanceCheckIn, TAttendanceCheckOut, TAttendanceCheckTime, TAttendanceLocation, TAttendanceSettings, TAttendanceSettingsGetBySite, TAuthorities, TAuthoritiesCalled, TBidPreloved, TBilling, TBillingConfiguration, TBillingItem, TBuilding, TBuildingLevel, TBuildingUnit, TBulletinBoard, TBulletinVideo, TCamera, TCategoryPreloved, TChannelPreloved, TChat, TChatPreloved, TCheckPoint$1 as TCheckPoint, TComplaintInfo, TComplaintReceivedTo, TCounter, TCreateNfcPatrolLog, TCustomer, TCustomerSite, TDayNumber, TDaySchedule, TDefaultAccessCard, TDesignations, TDocs, TDocumentCreate, TDocumentManagement, TEntryPassSettings, TEventManagement, TFeedback, TFeedbackMetadata, TFeedbackUpdate, TFeedbackUpdateCategory, TFeedbackUpdateServiceProvider, TFeedbackUpdateStatus, TFeedbackUpdateToCompleted, TFile, TFiles, TFolderUpdate, TFormEntry, TGetAttendancesByUserQuery, TGetAttendancesQuery, TGuestManagement, THidAmicoEvent, THidAmicoIdentity, THidAmicoReader, THidPermissionAssignment, THidPermissionCategory, THidSipAccount, THidSitePermissions, TIncidentInformation, TIncidentReport, TIncidentTypeAndTime, TInvoice, TKeyRef, TManpowerDesignations, TManpowerDesignationsUpdate, TManpowerMonitoring, TManpowerMonitoringUpdate, TManpowerRemarks, TManpowerRemarksStatusUpdate, TManpowerRemarksUpdate, TManpowerSearchFilter, TManpowerSites, TMember, TMemberUpdateStatus, TMessagePreloved, TMiniRole, TNfcPatrolLog, TNfcPatrolRoute, TNfcPatrolRouteEdit, TNfcPatrolSettings, TNfcPatrolSettingsGetBySite, TNfcPatrolSettingsUpdate, TNfcPatrolTag, TNfcPatrolTagConfigureReset, TNfcPatrolTagEdit, TNfcPatrolTagUpdateData, TNotification, TOccurrenceBook, TOccurrenceEntry, TOccurrenceSubject, TOnlineForm, TOrg, TOvernightParkingApprovalHours, TOvernightParkingRequest, TPatrolLog, TPatrolQuestion, TPatrolRoute, TPerson, TPlaceOfIncident, TPlates, TPost, TPostFavorite, TPrice, TPriceType, TPromoCode, TPromoTier, TRANSPORT_DEVICE_HTTP, TRANSPORT_RELAY_PLAYER, TRANSPORT_RTSP_FRAME, TRecipientOfComplaint, TRemarks, TResident, TResidentAppModules, TRobot, TRobotMetadata, TRole, TRoleV2, TRoute, TSOABillingItem, TSOAStatus, TServiceProvider, TServiceProviderBilling, TSession, TSessionCreate, TShifts, TSignNfcPatrolLog, TSite, TSiteCamera, TSiteFacility, TSiteFacilityBooking, TSiteInfo, TSiteInformation, TSiteMetadata, TSiteUpdateBlock, TStatementOfAccount, TSubcategoryPreloved, TSubmissionForm, TSubscription, TUnitBilling, TUnits, TUpdateFormEntry, TUpdateName, TUser, TUserCreate, TVehicle, TVehicleTransaction, TVehicleUpdate, TVerification, TVerificationMetadata, TVerificationMetadataV2, TVerificationV2, TVisitorTransaction, TWorkOrder, TWorkOrderMetadata, TWorkOrderUpdate, TWorkOrderUpdateStatus, TWorkOrderUpdateToCompleted, TanyoneDamageToProperty, UseAccessManagementRepo, UserStatus, VehicleCategory, VehicleOrder, VehicleSort, VehicleStatus, VehicleType, VerificationLinkType, VerificationStatus, VerificationSubjectType, VerificationType, VisitorSort, VisitorStatus, addressSchema, allowedFieldsSite, allowedNatures, attendanceSchema, attendanceSettingsSchema, building_level_namespace_collection, building_units_namespace_collection, buildings_namespace_collection, bulletin_boards_namespace_collection, cameraBaseUrl, cameraCapabilitiesFor, cameraDevices, cameraGrant, cameraHealthSummary, cameraManagePermissions, cameraTransports, chatPrelovedEvents, chatSchema, clampPtzSpeed, clockDriftSeconds, createManpowerRemarksDaily, customerSchema, deriveCameraHost, describeCameraCapabilities, designationsSchema, deviceControlEnabled, deviceHttpEnabled, deviceHttpTargets, deviceHttpTimeoutMs, deviceProbeTtlSeconds, events_namespace_collection, facility_bookings_namespace_collection, feedbackSchema, feedbacks2_namespace_collection, feedbacks_namespace_collection, ffmpegFrameArgs, ffmpegPath, formatCapabilityTrace, formatDahuaDate, guests_namespace_collection, hasAnyCapability, hasAnyPermission, incidentReport, incidentReportLog, incidents_namespace_collection, isCameraEntitled, isPatrolCctvCamera, isRelayPlayerUrl, logCamera, manpowerDesignationsSchema, manpowerEvents, manpowerMonitoringSchema, manpowerRemarksSchema, manpowerSitesSchema, mapWithLimit, nfcPatrolSettingsSchema, nfcPatrolSettingsSchemaUpdate, occurrence_book_namespace_collection, online_forms_namespace_collection, orgSchema, overnight_parking_requests_namespace_collection, parseCameraChannel, parseCameraHost, parseDahuaFind, parseDeviceTime, parseSoftwareVersion, promoCodeSchema, ptzEndpoint, publicCameraFields, registerCameraTransport, relayForRecorder, remarksSchema, resetCameraTransports, residentAppModuleKeys, residentFormEntry, resolutionRefusalReason, resolveCamera, resolveDeviceHttp, robotSchema, rtspUrl, schema, schemaAppSlugNotification, schemaApprovedBy, schemaApprover, schemaBidPreloved, schemaBilling, schemaBillingConfiguration, schemaBillingItem, schemaBuilding, schemaBuildingLevel, schemaBuildingUnit, schemaBuildingUpdateOptions, schemaBulletinBoard, schemaBulletinVideo, schemaCategoryPreloved, schemaChannelPreloved, schemaChatPreloved, schemaCreateHidAmicoIdentity, schemaCreateNfcPatrolLog, schemaCreateNotification, schemaCustomerSite, schemaDocumentManagement, schemaEntryPassSettings, schemaEventManagement, schemaFiles, schemaFormEntry, schemaGuestManagement, schemaHidAmicoConfiguration, schemaHidAmicoEvent, schemaHidAmicoExecuteActions, schemaHidAmicoIdentity, schemaHidAmicoIdentityIdParams, schemaHidAmicoIdentityQuery, schemaHidAmicoIntercomCall, schemaHidAmicoLogQuery, schemaHidAmicoNotificationParams, schemaHidAmicoObjectOperation, schemaHidAmicoReader, schemaHidAmicoReaderIdParams, schemaHidAmicoReaderListQuery, schemaHidAmicoSetConfiguration, schemaHidAmicoSiteIdParams, schemaHidAmicoSync, schemaHidAmicoUserImageParams, schemaHidAmicoUserImageUploadQuery, schemaHidAmicoVisitorImageParams, schemaHidAmicoVisitorImageUploadQuery, schemaHidAmicoVisitorQr, schemaHidPermissionCandidateQuery, schemaHidPermissionScopeQuery, schemaHidSipAccountRequest, schemaIncidentReport, schemaListNotification, schemaMultipleDocumentManagement, schemaNfcPatrolLog, schemaNfcPatrolRoute, schemaNfcPatrolTag, schemaNfcPatrolTagUpdateData, schemaNotification, schemaOccurrenceBook, schemaOccurrenceEntry, schemaOccurrenceSubject, schemaOnlineForm, schemaOvernightParkingApprovalHours, schemaOvernightParkingRequest, schemaPatrolLog, schemaPatrolQuestion, schemaPatrolRoute, schemaPerson, schemaPlate, schemaPost, schemaPostFavorite, schemaServiceProvider, schemaServiceProviderBilling, schemaSignNfcPatrolLog, schemaSiteCamera, schemaSiteFacility, schemaSiteFacilityBooking, schemaStatementOfAccount, schemaSubcategoryPreloved, schemaUnitBilling, schemaUpdateBidPreloved, schemaUpdateBuildingLevel, schemaUpdateBulletinBoard, schemaUpdateBulletinVideo, schemaUpdateCategoryPreloved, schemaUpdateChatPreloved, schemaUpdateDocumentManagement, schemaUpdateEntryPassSettings, schemaUpdateEventManagement, schemaUpdateFolderManagement, schemaUpdateFormEntry, schemaUpdateGuestManagement, schemaUpdateHidAmicoIdentity, schemaUpdateHidAmicoReader, schemaUpdateHidSitePermissions, schemaUpdateIncidentReport, schemaUpdateNotification, schemaUpdateOccurrenceBook, schemaUpdateOccurrenceEntry, schemaUpdateOccurrenceSubject, schemaUpdateOnlineForm, schemaUpdateOptions, schemaUpdateOvernightParkingRequest, schemaUpdatePatrolLog, schemaUpdatePatrolQuestion, schemaUpdatePatrolRoute, schemaUpdatePerson, schemaUpdatePost, schemaUpdatePostFavorite, schemaUpdateServiceProviderBilling, schemaUpdateSiteBillingConfiguration, schemaUpdateSiteBillingItem, schemaUpdateSiteCamera, schemaUpdateSiteFacility, schemaUpdateSiteFacilityBooking, schemaUpdateSiteUnitBilling, schemaUpdateStatementOfAccount, schemaUpdateSubcategoryPreloved, schemaUpdateVisTrans, schemaVehicleTransaction, schemaVisitorTransaction, schemeCamera, schemeLogCamera, sessionSchema, shiftSchema, siteSchema, site_people_namespace_collection, snapshotEndpoint, snapshotRefusalReason, updateRemarksStatusEod, updateRemarksisAcknowledged, updateSiteSchema, useAccessManagementController, useAddressRepo, useAttendanceController, useAttendanceRepository, useAttendanceSettingsController, useAttendanceSettingsRepository, useAttendanceSettingsService, useAuthController, useAuthControllerV2, useAuthService, useAuthServiceV2, useBidPrelovedController, useBidPrelovedRepo, useBidPrelovedService, useBuildingController, useBuildingLevelController, useBuildingLevelRepo, useBuildingLevelService, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useBulletinBoardController, useBulletinBoardRepo, useBulletinBoardService, useBulletinVideoController, useBulletinVideoRepo, useBulletinVideoService, useCameraViewController, useCameraViewService, useCategoryPrelovedController, useCategoryPrelovedRepo, useChannelPrelovedController, useChannelPrelovedRepo, useChatController, useChatPrelovedController, useChatPrelovedRepo, useChatPrelovedService, useChatRepo, useCounterModel, useCounterRepo, useCustomerController, useCustomerRepo, useCustomerSiteController, useCustomerSiteRepo, useCustomerSiteService, useDahuaService, useDashboardController, useDashboardRepo, useDocumentManagementController, useDocumentManagementRepo, useDocumentManagementService, useEntryPassSettingsController, useEntryPassSettingsRepo, useEventManagementController, useEventManagementRepo, useEventManagementService, useFeedbackController, useFeedbackRepo, useFeedbackService, useFileController, useFileRepo, useFileService, useFormEntryController, useFormEntryRepo, useGuestManagementController, useGuestManagementRepo, useGuestManagementService, useHidAmicoController, useHidAmicoRepo, useHidAmicoService, useHrmLabsAttendanceCtrl, useHrmLabsAttendanceSrvc, useIncidentReportController, useIncidentReportRepo, useIncidentReportService, useInvoiceController, useInvoiceModel, useInvoiceRepo, useManpowerDesignationCtrl, useManpowerDesignationRepo, useManpowerMonitoringCtrl, useManpowerMonitoringRepo, useManpowerMonitoringSrvc, useManpowerRemarkCtrl, useManpowerRemarksRepo, useManpowerSitesCtrl, useManpowerSitesRepo, useManpowerSitesSrvc, useMemberController, useMemberRepo, useMemberService, useNewDashboardController, useNewDashboardRepo, useNfcPatrolLogController, useNfcPatrolLogRepo, useNfcPatrolLogService, useNfcPatrolRouteController, useNfcPatrolRouteRepo, useNfcPatrolRouteService, useNfcPatrolSettingsController, useNfcPatrolSettingsRepository, useNfcPatrolSettingsService, useNfcPatrolTagController, useNfcPatrolTagRepo, useNfcPatrolTagService, useNotificationController, useNotificationRepo, useOccurrenceBookController, useOccurrenceBookRepo, useOccurrenceBookService, useOccurrenceEntryController, useOccurrenceEntryRepo, useOccurrenceEntryService, useOccurrenceSubjectController, useOccurrenceSubjectRepo, useOccurrenceSubjectService, useOnlineFormController, useOnlineFormRepo, useOrgController, useOrgControllerV2, useOrgRepo, useOvernightParkingController, useOvernightParkingRepo, useOvernightParkingRequestController, useOvernightParkingRequestRepo, useOvernightParkingRequestService, usePatrolLogController, usePatrolLogRepo, usePatrolQuestionController, usePatrolQuestionRepo, usePatrolRouteController, usePatrolRouteRepo, usePersonController, usePersonRepo, usePostFavoriteController, usePostFavoriteRepo, usePostFavoriteService, usePostPrelovedController, usePostPrelovedRepo, usePriceController, usePriceModel, usePriceRepo, usePromoCodeController, usePromoCodeRepo, useRedDotPaymentController, useRedDotPaymentRepo, useRedDotPaymentSvc, useRobotController, useRobotRepo, useRobotService, useRoleController, useRoleControllerV2, useRoleRepo, useRoleRepoV2, useRoleServiceV2, useServiceProviderBillingController, useServiceProviderBillingRepo, useServiceProviderBillingService, useServiceProviderController, useServiceProviderRepo, useSessionRepo, useSiteBillingConfigurationController, useSiteBillingConfigurationRepo, useSiteBillingItemController, useSiteBillingItemRepo, useSiteCameraController, useSiteCameraRepo, useSiteCameraService, useSiteController, useSiteFacilityBookingController, useSiteFacilityBookingRepo, useSiteFacilityBookingService, useSiteFacilityController, useSiteFacilityRepo, useSiteFacilityService, useSiteRepo, useSiteService, useSiteUnitBillingController, useSiteUnitBillingRepo, useSiteUnitBillingService, useStatementOfAccountController, useStatementOfAccountRepo, useSubcategoryPrelovedController, useSubcategoryPrelovedRepo, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useUserController, useUserControllerV2, useUserRepo, useUserRepoV2, useUserService, useUserServiceV2, useVehicleController, useVehicleRepo, useVehicleService, useVerificationController, useVerificationControllerV2, useVerificationRepo, useVerificationRepoV2, useVerificationService, useVerificationServiceV2, useVisitorTransactionController, useVisitorTransactionRepo, useVisitorTransactionService, useWorkOrderController, useWorkOrderRepo, useWorkOrderService, userSchema, vehicleSchema, vehicles_namespace_collection, visitorPersonRepo, visitorPersonService, visitorType, visitors_namespace_collection, wallConfig, workOrderSchema, work_orders2_namespace_collection, work_orders_namespace_collection };
package/dist/index.js CHANGED
@@ -38071,6 +38071,7 @@ var schemaNotification = import_joi58.default.object({
38071
38071
  });
38072
38072
  var schemaUpdateNotification = import_joi58.default.object({
38073
38073
  _id: import_joi58.default.string().hex().length(24).required(),
38074
+ user: import_joi58.default.string().hex().length(24).required(),
38074
38075
  hasRead: import_joi58.default.boolean().optional()
38075
38076
  });
38076
38077
  var schemaCreateNotification = import_joi58.default.object({
@@ -38088,8 +38089,9 @@ var schemaListNotification = import_joi58.default.object({
38088
38089
  limit: import_joi58.default.number().integer().min(1).max(50).allow("", null).default(10),
38089
38090
  search: import_joi58.default.string().trim().optional().allow("", null).default(""),
38090
38091
  hasRead: schemaNotification.extract("hasRead").allow("", null),
38091
- module: schemaNotification.extract("module"),
38092
- appSlug: schemaNotification.extract("appSlug")
38092
+ siteId: schemaNotification.extract("siteId"),
38093
+ appSlug: schemaNotification.extract("appSlug"),
38094
+ user: import_joi58.default.string().hex().length(24).optional()
38093
38095
  });
38094
38096
  var schemaAppSlugNotification = import_joi58.default.object({
38095
38097
  appSlug: schemaNotification.extract("appSlug")
@@ -38168,10 +38170,10 @@ function useNotificationRepo() {
38168
38170
  key: {
38169
38171
  userId: 1,
38170
38172
  appSlug: 1,
38171
- module: 1,
38173
+ siteId: 1,
38172
38174
  createdAt: -1
38173
38175
  },
38174
- name: "inbox_list_by_module"
38176
+ name: "inbox_list_by_site"
38175
38177
  }
38176
38178
  ]);
38177
38179
  return `Successfully created indexes for ${namespace_collection}.`;
@@ -38209,9 +38211,82 @@ function useNotificationRepo() {
38209
38211
  throw new import_node_server_utils111.InternalServerError("Failed to create notifications.");
38210
38212
  }
38211
38213
  }
38214
+ async function getByUserId({
38215
+ userId,
38216
+ appSlug,
38217
+ page = 1,
38218
+ limit = 10,
38219
+ hasRead,
38220
+ siteId,
38221
+ search = ""
38222
+ }) {
38223
+ if (!import_mongodb68.ObjectId.isValid(userId)) {
38224
+ throw new import_node_server_utils111.BadRequestError("Invalid user ID format.");
38225
+ }
38226
+ if (siteId && !import_mongodb68.ObjectId.isValid(siteId)) {
38227
+ throw new import_node_server_utils111.BadRequestError("Invalid site ID format.");
38228
+ }
38229
+ page = page > 0 ? page - 1 : 0;
38230
+ const query2 = {
38231
+ userId: new import_mongodb68.ObjectId(userId),
38232
+ status: { $ne: "deleted" },
38233
+ ...appSlug && { appSlug },
38234
+ ...hasRead !== void 0 && { hasRead },
38235
+ ...siteId && { siteId: new import_mongodb68.ObjectId(siteId) },
38236
+ ...search && {
38237
+ $or: [
38238
+ { title: { $regex: search, $options: "i" } },
38239
+ { body: { $regex: search, $options: "i" } }
38240
+ ]
38241
+ }
38242
+ };
38243
+ try {
38244
+ const [items, totalCount] = await Promise.all([
38245
+ collection().find(query2).sort({ createdAt: -1, _id: -1 }).skip(page * limit).limit(limit).toArray(),
38246
+ collection().countDocuments(query2)
38247
+ ]);
38248
+ return (0, import_node_server_utils111.paginate)(items, page, limit, totalCount);
38249
+ } catch (error) {
38250
+ if (error instanceof import_node_server_utils111.AppError)
38251
+ throw error;
38252
+ import_node_server_utils111.logger.log({ level: "error", message: error.message });
38253
+ throw new import_node_server_utils111.InternalServerError("Failed to retrieve notifications.");
38254
+ }
38255
+ }
38256
+ async function markAsReadById(_id, userId) {
38257
+ if (!import_mongodb68.ObjectId.isValid(_id)) {
38258
+ throw new import_node_server_utils111.BadRequestError("Invalid notification ID format.");
38259
+ }
38260
+ if (!import_mongodb68.ObjectId.isValid(userId)) {
38261
+ throw new import_node_server_utils111.BadRequestError("Invalid user ID format.");
38262
+ }
38263
+ try {
38264
+ const now = /* @__PURE__ */ new Date();
38265
+ const doc = await collection().findOneAndUpdate(
38266
+ {
38267
+ _id: new import_mongodb68.ObjectId(_id),
38268
+ userId: new import_mongodb68.ObjectId(userId),
38269
+ status: { $ne: "deleted" }
38270
+ },
38271
+ { $set: { hasRead: true, readAt: now, updatedAt: now } },
38272
+ { returnDocument: "after" }
38273
+ );
38274
+ if (!doc) {
38275
+ throw new import_node_server_utils111.NotFoundError("Notification not found.");
38276
+ }
38277
+ return doc;
38278
+ } catch (error) {
38279
+ if (error instanceof import_node_server_utils111.AppError)
38280
+ throw error;
38281
+ import_node_server_utils111.logger.log({ level: "error", message: error.message });
38282
+ throw new import_node_server_utils111.InternalServerError("Failed to update notification.");
38283
+ }
38284
+ }
38212
38285
  return {
38213
38286
  createIndexes,
38214
- addMany
38287
+ addMany,
38288
+ getByUserId,
38289
+ markAsReadById
38215
38290
  };
38216
38291
  }
38217
38292
 
@@ -38276,6 +38351,7 @@ var NotificationService = class {
38276
38351
  status: payload.status,
38277
38352
  module: "prelovedMarketplace",
38278
38353
  screen: "/(user)/(marketplace)/prelovedPostInfo",
38354
+ siteId: payload.siteId?.toString(),
38279
38355
  params: {
38280
38356
  id: payload.prelovedId.toString()
38281
38357
  }
@@ -71205,7 +71281,8 @@ function usePostFavoriteService() {
71205
71281
  to: userIds,
71206
71282
  prelovedId: postId,
71207
71283
  subject: "Preloved Marketplace Post",
71208
- status: "Published"
71284
+ status: "Published",
71285
+ siteId
71209
71286
  });
71210
71287
  }
71211
71288
  await session?.commitTransaction();
@@ -75012,6 +75089,91 @@ async function configureVisitorQrReader(client, qrFormat) {
75012
75089
  identifier: { qrcode_identification_enabled: "1" }
75013
75090
  });
75014
75091
  }
75092
+ async function ensureVisitorAccessAuthorization(client, readerId, readerLocation, hidUserId) {
75093
+ const accessRuleId = createStableHidId(`visitor-access-rule:${readerId}`);
75094
+ const existingRuleResponse = await client.loadObjects({
75095
+ object: "access_rules",
75096
+ where: { access_rules: { id: accessRuleId } },
75097
+ limit: 1,
75098
+ offset: 0
75099
+ });
75100
+ if (getHidObjectRows(existingRuleResponse, "access_rules").length) {
75101
+ await client.modifyObjects({
75102
+ object: "access_rules",
75103
+ where: { access_rules: { id: accessRuleId } },
75104
+ values: {
75105
+ name: "iService365 Visitor Access",
75106
+ type: 1,
75107
+ priority: 0
75108
+ }
75109
+ });
75110
+ } else {
75111
+ await client.createObjects({
75112
+ object: "access_rules",
75113
+ values: [{
75114
+ id: accessRuleId,
75115
+ name: "iService365 Visitor Access",
75116
+ type: 1,
75117
+ priority: 0
75118
+ }]
75119
+ });
75120
+ }
75121
+ const portalsResponse = await client.loadObjects({
75122
+ object: "portals",
75123
+ limit: 100,
75124
+ offset: 0
75125
+ });
75126
+ const portals = getHidObjectRows(portalsResponse, "portals").map((portal) => ({
75127
+ id: Number(portal.id),
75128
+ name: String(portal.name || "").trim()
75129
+ })).filter((portal) => Number.isSafeInteger(portal.id) && portal.id > 0);
75130
+ if (!portals.length) {
75131
+ throw new import_node_server_utils266.BadRequestError(
75132
+ "The HID reader has no portal configured for visitor access."
75133
+ );
75134
+ }
75135
+ const normalizedLocation = String(readerLocation || "").trim().toLowerCase();
75136
+ const locationMatches = normalizedLocation ? portals.filter((portal) => {
75137
+ const portalName = portal.name.toLowerCase();
75138
+ return portalName === normalizedLocation || portalName.includes(normalizedLocation) || normalizedLocation.includes(portalName);
75139
+ }) : [];
75140
+ const selectedPortals = locationMatches.length === 1 ? locationMatches : portals.length === 1 ? portals : [];
75141
+ if (!selectedPortals.length) {
75142
+ throw new import_node_server_utils266.BadRequestError(
75143
+ "The HID reader has multiple portals. Match the reader location to one portal before issuing visitor access."
75144
+ );
75145
+ }
75146
+ const portalIds = selectedPortals.map((portal) => portal.id);
75147
+ const userAccessRulesResponse = await client.loadObjects({
75148
+ object: "user_access_rules",
75149
+ where: { user_access_rules: { user_id: hidUserId, access_rule_id: accessRuleId } },
75150
+ limit: 1,
75151
+ offset: 0
75152
+ });
75153
+ if (!getHidObjectRows(userAccessRulesResponse, "user_access_rules").length) {
75154
+ await client.createObjects({
75155
+ object: "user_access_rules",
75156
+ values: [{ user_id: hidUserId, access_rule_id: accessRuleId }]
75157
+ });
75158
+ }
75159
+ const portalAccessRulesResponse = await client.loadObjects({
75160
+ object: "portal_access_rules",
75161
+ where: { portal_access_rules: { access_rule_id: accessRuleId } },
75162
+ limit: 100,
75163
+ offset: 0
75164
+ });
75165
+ const linkedPortalIds = new Set(
75166
+ getHidObjectRows(portalAccessRulesResponse, "portal_access_rules").map((relation) => Number(relation.portal_id)).filter((portalId) => Number.isSafeInteger(portalId) && portalId > 0)
75167
+ );
75168
+ const missingPortalLinks = portalIds.filter((portalId) => !linkedPortalIds.has(portalId)).map((portalId) => ({ portal_id: portalId, access_rule_id: accessRuleId }));
75169
+ if (missingPortalLinks.length) {
75170
+ await client.createObjects({
75171
+ object: "portal_access_rules",
75172
+ values: missingPortalLinks
75173
+ });
75174
+ }
75175
+ return { accessRuleId, portalIds };
75176
+ }
75015
75177
  function getRelayAuth() {
75016
75178
  const username = process.env.HID_AMICO_RELAY_USERNAME;
75017
75179
  const password = process.env.HID_AMICO_RELAY_PASSWORD;
@@ -75635,6 +75797,12 @@ function useHidAmicoService() {
75635
75797
  values: [{ id: hidUserId, ...user }]
75636
75798
  });
75637
75799
  }
75800
+ const authorization = await ensureVisitorAccessAuthorization(
75801
+ client,
75802
+ readerId,
75803
+ reader.location,
75804
+ hidUserId
75805
+ );
75638
75806
  for (const object of ["qrcodes", "cards"]) {
75639
75807
  const existingCredentialResponse = await client.loadObjects({
75640
75808
  object,
@@ -75684,6 +75852,8 @@ function useHidAmicoService() {
75684
75852
  qrFormat: value.qrFormat,
75685
75853
  credentialObject: credential.object,
75686
75854
  credentialId: credential.credentialId,
75855
+ accessRuleId: authorization.accessRuleId,
75856
+ portalIds: authorization.portalIds,
75687
75857
  issuedAt: issuedAt.toISOString(),
75688
75858
  expiresAt: expiresAt.toISOString()
75689
75859
  }
@@ -75707,6 +75877,8 @@ function useHidAmicoService() {
75707
75877
  visitor: value.visitorId,
75708
75878
  hidUserId,
75709
75879
  credentialObject: credential.object,
75880
+ accessRuleId: authorization.accessRuleId,
75881
+ portalIds: authorization.portalIds,
75710
75882
  issuedAt: issuedAt.toISOString(),
75711
75883
  expiresAt: expiresAt.toISOString()
75712
75884
  }
@@ -75898,6 +76070,12 @@ function useHidAmicoService() {
75898
76070
  values: [{ id: hidUserId, ...user }]
75899
76071
  });
75900
76072
  }
76073
+ const authorization = await ensureVisitorAccessAuthorization(
76074
+ client,
76075
+ readerId,
76076
+ reader.location,
76077
+ hidUserId
76078
+ );
75901
76079
  const result = await client.setUserImage(hidUserId, image, timestamp, match);
75902
76080
  const existingIdentity = await repo.findExistingIdentity({ reader: readerId, hidUserId });
75903
76081
  const existingMetadata = existingIdentity && isUnknownRecord(existingIdentity.metadata) ? existingIdentity.metadata : {};
@@ -75913,6 +76091,8 @@ function useHidAmicoService() {
75913
76091
  temporary: true,
75914
76092
  facialEnrolled: true,
75915
76093
  facialEnrolledAt: issuedAt.toISOString(),
76094
+ accessRuleId: authorization.accessRuleId,
76095
+ portalIds: authorization.portalIds,
75916
76096
  expiresAt: expiresAt.toISOString()
75917
76097
  }
75918
76098
  };
@@ -75934,6 +76114,8 @@ function useHidAmicoService() {
75934
76114
  visitor: visitorId,
75935
76115
  hidUserId,
75936
76116
  imageBytes: image.length,
76117
+ accessRuleId: authorization.accessRuleId,
76118
+ portalIds: authorization.portalIds,
75937
76119
  issuedAt: issuedAt.toISOString(),
75938
76120
  expiresAt: expiresAt.toISOString(),
75939
76121
  result: summarizeUserImageResult(result)
@@ -76858,15 +77040,11 @@ function useHidAmicoController() {
76858
77040
  // src/controllers/notification.controller.ts
76859
77041
  var import_node_server_utils268 = require("@7365admin1/node-server-utils");
76860
77042
  function useNotificationController() {
76861
- const { addMany: _addMany } = useNotificationRepo();
76862
- function currentUserId(req) {
76863
- const user = req.user;
76864
- const id = user?.user ?? user?._id;
76865
- if (!id) {
76866
- throw new import_node_server_utils268.BadRequestError("Unable to resolve current user.");
76867
- }
76868
- return String(id);
76869
- }
77043
+ const {
77044
+ addMany: _addMany,
77045
+ getByUserId: _getByUserId,
77046
+ markAsReadById: _markAsReadById
77047
+ } = useNotificationRepo();
76870
77048
  async function add(req, res, next) {
76871
77049
  const { error, value } = schemaCreateNotification.validate(req.body);
76872
77050
  if (error) {
@@ -76891,8 +77069,53 @@ function useNotificationController() {
76891
77069
  return;
76892
77070
  }
76893
77071
  }
77072
+ async function getAll(req, res, next) {
77073
+ const { error, value } = schemaListNotification.validate(req.query);
77074
+ if (error) {
77075
+ next(new import_node_server_utils268.BadRequestError(error.message));
77076
+ return;
77077
+ }
77078
+ try {
77079
+ const data = await _getByUserId({
77080
+ userId: value.user,
77081
+ appSlug: value.appSlug || void 0,
77082
+ page: value.page,
77083
+ limit: value.limit,
77084
+ hasRead: value.hasRead === "" ? void 0 : value.hasRead,
77085
+ siteId: value.siteId || void 0,
77086
+ search: value.search
77087
+ });
77088
+ res.status(200).json({ data });
77089
+ return;
77090
+ } catch (error2) {
77091
+ import_node_server_utils268.logger.log({ level: "error", message: error2.message });
77092
+ next(error2);
77093
+ return;
77094
+ }
77095
+ }
77096
+ async function markAsRead(req, res, next) {
77097
+ const { error, value } = schemaUpdateNotification.validate({
77098
+ _id: req.params.id,
77099
+ user: req.params.user
77100
+ });
77101
+ if (error) {
77102
+ next(new import_node_server_utils268.BadRequestError(error.message));
77103
+ return;
77104
+ }
77105
+ try {
77106
+ const data = await _markAsReadById(value._id, value.user);
77107
+ res.status(200).json({ message: "success", data });
77108
+ return;
77109
+ } catch (error2) {
77110
+ import_node_server_utils268.logger.log({ level: "error", message: error2.message });
77111
+ next(error2);
77112
+ return;
77113
+ }
77114
+ }
76894
77115
  return {
76895
- add
77116
+ add,
77117
+ getAll,
77118
+ markAsRead
76896
77119
  };
76897
77120
  }
76898
77121
  // Annotate the CommonJS export names for ESM import in node: