@7365admin1/core 2.8.0 → 2.9.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 +38 -7
- package/dist/index.js +191 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -549,6 +549,7 @@ type TAddress = {
|
|
|
549
549
|
postalCode: string;
|
|
550
550
|
taxId: string;
|
|
551
551
|
};
|
|
552
|
+
declare function MAddress(value: any): TAddress;
|
|
552
553
|
|
|
553
554
|
declare function useSubscriptionService(): {
|
|
554
555
|
createOrgSubscription: (value: {
|
|
@@ -4261,6 +4262,13 @@ type TIncidentTypeAndTime = {
|
|
|
4261
4262
|
typeOfIncident: string;
|
|
4262
4263
|
dateOfIncident?: string | Date;
|
|
4263
4264
|
};
|
|
4265
|
+
type TAuthoritiesCalled = {
|
|
4266
|
+
type: string;
|
|
4267
|
+
vehicleNumber: string;
|
|
4268
|
+
personInCharge: string;
|
|
4269
|
+
caseReportReference: string;
|
|
4270
|
+
description: string;
|
|
4271
|
+
};
|
|
4264
4272
|
type TSubmissionForm = {
|
|
4265
4273
|
dateOfReport: string | Date;
|
|
4266
4274
|
time?: string;
|
|
@@ -4291,17 +4299,31 @@ type TIncidentInformation = {
|
|
|
4291
4299
|
recipientOfComplaint?: TRecipientOfComplaint;
|
|
4292
4300
|
complaintReceivedTo: TComplaintReceivedTo;
|
|
4293
4301
|
};
|
|
4302
|
+
type TAffectedInjured = {
|
|
4303
|
+
name: string;
|
|
4304
|
+
contact?: string;
|
|
4305
|
+
nric?: string;
|
|
4306
|
+
};
|
|
4307
|
+
type TanyoneDamageToProperty = {
|
|
4308
|
+
description: string;
|
|
4309
|
+
block: number;
|
|
4310
|
+
level: string;
|
|
4311
|
+
unit: string;
|
|
4312
|
+
blkLevelUnit: string;
|
|
4313
|
+
name: string;
|
|
4314
|
+
contact: string;
|
|
4315
|
+
};
|
|
4294
4316
|
type TAffectedEntities = {
|
|
4295
4317
|
anyUnitAffectedValue: "yes" | "no";
|
|
4296
4318
|
affectedUnit?: Record<string, any> | ObjectId;
|
|
4297
4319
|
anyoneAffectedValue: "yes" | "no";
|
|
4298
|
-
affectedInjured:
|
|
4320
|
+
affectedInjured: TAffectedInjured[];
|
|
4299
4321
|
anyPropertyAffectedValue: "yes" | "no";
|
|
4300
|
-
anyoneDamageToProperty:
|
|
4322
|
+
anyoneDamageToProperty: TanyoneDamageToProperty[];
|
|
4301
4323
|
};
|
|
4302
4324
|
type TAuthorities = {
|
|
4303
4325
|
authoritiesValue: "yes" | "no";
|
|
4304
|
-
authoritiesCalled:
|
|
4326
|
+
authoritiesCalled: TAuthoritiesCalled[];
|
|
4305
4327
|
incidentThereAfter?: string;
|
|
4306
4328
|
managementNotified?: TActionStatus;
|
|
4307
4329
|
incidentResolved?: string;
|
|
@@ -4331,7 +4353,7 @@ type TIncidentReport = {
|
|
|
4331
4353
|
photos?: string[];
|
|
4332
4354
|
approvedBy?: ObjectId | null;
|
|
4333
4355
|
approvedByName?: string;
|
|
4334
|
-
|
|
4356
|
+
remarks?: string | null;
|
|
4335
4357
|
status: "pending" | "approved" | "rejected";
|
|
4336
4358
|
createdAt?: string | Date;
|
|
4337
4359
|
updatedAt?: string | Date;
|
|
@@ -4352,7 +4374,7 @@ declare function MIncidentReport(value: TIncidentReport): {
|
|
|
4352
4374
|
photos: string[];
|
|
4353
4375
|
approvedBy: ObjectId | null;
|
|
4354
4376
|
approvedByName: string;
|
|
4355
|
-
|
|
4377
|
+
remarks: string | null;
|
|
4356
4378
|
status: "pending" | "approved" | "rejected";
|
|
4357
4379
|
createdAt: string | Date;
|
|
4358
4380
|
updatedAt: string | Date | undefined;
|
|
@@ -4360,9 +4382,10 @@ declare function MIncidentReport(value: TIncidentReport): {
|
|
|
4360
4382
|
};
|
|
4361
4383
|
|
|
4362
4384
|
declare function useIncidentReportService(): {
|
|
4363
|
-
add: (value: TIncidentReport) => Promise<
|
|
4385
|
+
add: (value: TIncidentReport) => Promise<ObjectId>;
|
|
4364
4386
|
updateIncidentReportById: (id: string | ObjectId, value: Partial<TIncidentReport>) => Promise<string>;
|
|
4365
4387
|
createIncidentSummary: (value: Partial<TIncidentReport>) => Promise<string>;
|
|
4388
|
+
reviewIncidentReport: (id: string | ObjectId, value: Partial<TIncidentReport>) => Promise<string>;
|
|
4366
4389
|
};
|
|
4367
4390
|
|
|
4368
4391
|
declare function useIncidentReportController(): {
|
|
@@ -4372,6 +4395,7 @@ declare function useIncidentReportController(): {
|
|
|
4372
4395
|
updateIncidentReportById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4373
4396
|
deleteIncidentReportById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4374
4397
|
createIncidentSummary: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4398
|
+
reviewIncidentReport: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4375
4399
|
};
|
|
4376
4400
|
|
|
4377
4401
|
declare function useIncidentReportRepo(): {
|
|
@@ -4394,6 +4418,7 @@ declare function useIncidentReportRepo(): {
|
|
|
4394
4418
|
deleteIncidentReportById: (_id: string | ObjectId) => Promise<number>;
|
|
4395
4419
|
createIndexes: () => Promise<void>;
|
|
4396
4420
|
createTextIndex: () => Promise<void>;
|
|
4421
|
+
reviewIncidentReport: (_id: ObjectId | string, value: Partial<TIncidentReport>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
4397
4422
|
};
|
|
4398
4423
|
|
|
4399
4424
|
type TNfcPatrolSettings = {
|
|
@@ -4716,4 +4741,10 @@ declare function useNfcPatrolLogController(): {
|
|
|
4716
4741
|
getAllBySite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4717
4742
|
};
|
|
4718
4743
|
|
|
4719
|
-
|
|
4744
|
+
declare function useAddressRepo(): {
|
|
4745
|
+
createIndex: () => Promise<void>;
|
|
4746
|
+
add: (value: TAddress, session?: ClientSession) => Promise<ObjectId>;
|
|
4747
|
+
getByUserId: (user: string | ObjectId) => Promise<TAddress | null>;
|
|
4748
|
+
};
|
|
4749
|
+
|
|
4750
|
+
export { AccessTypeProps, AssignCardConfig, BulkCardUpdate, Camera, DEVICE_STATUS, EAccessCardTypes, EAccessCardUserTypes, IAccessCard, IAccessCardTransaction, MAccessCard, MAccessCardTransaction, MAddress, MAttendance, MAttendanceSettings, MBillingConfiguration, MBillingItem, MBuilding, MBuildingUnit, MBulletinBoard, MBulletinVideo, MChat, MCustomer, MCustomerSite, MDocumentManagement, MEntryPassSettings, MEventManagement, MFeedback, MFile, MGuestManagement, MIncidentReport, MMember, MNfcPatrolLog, MNfcPatrolRoute, MNfcPatrolSettings, MNfcPatrolSettingsUpdate, MNfcPatrolTag, MOccurrenceBook, MOccurrenceEntry, MOccurrenceSubject, MOnlineForm, MOrg, MPatrolLog, MPatrolQuestion, MPatrolRoute, MPerson, MPromoCode, MRobot, MRole, MServiceProvider, MServiceProviderBilling, MSession, MSite, MSiteCamera, MSiteFacility, MSiteFacilityBooking, MStatementOfAccount, MSubscription, MUnitBilling, MUser, MVehicle, MVehicleTransaction, MVerification, MVisitorTransaction, MWorkOrder, PERSON_TYPES, PersonType, QrTagProps, SiteType, TActionStatus, TAddress, TAffectedEntities, TAffectedInjured, TAttendance, TAttendanceCheckIn, TAttendanceCheckOut, TAttendanceCheckTime, TAttendanceLocation, TAttendanceSettings, TAttendanceSettingsGetBySite, TAuthorities, TAuthoritiesCalled, TBilling, TBillingConfiguration, TBillingItem, TBuilding, TBuildingUnit, TBulletinBoard, TBulletinVideo, TCamera, TChat, TCheckPoint$1 as TCheckPoint, TComplaintInfo, TComplaintReceivedTo, TCounter, TCustomer, TCustomerSite, TDayNumber, TDefaultAccessCard, TDocs, TDocumentManagement, TEntryPassSettings, TEventManagement, TFeedback, TFeedbackMetadata, TFeedbackUpdate, TFeedbackUpdateCategory, TFeedbackUpdateServiceProvider, TFeedbackUpdateStatus, TFeedbackUpdateToCompleted, TFile, TGetAttendancesByUserQuery, TGetAttendancesQuery, TGuestManagement, TIncidentInformation, TIncidentReport, TIncidentTypeAndTime, TInvoice, TMember, TMemberUpdateStatus, TMiniRole, TNfcPatrolLog, TNfcPatrolRoute, TNfcPatrolRouteEdit, TNfcPatrolSettings, TNfcPatrolSettingsGetBySite, TNfcPatrolSettingsUpdate, TNfcPatrolTag, TNfcPatrolTagConfigureReset, TNfcPatrolTagEdit, TNfcPatrolTagUpdateData, TOccurrenceBook, TOccurrenceEntry, TOccurrenceSubject, TOnlineForm, TOrg, TPatrolLog, TPatrolQuestion, TPatrolRoute, TPerson, TPlaceOfIncident, TPlates, TPrice, TPriceType, TPromoCode, TPromoTier, TRecipientOfComplaint, TRobot, TRobotMetadata, TRole, TRoute, TSOABillingItem, TSOAStatus, TServiceProvider, TServiceProviderBilling, TSession, TSessionCreate, TSite, TSiteCamera, TSiteFacility, TSiteFacilityBooking, TSiteInfo, TSiteMetadata, TSiteUpdateBlock, TStatementOfAccount, TSubmissionForm, TSubscription, TUnitBilling, TUnits, TUpdateName, TUser, TUserCreate, TVehicle, TVehicleTransaction, TVehicleUpdate, TVerification, TVerificationMetadata, TVisitorTransaction, TWorkOrder, TWorkOrderMetadata, TWorkOrderUpdate, TWorkOrderUpdateStatus, TWorkOrderUpdateToCompleted, TanyoneDamageToProperty, UseAccessManagementRepo, allowedCategories, allowedFieldsSite, allowedNatures, allowedTypes, attendanceSchema, attendanceSettingsSchema, chatSchema, customerSchema, feedbackSchema, logCamera, nfcPatrolSettingsSchema, nfcPatrolSettingsSchemaUpdate, orgSchema, promoCodeSchema, robotSchema, schema, schemaBilling, schemaBillingConfiguration, schemaBillingItem, schemaBuilding, schemaBuildingUnit, schemaBuildingUpdateOptions, schemaBulletinBoard, schemaBulletinVideo, schemaCustomerSite, schemaDocumentManagement, schemaEntryPassSettings, schemaEventManagement, schemaGuestManagement, schemaIncidentReport, schemaNfcPatrolLog, schemaNfcPatrolRoute, schemaNfcPatrolTag, schemaNfcPatrolTagUpdateData, schemaOccurrenceBook, schemaOccurrenceEntry, schemaOccurrenceSubject, schemaOnlineForm, schemaPatrolLog, schemaPatrolQuestion, schemaPatrolRoute, schemaPerson, schemaPlate, schemaServiceProvider, schemaServiceProviderBilling, schemaSiteCamera, schemaSiteFacility, schemaSiteFacilityBooking, schemaStatementOfAccount, schemaUnitBilling, schemaUpdateBulletinBoard, schemaUpdateBulletinVideo, schemaUpdateDocumentManagement, schemaUpdateEntryPassSettings, schemaUpdateEventManagement, schemaUpdateGuestManagement, schemaUpdateIncidentReport, schemaUpdateOccurrenceBook, schemaUpdateOccurrenceEntry, schemaUpdateOccurrenceSubject, schemaUpdateOnlineForm, schemaUpdateOptions, schemaUpdatePatrolLog, schemaUpdatePatrolQuestion, schemaUpdatePatrolRoute, schemaUpdatePerson, schemaUpdateServiceProviderBilling, schemaUpdateSiteBillingConfiguration, schemaUpdateSiteBillingItem, schemaUpdateSiteCamera, schemaUpdateSiteFacility, schemaUpdateSiteUnitBilling, schemaUpdateStatementOfAccount, schemaUpdateVisTrans, schemaVehicleTransaction, schemaVisitorTransaction, schemeCamera, schemeLogCamera, siteSchema, tokenSchema, useAccessManagementController, useAddressRepo, useAttendanceController, useAttendanceRepository, useAttendanceSettingsController, useAttendanceSettingsRepository, useAttendanceSettingsService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useBulletinBoardController, useBulletinBoardRepo, useBulletinBoardService, useBulletinVideoController, useBulletinVideoRepo, useBulletinVideoService, useChatController, 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, useGuestManagementController, useGuestManagementRepo, useGuestManagementService, useIncidentReportController, useIncidentReportRepo, useIncidentReportService, useInvoiceController, useInvoiceModel, useInvoiceRepo, useMemberController, useMemberRepo, useNfcPatrolLogController, useNfcPatrolLogRepo, useNfcPatrolLogService, useNfcPatrolRouteController, useNfcPatrolRouteRepo, useNfcPatrolRouteService, useNfcPatrolSettingsController, useNfcPatrolSettingsRepository, useNfcPatrolSettingsService, useNfcPatrolTagController, useNfcPatrolTagRepo, useNfcPatrolTagService, useOccurrenceBookController, useOccurrenceBookRepo, useOccurrenceBookService, useOccurrenceEntryController, useOccurrenceEntryRepo, useOccurrenceEntryService, useOccurrenceSubjectController, useOccurrenceSubjectRepo, useOccurrenceSubjectService, useOnlineFormController, useOnlineFormRepo, useOrgController, useOrgRepo, usePatrolLogController, usePatrolLogRepo, usePatrolQuestionController, usePatrolQuestionRepo, usePatrolRouteController, usePatrolRouteRepo, usePersonController, usePersonRepo, usePriceController, usePriceModel, usePriceRepo, usePromoCodeController, usePromoCodeRepo, useRobotController, useRobotRepo, useRobotService, useRoleController, useRoleRepo, 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, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useUserController, useUserRepo, useUserService, useVehicleController, useVehicleRepo, useVehicleService, useVerificationController, useVerificationRepo, useVerificationService, useVisitorTransactionController, useVisitorTransactionRepo, useVisitorTransactionService, useWorkOrderController, useWorkOrderRepo, useWorkOrderService, userSchema, vehicleSchema, workOrderSchema };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
EAccessCardUserTypes: () => EAccessCardUserTypes,
|
|
37
37
|
MAccessCard: () => MAccessCard,
|
|
38
38
|
MAccessCardTransaction: () => MAccessCardTransaction,
|
|
39
|
+
MAddress: () => MAddress,
|
|
39
40
|
MAttendance: () => MAttendance,
|
|
40
41
|
MAttendanceSettings: () => MAttendanceSettings,
|
|
41
42
|
MBillingConfiguration: () => MBillingConfiguration,
|
|
@@ -170,6 +171,7 @@ __export(src_exports, {
|
|
|
170
171
|
siteSchema: () => siteSchema,
|
|
171
172
|
tokenSchema: () => tokenSchema,
|
|
172
173
|
useAccessManagementController: () => useAccessManagementController,
|
|
174
|
+
useAddressRepo: () => useAddressRepo,
|
|
173
175
|
useAttendanceController: () => useAttendanceController,
|
|
174
176
|
useAttendanceRepository: () => useAttendanceRepository,
|
|
175
177
|
useAttendanceSettingsController: () => useAttendanceSettingsController,
|
|
@@ -2084,6 +2086,14 @@ function useOccurrenceEntryRepo() {
|
|
|
2084
2086
|
throw new Error("Invalid signature ID.");
|
|
2085
2087
|
}
|
|
2086
2088
|
}
|
|
2089
|
+
if (value.incidentReportId && typeof value.incidentReportId === "string") {
|
|
2090
|
+
try {
|
|
2091
|
+
value.incidentReportId = new import_mongodb7.ObjectId(value.incidentReportId);
|
|
2092
|
+
} catch {
|
|
2093
|
+
throw new Error("Invalid incident report ID.");
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
console.log("Updating occurrence entry:", _id, value);
|
|
2087
2097
|
try {
|
|
2088
2098
|
const res = await collection.updateOne(
|
|
2089
2099
|
{ _id },
|
|
@@ -12998,8 +13008,8 @@ var schemaBuildingUnit = import_joi38.default.object({
|
|
|
12998
13008
|
buildingUnitFiles: import_joi38.default.array().items(import_joi38.default.string()).optional().allow("", null),
|
|
12999
13009
|
companyName: import_joi38.default.string().optional().allow("", null),
|
|
13000
13010
|
companyRegistrationNumber: import_joi38.default.string().optional().allow("", null),
|
|
13001
|
-
leaseStart: import_joi38.default.date().
|
|
13002
|
-
leaseEnd: import_joi38.default.date().
|
|
13011
|
+
leaseStart: import_joi38.default.date().optional(),
|
|
13012
|
+
leaseEnd: import_joi38.default.date().optional(),
|
|
13003
13013
|
owner: import_joi38.default.string().hex().optional().allow("", null),
|
|
13004
13014
|
ownerName: import_joi38.default.string().optional().allow("", null),
|
|
13005
13015
|
billing: import_joi38.default.array().items(schemaBilling).optional().allow("", null)
|
|
@@ -14341,8 +14351,8 @@ function useBuildingUnitController() {
|
|
|
14341
14351
|
buildingUnitFiles: import_joi40.default.array().items(import_joi40.default.string()).optional(),
|
|
14342
14352
|
companyName: import_joi40.default.string().optional().allow("", null),
|
|
14343
14353
|
companyRegistrationNumber: import_joi40.default.string().optional().allow("", null),
|
|
14344
|
-
leaseStart: import_joi40.default.date().
|
|
14345
|
-
leaseEnd: import_joi40.default.date().
|
|
14354
|
+
leaseStart: import_joi40.default.date().optional(),
|
|
14355
|
+
leaseEnd: import_joi40.default.date().optional()
|
|
14346
14356
|
}),
|
|
14347
14357
|
qty: import_joi40.default.number().integer().min(1).max(20).optional().default(1)
|
|
14348
14358
|
});
|
|
@@ -17523,7 +17533,11 @@ function useAttendanceSettingsRepository() {
|
|
|
17523
17533
|
isLocationEnabled: 1,
|
|
17524
17534
|
location: 1,
|
|
17525
17535
|
isGeofencingEnabled: 1,
|
|
17526
|
-
mile: 1
|
|
17536
|
+
mile: 1,
|
|
17537
|
+
postalCode: 1,
|
|
17538
|
+
country: 1,
|
|
17539
|
+
city: 1,
|
|
17540
|
+
address: 1
|
|
17527
17541
|
}
|
|
17528
17542
|
}
|
|
17529
17543
|
]).toArray();
|
|
@@ -29701,6 +29715,7 @@ function useStatementOfAccountService() {
|
|
|
29701
29715
|
try {
|
|
29702
29716
|
const browser = await (0, import_puppeteer.launch)({
|
|
29703
29717
|
headless: true,
|
|
29718
|
+
executablePath: process.env.CHROME_BINARY,
|
|
29704
29719
|
args: [`--no-sandbox`, `--disable-gpu`, `--disable-dev-shm-usage`]
|
|
29705
29720
|
});
|
|
29706
29721
|
const page = await browser.newPage();
|
|
@@ -31325,6 +31340,27 @@ var actionStatusSchema = import_joi99.default.object({
|
|
|
31325
31340
|
status: import_joi99.default.string().optional(),
|
|
31326
31341
|
time: import_joi99.default.string().optional()
|
|
31327
31342
|
});
|
|
31343
|
+
var affectedInjuredStatusSchema = import_joi99.default.object({
|
|
31344
|
+
name: import_joi99.default.string().required(),
|
|
31345
|
+
contact: import_joi99.default.string().optional().allow(null, ""),
|
|
31346
|
+
nric: import_joi99.default.string().optional().allow(null, "")
|
|
31347
|
+
});
|
|
31348
|
+
var anyoneDamageToPropertyStatusSchema = import_joi99.default.object({
|
|
31349
|
+
description: import_joi99.default.string().optional().allow(null, ""),
|
|
31350
|
+
block: import_joi99.default.number().optional().allow(null, ""),
|
|
31351
|
+
level: import_joi99.default.string().optional().allow(null, ""),
|
|
31352
|
+
unit: import_joi99.default.string().optional().allow(null, ""),
|
|
31353
|
+
blkLevelUnit: import_joi99.default.string().optional().allow(null, ""),
|
|
31354
|
+
name: import_joi99.default.string().optional().allow(null, ""),
|
|
31355
|
+
contact: import_joi99.default.string().optional().allow(null, "")
|
|
31356
|
+
});
|
|
31357
|
+
var authoritiesCalledStatusSchema = import_joi99.default.object({
|
|
31358
|
+
type: import_joi99.default.string().optional().allow(null, ""),
|
|
31359
|
+
vehicleNumber: import_joi99.default.string().optional().allow(null, ""),
|
|
31360
|
+
personInCharge: import_joi99.default.string().optional().allow(null, ""),
|
|
31361
|
+
caseReportReference: import_joi99.default.string().optional().allow(null, ""),
|
|
31362
|
+
description: import_joi99.default.string().optional().allow(null, "")
|
|
31363
|
+
});
|
|
31328
31364
|
var schemaIncidentReport = import_joi99.default.object({
|
|
31329
31365
|
reportId: import_joi99.default.string().required(),
|
|
31330
31366
|
incidentInformation: import_joi99.default.object({
|
|
@@ -31337,7 +31373,7 @@ var schemaIncidentReport = import_joi99.default.object({
|
|
|
31337
31373
|
placeOfIncident: import_joi99.default.object({
|
|
31338
31374
|
block: import_joi99.default.number().optional().allow(null, ""),
|
|
31339
31375
|
level: import_joi99.default.string().optional().allow(null, ""),
|
|
31340
|
-
unit: import_joi99.default.string().
|
|
31376
|
+
unit: import_joi99.default.string().optional().allow(null, ""),
|
|
31341
31377
|
other: import_joi99.default.string().allow(null, "").optional().allow(null, ""),
|
|
31342
31378
|
isOther: import_joi99.default.boolean().required(),
|
|
31343
31379
|
incidentLocation: import_joi99.default.string().optional().allow(null, "")
|
|
@@ -31374,13 +31410,13 @@ var schemaIncidentReport = import_joi99.default.object({
|
|
|
31374
31410
|
anyUnitAffectedValue: import_joi99.default.string().valid("yes", "no").required(),
|
|
31375
31411
|
affectedUnit: import_joi99.default.any().optional(),
|
|
31376
31412
|
anyoneAffectedValue: import_joi99.default.string().valid("yes", "no").required(),
|
|
31377
|
-
affectedInjured: import_joi99.default.array().items(
|
|
31413
|
+
affectedInjured: import_joi99.default.array().items(affectedInjuredStatusSchema).optional().allow(null, ""),
|
|
31378
31414
|
anyPropertyAffectedValue: import_joi99.default.string().valid("yes", "no").required(),
|
|
31379
|
-
anyoneDamageToProperty: import_joi99.default.array().items(
|
|
31380
|
-
}).
|
|
31415
|
+
anyoneDamageToProperty: import_joi99.default.array().items(anyoneDamageToPropertyStatusSchema).optional()
|
|
31416
|
+
}).optional().allow(null, ""),
|
|
31381
31417
|
authorities: import_joi99.default.object({
|
|
31382
31418
|
authoritiesValue: import_joi99.default.string().valid("yes", "no").required(),
|
|
31383
|
-
authoritiesCalled: import_joi99.default.array().items(
|
|
31419
|
+
authoritiesCalled: import_joi99.default.array().items(authoritiesCalledStatusSchema).optional().allow(null, ""),
|
|
31384
31420
|
incidentThereAfter: import_joi99.default.string().optional().allow("", null),
|
|
31385
31421
|
managementNotified: actionStatusSchema.optional(),
|
|
31386
31422
|
incidentResolved: import_joi99.default.string().optional().allow("", null),
|
|
@@ -31404,7 +31440,7 @@ var schemaIncidentReport = import_joi99.default.object({
|
|
|
31404
31440
|
photos: import_joi99.default.array().items(import_joi99.default.string()).optional(),
|
|
31405
31441
|
approvedBy: import_joi99.default.string().hex().allow(null, "").optional(),
|
|
31406
31442
|
approvedByName: import_joi99.default.string().optional().allow("", null),
|
|
31407
|
-
|
|
31443
|
+
remarks: import_joi99.default.string().optional().allow("", null),
|
|
31408
31444
|
status: import_joi99.default.string().valid("pending", "approved", "rejected").default("pending")
|
|
31409
31445
|
});
|
|
31410
31446
|
var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
@@ -31419,7 +31455,7 @@ var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
|
31419
31455
|
placeOfIncident: import_joi99.default.object({
|
|
31420
31456
|
block: import_joi99.default.number().optional().allow(null, ""),
|
|
31421
31457
|
level: import_joi99.default.string().optional().allow(null, ""),
|
|
31422
|
-
unit: import_joi99.default.string().
|
|
31458
|
+
unit: import_joi99.default.string().optional().allow(null, ""),
|
|
31423
31459
|
other: import_joi99.default.string().allow(null, "").optional().allow(null, ""),
|
|
31424
31460
|
isOther: import_joi99.default.boolean().allow(null, ""),
|
|
31425
31461
|
incidentLocation: import_joi99.default.string().optional().allow(null, "")
|
|
@@ -31456,13 +31492,13 @@ var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
|
31456
31492
|
anyUnitAffectedValue: import_joi99.default.string().valid("yes", "no").allow(null, ""),
|
|
31457
31493
|
affectedUnit: import_joi99.default.any().optional(),
|
|
31458
31494
|
anyoneAffectedValue: import_joi99.default.string().valid("yes", "no").allow(null, ""),
|
|
31459
|
-
affectedInjured: import_joi99.default.array().items(
|
|
31495
|
+
affectedInjured: import_joi99.default.array().items(affectedInjuredStatusSchema).optional().allow(null, ""),
|
|
31460
31496
|
anyPropertyAffectedValue: import_joi99.default.string().valid("yes", "no").allow(null, ""),
|
|
31461
|
-
anyoneDamageToProperty: import_joi99.default.array().items(
|
|
31462
|
-
}).allow(null, ""),
|
|
31497
|
+
anyoneDamageToProperty: import_joi99.default.array().items(anyoneDamageToPropertyStatusSchema).optional().allow(null, "")
|
|
31498
|
+
}).optional().allow(null, ""),
|
|
31463
31499
|
authorities: import_joi99.default.object({
|
|
31464
31500
|
authoritiesValue: import_joi99.default.string().valid("yes", "no").allow(null, ""),
|
|
31465
|
-
authoritiesCalled: import_joi99.default.array().items(
|
|
31501
|
+
authoritiesCalled: import_joi99.default.array().items(authoritiesCalledStatusSchema).optional().allow(null, ""),
|
|
31466
31502
|
incidentThereAfter: import_joi99.default.string().optional().allow("", null),
|
|
31467
31503
|
managementNotified: actionStatusSchema.optional(),
|
|
31468
31504
|
incidentResolved: import_joi99.default.string().optional().allow("", null),
|
|
@@ -31486,7 +31522,7 @@ var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
|
31486
31522
|
photos: import_joi99.default.array().items(import_joi99.default.string()).optional(),
|
|
31487
31523
|
approvedBy: import_joi99.default.string().hex().allow(null, "").optional(),
|
|
31488
31524
|
approvedByName: import_joi99.default.string().optional().allow("", null),
|
|
31489
|
-
|
|
31525
|
+
remarks: import_joi99.default.string().optional().allow("", null),
|
|
31490
31526
|
status: import_joi99.default.string().valid("pending", "approved", "rejected").default("pending")
|
|
31491
31527
|
});
|
|
31492
31528
|
function MIncidentReport(value) {
|
|
@@ -31528,14 +31564,6 @@ function MIncidentReport(value) {
|
|
|
31528
31564
|
throw new Error("Invalid siteInfo.site ID.");
|
|
31529
31565
|
}
|
|
31530
31566
|
}
|
|
31531
|
-
const place = incidentInformation?.placeOfIncident;
|
|
31532
|
-
if (place?.unit && typeof place.unit === "string") {
|
|
31533
|
-
try {
|
|
31534
|
-
place.unit = new import_mongodb96.ObjectId(place.unit);
|
|
31535
|
-
} catch {
|
|
31536
|
-
throw new Error("Invalid unit ID.");
|
|
31537
|
-
}
|
|
31538
|
-
}
|
|
31539
31567
|
if (incidentInformation?.incidentTypeAndTime?.dateOfIncident && typeof incidentInformation.incidentTypeAndTime.dateOfIncident !== "string") {
|
|
31540
31568
|
incidentInformation.incidentTypeAndTime.dateOfIncident = incidentInformation.incidentTypeAndTime.dateOfIncident.toISOString();
|
|
31541
31569
|
}
|
|
@@ -31557,7 +31585,7 @@ function MIncidentReport(value) {
|
|
|
31557
31585
|
photos: value.photos ?? [],
|
|
31558
31586
|
approvedBy: value.approvedBy ?? null,
|
|
31559
31587
|
approvedByName: value.approvedByName ?? "",
|
|
31560
|
-
|
|
31588
|
+
remarks: value.remarks ?? null,
|
|
31561
31589
|
status: value.status ?? "pending",
|
|
31562
31590
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
31563
31591
|
updatedAt: value.updatedAt,
|
|
@@ -31756,6 +31784,37 @@ function useIncidentReportRepo() {
|
|
|
31756
31784
|
} catch (error) {
|
|
31757
31785
|
throw new import_node_server_utils173.BadRequestError("Invalid ID format.");
|
|
31758
31786
|
}
|
|
31787
|
+
if (value.organization && typeof value.organization === "string") {
|
|
31788
|
+
try {
|
|
31789
|
+
value.organization = new import_mongodb97.ObjectId(value.organization);
|
|
31790
|
+
} catch {
|
|
31791
|
+
throw new Error("Invalid organization ID.");
|
|
31792
|
+
}
|
|
31793
|
+
}
|
|
31794
|
+
if (value.site && typeof value.site === "string") {
|
|
31795
|
+
try {
|
|
31796
|
+
value.site = new import_mongodb97.ObjectId(value.site);
|
|
31797
|
+
} catch {
|
|
31798
|
+
throw new Error("Invalid site ID.");
|
|
31799
|
+
}
|
|
31800
|
+
}
|
|
31801
|
+
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
31802
|
+
try {
|
|
31803
|
+
value.approvedBy = new import_mongodb97.ObjectId(value.approvedBy);
|
|
31804
|
+
} catch {
|
|
31805
|
+
throw new Error("Invalid approvedBy ID.");
|
|
31806
|
+
}
|
|
31807
|
+
}
|
|
31808
|
+
const { incidentInformation } = value;
|
|
31809
|
+
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
31810
|
+
try {
|
|
31811
|
+
incidentInformation.siteInfo.site = new import_mongodb97.ObjectId(
|
|
31812
|
+
incidentInformation.siteInfo.site
|
|
31813
|
+
);
|
|
31814
|
+
} catch {
|
|
31815
|
+
throw new Error("Invalid siteInfo.site ID.");
|
|
31816
|
+
}
|
|
31817
|
+
}
|
|
31759
31818
|
try {
|
|
31760
31819
|
const res = await collection.updateOne(
|
|
31761
31820
|
{ _id },
|
|
@@ -31809,6 +31868,37 @@ function useIncidentReportRepo() {
|
|
|
31809
31868
|
throw error;
|
|
31810
31869
|
}
|
|
31811
31870
|
}
|
|
31871
|
+
async function reviewIncidentReport(_id, value, session) {
|
|
31872
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
31873
|
+
try {
|
|
31874
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
31875
|
+
} catch (error) {
|
|
31876
|
+
throw new import_node_server_utils173.BadRequestError("Invalid ID format.");
|
|
31877
|
+
}
|
|
31878
|
+
try {
|
|
31879
|
+
const res = await collection.updateOne(
|
|
31880
|
+
{ _id },
|
|
31881
|
+
{ $set: value },
|
|
31882
|
+
{ session }
|
|
31883
|
+
);
|
|
31884
|
+
if (res.modifiedCount === 0) {
|
|
31885
|
+
throw new import_node_server_utils173.InternalServerError(
|
|
31886
|
+
`Unable to ${value.status} incident report.`
|
|
31887
|
+
);
|
|
31888
|
+
}
|
|
31889
|
+
delNamespace().then(() => {
|
|
31890
|
+
import_node_server_utils173.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
31891
|
+
}).catch((err) => {
|
|
31892
|
+
import_node_server_utils173.logger.error(
|
|
31893
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
31894
|
+
err
|
|
31895
|
+
);
|
|
31896
|
+
});
|
|
31897
|
+
return res;
|
|
31898
|
+
} catch (error) {
|
|
31899
|
+
throw error;
|
|
31900
|
+
}
|
|
31901
|
+
}
|
|
31812
31902
|
return {
|
|
31813
31903
|
add,
|
|
31814
31904
|
getAll,
|
|
@@ -31816,18 +31906,24 @@ function useIncidentReportRepo() {
|
|
|
31816
31906
|
updateIncidentReportById,
|
|
31817
31907
|
deleteIncidentReportById,
|
|
31818
31908
|
createIndexes,
|
|
31819
|
-
createTextIndex
|
|
31909
|
+
createTextIndex,
|
|
31910
|
+
reviewIncidentReport
|
|
31820
31911
|
};
|
|
31821
31912
|
}
|
|
31822
31913
|
|
|
31823
31914
|
// src/services/incident-report.service.ts
|
|
31824
31915
|
var import_openai = __toESM(require("openai"));
|
|
31825
31916
|
function useIncidentReportService() {
|
|
31826
|
-
const {
|
|
31917
|
+
const {
|
|
31918
|
+
add: _add,
|
|
31919
|
+
updateIncidentReportById: _updateIncidentReportById,
|
|
31920
|
+
reviewIncidentReport: _reviewIncidentReport
|
|
31921
|
+
} = useIncidentReportRepo();
|
|
31827
31922
|
const {
|
|
31828
31923
|
updateSiteIncidentCounter: _updateSiteIncidentCounter,
|
|
31829
31924
|
getSiteById: _getSiteById
|
|
31830
31925
|
} = useSiteRepo();
|
|
31926
|
+
const { getUserById } = useUserRepo();
|
|
31831
31927
|
const { getById: _getUnitById } = useBuildingUnitRepo();
|
|
31832
31928
|
const { getById: _getOrganizationById } = useOrgRepo();
|
|
31833
31929
|
async function add(value) {
|
|
@@ -31847,23 +31943,9 @@ function useIncidentReportService() {
|
|
|
31847
31943
|
);
|
|
31848
31944
|
}
|
|
31849
31945
|
}
|
|
31850
|
-
|
|
31851
|
-
const unit = await _getUnitById(
|
|
31852
|
-
value.incidentInformation.placeOfIncident.unit,
|
|
31853
|
-
session
|
|
31854
|
-
);
|
|
31855
|
-
if (!unit) {
|
|
31856
|
-
throw new Error(
|
|
31857
|
-
"Building unit not found for the provided place of incident."
|
|
31858
|
-
);
|
|
31859
|
-
}
|
|
31860
|
-
value.incidentInformation.placeOfIncident.incidentLocation = value.incidentInformation.placeOfIncident.block?.toString() + "-" + value.incidentInformation.placeOfIncident.level + "-" + unit?.name;
|
|
31861
|
-
} else {
|
|
31862
|
-
value.incidentInformation.placeOfIncident.incidentLocation = value.incidentInformation.placeOfIncident.other;
|
|
31863
|
-
}
|
|
31864
|
-
await _add(value, session);
|
|
31946
|
+
const result = await _add(value, session);
|
|
31865
31947
|
await session?.commitTransaction();
|
|
31866
|
-
return
|
|
31948
|
+
return result;
|
|
31867
31949
|
} catch (error) {
|
|
31868
31950
|
await session?.abortTransaction();
|
|
31869
31951
|
throw error;
|
|
@@ -31910,19 +31992,10 @@ function useIncidentReportService() {
|
|
|
31910
31992
|
value.site = site.name;
|
|
31911
31993
|
}
|
|
31912
31994
|
}
|
|
31913
|
-
if (value?.
|
|
31914
|
-
const
|
|
31915
|
-
|
|
31916
|
-
|
|
31917
|
-
);
|
|
31918
|
-
if (unit) {
|
|
31919
|
-
value.incidentInformation.placeOfIncident.unit = unit.name;
|
|
31920
|
-
}
|
|
31921
|
-
if (value?.organization) {
|
|
31922
|
-
const org = await _getOrganizationById(value.organization);
|
|
31923
|
-
if (org) {
|
|
31924
|
-
value.organization = org.name;
|
|
31925
|
-
}
|
|
31995
|
+
if (value?.organization) {
|
|
31996
|
+
const org = await _getOrganizationById(value.organization);
|
|
31997
|
+
if (org) {
|
|
31998
|
+
value.organization = org.name;
|
|
31926
31999
|
}
|
|
31927
32000
|
}
|
|
31928
32001
|
const completion = await openai.chat.completions.create({
|
|
@@ -31945,10 +32018,32 @@ function useIncidentReportService() {
|
|
|
31945
32018
|
throw error;
|
|
31946
32019
|
}
|
|
31947
32020
|
}
|
|
32021
|
+
async function reviewIncidentReport(id, value) {
|
|
32022
|
+
const session = import_node_server_utils174.useAtlas.getClient()?.startSession();
|
|
32023
|
+
session?.startTransaction();
|
|
32024
|
+
try {
|
|
32025
|
+
if (value.approvedBy) {
|
|
32026
|
+
const approvedBy = await getUserById(value.approvedBy);
|
|
32027
|
+
if (!approvedBy || !approvedBy.name)
|
|
32028
|
+
throw new import_node_server_utils174.BadRequestError("Created by not found.");
|
|
32029
|
+
value.approvedByName = approvedBy.name;
|
|
32030
|
+
value.approvedBy = approvedBy._id;
|
|
32031
|
+
}
|
|
32032
|
+
await _reviewIncidentReport(id, value, session);
|
|
32033
|
+
await session?.commitTransaction();
|
|
32034
|
+
return `Successfully ${value.status} incident report.`;
|
|
32035
|
+
} catch (error) {
|
|
32036
|
+
await session?.abortTransaction();
|
|
32037
|
+
throw error;
|
|
32038
|
+
} finally {
|
|
32039
|
+
session?.endSession();
|
|
32040
|
+
}
|
|
32041
|
+
}
|
|
31948
32042
|
return {
|
|
31949
32043
|
add,
|
|
31950
32044
|
updateIncidentReportById,
|
|
31951
|
-
createIncidentSummary
|
|
32045
|
+
createIncidentSummary,
|
|
32046
|
+
reviewIncidentReport
|
|
31952
32047
|
};
|
|
31953
32048
|
}
|
|
31954
32049
|
|
|
@@ -31959,7 +32054,8 @@ function useIncidentReportController() {
|
|
|
31959
32054
|
const {
|
|
31960
32055
|
add: _add,
|
|
31961
32056
|
updateIncidentReportById: _updateIncidentReportById,
|
|
31962
|
-
createIncidentSummary: _createIncidentSummary
|
|
32057
|
+
createIncidentSummary: _createIncidentSummary,
|
|
32058
|
+
reviewIncidentReport: _reviewIncidentReport
|
|
31963
32059
|
} = useIncidentReportService();
|
|
31964
32060
|
const {
|
|
31965
32061
|
getAll: _getAll,
|
|
@@ -31979,7 +32075,7 @@ function useIncidentReportController() {
|
|
|
31979
32075
|
}
|
|
31980
32076
|
try {
|
|
31981
32077
|
const data = await _add(payload);
|
|
31982
|
-
res.status(201).json(data);
|
|
32078
|
+
res.status(201).json({ data });
|
|
31983
32079
|
return;
|
|
31984
32080
|
} catch (error2) {
|
|
31985
32081
|
import_node_server_utils175.logger.log({ level: "error", message: error2.message });
|
|
@@ -32127,13 +32223,45 @@ function useIncidentReportController() {
|
|
|
32127
32223
|
return;
|
|
32128
32224
|
}
|
|
32129
32225
|
}
|
|
32226
|
+
async function reviewIncidentReport(req, res, next) {
|
|
32227
|
+
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
32228
|
+
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
32229
|
+
{}
|
|
32230
|
+
);
|
|
32231
|
+
req.body.approvedBy = cookies?.["user"].toString() ?? "";
|
|
32232
|
+
const _id = req.params.id;
|
|
32233
|
+
const payload = { _id, ...req.body };
|
|
32234
|
+
const schema2 = import_joi100.default.object({
|
|
32235
|
+
_id: import_joi100.default.string().hex().required(),
|
|
32236
|
+
status: import_joi100.default.string().valid("approved", "rejected").required(),
|
|
32237
|
+
approvedBy: import_joi100.default.string().required(),
|
|
32238
|
+
remarks: import_joi100.default.string().optional().allow("", null)
|
|
32239
|
+
});
|
|
32240
|
+
const { error } = schema2.validate(payload);
|
|
32241
|
+
if (error) {
|
|
32242
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
32243
|
+
import_node_server_utils175.logger.log({ level: "error", message: messages });
|
|
32244
|
+
next(new import_node_server_utils175.BadRequestError(messages));
|
|
32245
|
+
return;
|
|
32246
|
+
}
|
|
32247
|
+
try {
|
|
32248
|
+
const result = await _reviewIncidentReport(_id, req.body);
|
|
32249
|
+
res.status(200).json({ message: result });
|
|
32250
|
+
return;
|
|
32251
|
+
} catch (error2) {
|
|
32252
|
+
import_node_server_utils175.logger.log({ level: "error", message: error2.message });
|
|
32253
|
+
next(error2);
|
|
32254
|
+
return;
|
|
32255
|
+
}
|
|
32256
|
+
}
|
|
32130
32257
|
return {
|
|
32131
32258
|
add,
|
|
32132
32259
|
getAll,
|
|
32133
32260
|
getIncidentReportById,
|
|
32134
32261
|
updateIncidentReportById,
|
|
32135
32262
|
deleteIncidentReportById,
|
|
32136
|
-
createIncidentSummary
|
|
32263
|
+
createIncidentSummary,
|
|
32264
|
+
reviewIncidentReport
|
|
32137
32265
|
};
|
|
32138
32266
|
}
|
|
32139
32267
|
|
|
@@ -34047,6 +34175,7 @@ function useNfcPatrolLogController() {
|
|
|
34047
34175
|
EAccessCardUserTypes,
|
|
34048
34176
|
MAccessCard,
|
|
34049
34177
|
MAccessCardTransaction,
|
|
34178
|
+
MAddress,
|
|
34050
34179
|
MAttendance,
|
|
34051
34180
|
MAttendanceSettings,
|
|
34052
34181
|
MBillingConfiguration,
|
|
@@ -34181,6 +34310,7 @@ function useNfcPatrolLogController() {
|
|
|
34181
34310
|
siteSchema,
|
|
34182
34311
|
tokenSchema,
|
|
34183
34312
|
useAccessManagementController,
|
|
34313
|
+
useAddressRepo,
|
|
34184
34314
|
useAttendanceController,
|
|
34185
34315
|
useAttendanceRepository,
|
|
34186
34316
|
useAttendanceSettingsController,
|