@7365admin1/core 3.53.8 → 3.54.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 +47 -0
- package/dist/index.d.ts +229 -61
- package/dist/index.js +260 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/camera-view.util.test.mjs +4 -158
- package/test/e2e/harness.mjs +9 -0
- package/test/e2e/personal-emergency-chain-scope.e2e.test.mjs +373 -0
- package/test/notification-category.util.test.mjs +29 -11
- package/test/personal-emergency-chain.test.mjs +261 -0
- package/test/picker-site-scope.test.mjs +181 -0
package/dist/index.js
CHANGED
|
@@ -536,13 +536,13 @@ var require_logger = __commonJS({
|
|
|
536
536
|
"use strict";
|
|
537
537
|
exports.__esModule = true;
|
|
538
538
|
var _utils = require_utils();
|
|
539
|
-
var
|
|
539
|
+
var logger222 = {
|
|
540
540
|
methodMap: ["debug", "info", "warn", "error"],
|
|
541
541
|
level: "info",
|
|
542
542
|
// Maps a given level value to the `methodMap` indexes above.
|
|
543
543
|
lookupLevel: function lookupLevel(level) {
|
|
544
544
|
if (typeof level === "string") {
|
|
545
|
-
var levelMap = _utils.indexOf(
|
|
545
|
+
var levelMap = _utils.indexOf(logger222.methodMap, level.toLowerCase());
|
|
546
546
|
if (levelMap >= 0) {
|
|
547
547
|
level = levelMap;
|
|
548
548
|
} else {
|
|
@@ -553,9 +553,9 @@ var require_logger = __commonJS({
|
|
|
553
553
|
},
|
|
554
554
|
// Can be overridden in the host environment
|
|
555
555
|
log: function log(level) {
|
|
556
|
-
level =
|
|
557
|
-
if (typeof console !== "undefined" &&
|
|
558
|
-
var method =
|
|
556
|
+
level = logger222.lookupLevel(level);
|
|
557
|
+
if (typeof console !== "undefined" && logger222.lookupLevel(logger222.level) <= level) {
|
|
558
|
+
var method = logger222.methodMap[level];
|
|
559
559
|
if (!console[method]) {
|
|
560
560
|
method = "log";
|
|
561
561
|
}
|
|
@@ -566,7 +566,7 @@ var require_logger = __commonJS({
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
|
-
exports["default"] =
|
|
569
|
+
exports["default"] = logger222;
|
|
570
570
|
module2.exports = exports["default"];
|
|
571
571
|
}
|
|
572
572
|
});
|
|
@@ -5933,11 +5933,13 @@ __export(src_exports, {
|
|
|
5933
5933
|
CameraType: () => CameraType,
|
|
5934
5934
|
ConsoleAuditAction: () => ConsoleAuditAction,
|
|
5935
5935
|
ConsoleAuditTarget: () => ConsoleAuditTarget,
|
|
5936
|
+
DEFAULT_RING_SECONDS: () => DEFAULT_RING_SECONDS,
|
|
5936
5937
|
DEFAULT_SITE_TIMEZONE: () => DEFAULT_SITE_TIMEZONE,
|
|
5937
5938
|
DEVICE_STATUS: () => DEVICE_STATUS,
|
|
5938
5939
|
DOBStatus: () => DOBStatus,
|
|
5939
5940
|
DUPLICATE_TERMS_VERSION_MESSAGE: () => DUPLICATE_TERMS_VERSION_MESSAGE,
|
|
5940
5941
|
DayOfWeek: () => DayOfWeek,
|
|
5942
|
+
E164: () => E164,
|
|
5941
5943
|
EAccessCardTypes: () => EAccessCardTypes,
|
|
5942
5944
|
EAccessCardUserTypes: () => EAccessCardUserTypes,
|
|
5943
5945
|
EmailSender: () => EmailSender,
|
|
@@ -5960,6 +5962,8 @@ __export(src_exports, {
|
|
|
5960
5962
|
MAX_BULK_CAMERA_ROWS: () => MAX_BULK_CAMERA_ROWS,
|
|
5961
5963
|
MAX_CAMERA_CHANNEL: () => MAX_CAMERA_CHANNEL,
|
|
5962
5964
|
MAX_CAMERA_NAME_LENGTH: () => MAX_CAMERA_NAME_LENGTH,
|
|
5965
|
+
MAX_PERSONAL_EMERGENCY_CONTACTS: () => MAX_PERSONAL_EMERGENCY_CONTACTS,
|
|
5966
|
+
MAX_RING_SECONDS: () => MAX_RING_SECONDS,
|
|
5963
5967
|
MAccessCard: () => MAccessCard,
|
|
5964
5968
|
MAccessCardTransaction: () => MAccessCardTransaction,
|
|
5965
5969
|
MAddress: () => MAddress,
|
|
@@ -5993,6 +5997,7 @@ __export(src_exports, {
|
|
|
5993
5997
|
MHidAmicoReader: () => MHidAmicoReader,
|
|
5994
5998
|
MHidSipAccount: () => MHidSipAccount,
|
|
5995
5999
|
MHidSitePermissions: () => MHidSitePermissions,
|
|
6000
|
+
MIN_RING_SECONDS: () => MIN_RING_SECONDS,
|
|
5996
6001
|
MIncidentReport: () => MIncidentReport,
|
|
5997
6002
|
MManpowerDesignations: () => MManpowerDesignations,
|
|
5998
6003
|
MManpowerMonitoring: () => MManpowerMonitoring,
|
|
@@ -6018,6 +6023,7 @@ __export(src_exports, {
|
|
|
6018
6023
|
MPatrolQuestion: () => MPatrolQuestion,
|
|
6019
6024
|
MPatrolRoute: () => MPatrolRoute,
|
|
6020
6025
|
MPerson: () => MPerson,
|
|
6026
|
+
MPersonalEmergencyChain: () => MPersonalEmergencyChain,
|
|
6021
6027
|
MPlatformTerms: () => MPlatformTerms,
|
|
6022
6028
|
MPost: () => MPost,
|
|
6023
6029
|
MPostFavorite: () => MPostFavorite,
|
|
@@ -6160,6 +6166,7 @@ __export(src_exports, {
|
|
|
6160
6166
|
deviceHttpTimeoutMs: () => deviceHttpTimeoutMs,
|
|
6161
6167
|
deviceProbeTtlSeconds: () => deviceProbeTtlSeconds,
|
|
6162
6168
|
emitNotificationCreated: () => emitNotificationCreated,
|
|
6169
|
+
emptyPersonalEmergencyChain: () => emptyPersonalEmergencyChain,
|
|
6163
6170
|
encodeHidPacsCard: () => encodeHidPacsCard,
|
|
6164
6171
|
entitledSiteScope: () => entitledSiteScope,
|
|
6165
6172
|
events_namespace_collection: () => events_namespace_collection,
|
|
@@ -6216,7 +6223,6 @@ __export(src_exports, {
|
|
|
6216
6223
|
online_forms_namespace_collection: () => online_forms_namespace_collection,
|
|
6217
6224
|
orgLevelRoles: () => orgLevelRoles,
|
|
6218
6225
|
orgSchema: () => orgSchema,
|
|
6219
|
-
orgSiteScope: () => orgSiteScope,
|
|
6220
6226
|
overnight_parking_requests_namespace_collection: () => overnight_parking_requests_namespace_collection,
|
|
6221
6227
|
parseCameraChannel: () => parseCameraChannel,
|
|
6222
6228
|
parseCameraHost: () => parseCameraHost,
|
|
@@ -6343,6 +6349,7 @@ __export(src_exports, {
|
|
|
6343
6349
|
schemaPatrolQuestion: () => schemaPatrolQuestion,
|
|
6344
6350
|
schemaPatrolRoute: () => schemaPatrolRoute,
|
|
6345
6351
|
schemaPerson: () => schemaPerson,
|
|
6352
|
+
schemaPersonalEmergencyContact: () => schemaPersonalEmergencyContact,
|
|
6346
6353
|
schemaPlate: () => schemaPlate,
|
|
6347
6354
|
schemaPlatformTerms: () => schemaPlatformTerms,
|
|
6348
6355
|
schemaPost: () => schemaPost,
|
|
@@ -6388,6 +6395,7 @@ __export(src_exports, {
|
|
|
6388
6395
|
schemaUpdatePatrolQuestion: () => schemaUpdatePatrolQuestion,
|
|
6389
6396
|
schemaUpdatePatrolRoute: () => schemaUpdatePatrolRoute,
|
|
6390
6397
|
schemaUpdatePerson: () => schemaUpdatePerson,
|
|
6398
|
+
schemaUpdatePersonalEmergencyChain: () => schemaUpdatePersonalEmergencyChain,
|
|
6391
6399
|
schemaUpdatePost: () => schemaUpdatePost,
|
|
6392
6400
|
schemaUpdatePostFavorite: () => schemaUpdatePostFavorite,
|
|
6393
6401
|
schemaUpdateServiceProviderBilling: () => schemaUpdateServiceProviderBilling,
|
|
@@ -6568,6 +6576,9 @@ __export(src_exports, {
|
|
|
6568
6576
|
usePatrolRouteRepo: () => usePatrolRouteRepo,
|
|
6569
6577
|
usePersonController: () => usePersonController,
|
|
6570
6578
|
usePersonRepo: () => usePersonRepo,
|
|
6579
|
+
usePersonalEmergencyChainController: () => usePersonalEmergencyChainController,
|
|
6580
|
+
usePersonalEmergencyChainRepo: () => usePersonalEmergencyChainRepo,
|
|
6581
|
+
usePersonalEmergencyChainService: () => usePersonalEmergencyChainService,
|
|
6571
6582
|
usePlatformTermsController: () => usePlatformTermsController,
|
|
6572
6583
|
usePlatformTermsRepo: () => usePlatformTermsRepo,
|
|
6573
6584
|
usePlatformTermsService: () => usePlatformTermsService,
|
|
@@ -14876,12 +14887,15 @@ var NOTIFICATION_CATEGORIES = [
|
|
|
14876
14887
|
channelNote: { email: NO_EMAIL_RECIPIENT },
|
|
14877
14888
|
permissionResources: ["emergency-contact"],
|
|
14878
14889
|
safety: true,
|
|
14879
|
-
//
|
|
14880
|
-
// contacts are written
|
|
14881
|
-
//
|
|
14882
|
-
//
|
|
14883
|
-
//
|
|
14884
|
-
|
|
14890
|
+
// A caller exists again. `iservice365-API-core` is still the only place a
|
|
14891
|
+
// site's emergency contacts are written, and its `emergency.service.ts`
|
|
14892
|
+
// now calls the sender below on each of the three writes. That caller
|
|
14893
|
+
// reads THIS flag before it sends (`notificationCategory("emergencyContact")
|
|
14894
|
+
// ?.rendered`), so the two halves cannot land out of order and leave a
|
|
14895
|
+
// safety alert arriving with no switch to turn it off: whichever repository
|
|
14896
|
+
// merges first, the alert only starts once a published core carrying this
|
|
14897
|
+
// line is installed there.
|
|
14898
|
+
rendered: true
|
|
14885
14899
|
},
|
|
14886
14900
|
{
|
|
14887
14901
|
key: "virtualPatrol",
|
|
@@ -25069,22 +25083,6 @@ function selectHealthTargets(cameraIds, cap, isValidId) {
|
|
|
25069
25083
|
truncated: unique.length > limit
|
|
25070
25084
|
};
|
|
25071
25085
|
}
|
|
25072
|
-
function orgSiteScope(params) {
|
|
25073
|
-
const org = idOf(params.org);
|
|
25074
|
-
if (!org)
|
|
25075
|
-
return null;
|
|
25076
|
-
const inOrg = params.memberships.filter(
|
|
25077
|
-
(membership) => idOf(membership.org) === org
|
|
25078
|
-
);
|
|
25079
|
-
if (inOrg.some(
|
|
25080
|
-
(membership) => !idOf(membership.siteId) || membership.orgLevelRole === true
|
|
25081
|
-
)) {
|
|
25082
|
-
return null;
|
|
25083
|
-
}
|
|
25084
|
-
return Array.from(
|
|
25085
|
-
new Set(inOrg.map((membership) => idOf(membership.siteId)).filter(Boolean))
|
|
25086
|
-
);
|
|
25087
|
-
}
|
|
25088
25086
|
function entitledSiteScope(params) {
|
|
25089
25087
|
const sites = /* @__PURE__ */ new Set();
|
|
25090
25088
|
for (const membership of params.memberships) {
|
|
@@ -29915,7 +29913,7 @@ function usePromoCodeRepo() {
|
|
|
29915
29913
|
}
|
|
29916
29914
|
}
|
|
29917
29915
|
async function updateById(_id, value) {
|
|
29918
|
-
const objectId2 =
|
|
29916
|
+
const objectId2 = toObjectId26(_id);
|
|
29919
29917
|
const changes = promoCodeUpdate(value);
|
|
29920
29918
|
const res = await collection.updateOne(
|
|
29921
29919
|
{ _id: objectId2, deletedAt: null },
|
|
@@ -29928,7 +29926,7 @@ function usePromoCodeRepo() {
|
|
|
29928
29926
|
return res;
|
|
29929
29927
|
}
|
|
29930
29928
|
async function updateStatusById(_id, status) {
|
|
29931
|
-
const objectId2 =
|
|
29929
|
+
const objectId2 = toObjectId26(_id);
|
|
29932
29930
|
const res = await collection.updateOne(
|
|
29933
29931
|
{ _id: objectId2, deletedAt: null },
|
|
29934
29932
|
{ $set: { status } }
|
|
@@ -29940,7 +29938,7 @@ function usePromoCodeRepo() {
|
|
|
29940
29938
|
return res;
|
|
29941
29939
|
}
|
|
29942
29940
|
async function softDeleteById(_id, deletedBy) {
|
|
29943
|
-
const objectId2 =
|
|
29941
|
+
const objectId2 = toObjectId26(_id);
|
|
29944
29942
|
const res = await collection.updateOne(
|
|
29945
29943
|
{ _id: objectId2, deletedAt: null },
|
|
29946
29944
|
{
|
|
@@ -29957,7 +29955,7 @@ function usePromoCodeRepo() {
|
|
|
29957
29955
|
await invalidate(`delete ${objectId2}`);
|
|
29958
29956
|
return res;
|
|
29959
29957
|
}
|
|
29960
|
-
function
|
|
29958
|
+
function toObjectId26(_id) {
|
|
29961
29959
|
const { error } = import_joi34.default.object({
|
|
29962
29960
|
_id: import_joi34.default.string().hex().length(24).required()
|
|
29963
29961
|
}).validate({ _id: String(_id) });
|
|
@@ -42355,8 +42353,7 @@ function useCustomerSiteController() {
|
|
|
42355
42353
|
});
|
|
42356
42354
|
try {
|
|
42357
42355
|
await requireOrgAccess(req, org);
|
|
42358
|
-
const
|
|
42359
|
-
const siteScope = staffMayBypass(actor) ? null : orgSiteScope({ memberships: actor.memberships, org });
|
|
42356
|
+
const siteScope = await entitledSites(req);
|
|
42360
42357
|
const data = await _getAll({
|
|
42361
42358
|
search,
|
|
42362
42359
|
page,
|
|
@@ -92088,6 +92085,222 @@ function useNotificationPreferenceController() {
|
|
|
92088
92085
|
}
|
|
92089
92086
|
return { get, update };
|
|
92090
92087
|
}
|
|
92088
|
+
|
|
92089
|
+
// src/models/personal-emergency-chain.model.ts
|
|
92090
|
+
var import_node_server_utils303 = require("@7365admin1/node-server-utils");
|
|
92091
|
+
var import_mongodb184 = require("mongodb");
|
|
92092
|
+
var import_joi167 = __toESM(require("joi"));
|
|
92093
|
+
var MAX_PERSONAL_EMERGENCY_CONTACTS = 10;
|
|
92094
|
+
var MIN_RING_SECONDS = 5;
|
|
92095
|
+
var MAX_RING_SECONDS = 120;
|
|
92096
|
+
var DEFAULT_RING_SECONDS = 20;
|
|
92097
|
+
var E164 = /^\+[1-9]\d{1,14}$/;
|
|
92098
|
+
var schemaPersonalEmergencyContact = import_joi167.default.object({
|
|
92099
|
+
name: import_joi167.default.string().trim().min(1).max(120).required(),
|
|
92100
|
+
phone: import_joi167.default.string().trim().pattern(E164).required().messages({
|
|
92101
|
+
"string.pattern.base": "Phone number must be in international format, e.g. +6591234567."
|
|
92102
|
+
}),
|
|
92103
|
+
relationship: import_joi167.default.string().trim().max(60).allow("", null).default(""),
|
|
92104
|
+
order: import_joi167.default.number().integer().min(1).max(MAX_PERSONAL_EMERGENCY_CONTACTS).required(),
|
|
92105
|
+
active: import_joi167.default.boolean().default(true)
|
|
92106
|
+
});
|
|
92107
|
+
var schemaUpdatePersonalEmergencyChain = import_joi167.default.object({
|
|
92108
|
+
contacts: import_joi167.default.array().items(schemaPersonalEmergencyContact).unique("order").max(MAX_PERSONAL_EMERGENCY_CONTACTS).required().messages({
|
|
92109
|
+
"array.unique": "Two contacts cannot share the same position in the chain."
|
|
92110
|
+
}),
|
|
92111
|
+
ringSeconds: import_joi167.default.number().integer().min(MIN_RING_SECONDS).max(MAX_RING_SECONDS).default(DEFAULT_RING_SECONDS),
|
|
92112
|
+
siteDirectoryFallback: import_joi167.default.boolean().default(true),
|
|
92113
|
+
org: import_joi167.default.string().hex().length(24).allow("", null).default(null),
|
|
92114
|
+
site: import_joi167.default.string().hex().length(24).allow("", null).default(null)
|
|
92115
|
+
});
|
|
92116
|
+
var toObjectId25 = (value, what) => {
|
|
92117
|
+
if (value === null || value === void 0 || value === "")
|
|
92118
|
+
return null;
|
|
92119
|
+
const id = value.toString();
|
|
92120
|
+
if (!import_mongodb184.ObjectId.isValid(id))
|
|
92121
|
+
throw new import_node_server_utils303.BadRequestError(`Invalid ${what}.`);
|
|
92122
|
+
return new import_mongodb184.ObjectId(id);
|
|
92123
|
+
};
|
|
92124
|
+
function MPersonalEmergencyChain(value) {
|
|
92125
|
+
const user = toObjectId25(value.user, "user ID");
|
|
92126
|
+
if (!user)
|
|
92127
|
+
throw new import_node_server_utils303.BadRequestError("Invalid user ID.");
|
|
92128
|
+
const contacts = [...value.contacts ?? []].map((c) => ({
|
|
92129
|
+
name: c.name.trim(),
|
|
92130
|
+
phone: c.phone.trim(),
|
|
92131
|
+
relationship: (c.relationship ?? "").trim(),
|
|
92132
|
+
order: c.order,
|
|
92133
|
+
active: c.active ?? true
|
|
92134
|
+
})).sort((a, b) => a.order - b.order);
|
|
92135
|
+
const seen = /* @__PURE__ */ new Set();
|
|
92136
|
+
for (const contact of contacts) {
|
|
92137
|
+
if (seen.has(contact.order)) {
|
|
92138
|
+
throw new import_node_server_utils303.BadRequestError(
|
|
92139
|
+
"Two contacts cannot share the same position in the chain."
|
|
92140
|
+
);
|
|
92141
|
+
}
|
|
92142
|
+
seen.add(contact.order);
|
|
92143
|
+
}
|
|
92144
|
+
const now = /* @__PURE__ */ new Date();
|
|
92145
|
+
return {
|
|
92146
|
+
user,
|
|
92147
|
+
org: toObjectId25(value.org, "organization ID"),
|
|
92148
|
+
site: toObjectId25(value.site, "site ID"),
|
|
92149
|
+
contacts,
|
|
92150
|
+
ringSeconds: value.ringSeconds ?? DEFAULT_RING_SECONDS,
|
|
92151
|
+
siteDirectoryFallback: value.siteDirectoryFallback ?? true,
|
|
92152
|
+
createdAt: value.createdAt ?? now,
|
|
92153
|
+
updatedAt: now
|
|
92154
|
+
};
|
|
92155
|
+
}
|
|
92156
|
+
function emptyPersonalEmergencyChain(user) {
|
|
92157
|
+
return {
|
|
92158
|
+
user,
|
|
92159
|
+
org: null,
|
|
92160
|
+
site: null,
|
|
92161
|
+
contacts: [],
|
|
92162
|
+
ringSeconds: DEFAULT_RING_SECONDS,
|
|
92163
|
+
siteDirectoryFallback: true
|
|
92164
|
+
};
|
|
92165
|
+
}
|
|
92166
|
+
|
|
92167
|
+
// src/repositories/personal-emergency-chain.repo.ts
|
|
92168
|
+
var import_mongodb185 = require("mongodb");
|
|
92169
|
+
var import_node_server_utils304 = require("@7365admin1/node-server-utils");
|
|
92170
|
+
function usePersonalEmergencyChainRepo() {
|
|
92171
|
+
const namespace_collection = "personal-emergency-contacts";
|
|
92172
|
+
const getDB2 = () => {
|
|
92173
|
+
const db2 = import_node_server_utils304.useAtlas.getDb();
|
|
92174
|
+
if (!db2) {
|
|
92175
|
+
throw new import_node_server_utils304.InternalServerError("Unable to connect to server.");
|
|
92176
|
+
}
|
|
92177
|
+
return db2;
|
|
92178
|
+
};
|
|
92179
|
+
const collection = () => getDB2().collection(namespace_collection);
|
|
92180
|
+
async function createIndexes() {
|
|
92181
|
+
try {
|
|
92182
|
+
await collection().createIndexes([
|
|
92183
|
+
{ key: { user: 1 }, name: "one_chain_per_user", unique: true }
|
|
92184
|
+
]);
|
|
92185
|
+
return `Successfully created indexes for ${namespace_collection}.`;
|
|
92186
|
+
} catch (error) {
|
|
92187
|
+
import_node_server_utils304.logger.log({ level: "error", message: error.message });
|
|
92188
|
+
throw new import_node_server_utils304.InternalServerError(
|
|
92189
|
+
`Failed to create indexes for ${namespace_collection}.`
|
|
92190
|
+
);
|
|
92191
|
+
}
|
|
92192
|
+
}
|
|
92193
|
+
async function getByUser(user) {
|
|
92194
|
+
if (!import_mongodb185.ObjectId.isValid(user)) {
|
|
92195
|
+
throw new import_node_server_utils304.BadRequestError("Invalid user ID format.");
|
|
92196
|
+
}
|
|
92197
|
+
try {
|
|
92198
|
+
const doc = await collection().findOne({ user: new import_mongodb185.ObjectId(user) });
|
|
92199
|
+
return doc ?? emptyPersonalEmergencyChain(user);
|
|
92200
|
+
} catch (error) {
|
|
92201
|
+
if (error instanceof import_node_server_utils304.AppError)
|
|
92202
|
+
throw error;
|
|
92203
|
+
import_node_server_utils304.logger.log({ level: "error", message: error.message });
|
|
92204
|
+
throw new import_node_server_utils304.InternalServerError("Failed to retrieve emergency contacts.");
|
|
92205
|
+
}
|
|
92206
|
+
}
|
|
92207
|
+
async function replaceForUser(user, value) {
|
|
92208
|
+
const doc = MPersonalEmergencyChain({ ...value, user });
|
|
92209
|
+
try {
|
|
92210
|
+
await collection().updateOne(
|
|
92211
|
+
{ user: doc.user },
|
|
92212
|
+
{
|
|
92213
|
+
$set: {
|
|
92214
|
+
contacts: doc.contacts,
|
|
92215
|
+
ringSeconds: doc.ringSeconds,
|
|
92216
|
+
siteDirectoryFallback: doc.siteDirectoryFallback,
|
|
92217
|
+
org: doc.org,
|
|
92218
|
+
site: doc.site,
|
|
92219
|
+
updatedAt: doc.updatedAt
|
|
92220
|
+
},
|
|
92221
|
+
$setOnInsert: { user: doc.user, createdAt: doc.createdAt }
|
|
92222
|
+
},
|
|
92223
|
+
{ upsert: true }
|
|
92224
|
+
);
|
|
92225
|
+
return doc;
|
|
92226
|
+
} catch (error) {
|
|
92227
|
+
if (error instanceof import_node_server_utils304.AppError)
|
|
92228
|
+
throw error;
|
|
92229
|
+
import_node_server_utils304.logger.log({ level: "error", message: error.message });
|
|
92230
|
+
throw new import_node_server_utils304.InternalServerError("Failed to save emergency contacts.");
|
|
92231
|
+
}
|
|
92232
|
+
}
|
|
92233
|
+
return { createIndexes, getByUser, replaceForUser };
|
|
92234
|
+
}
|
|
92235
|
+
|
|
92236
|
+
// src/services/personal-emergency-chain.service.ts
|
|
92237
|
+
var import_node_server_utils305 = require("@7365admin1/node-server-utils");
|
|
92238
|
+
function usePersonalEmergencyChainService() {
|
|
92239
|
+
async function getForUser(user) {
|
|
92240
|
+
if (!user)
|
|
92241
|
+
throw new import_node_server_utils305.BadRequestError("No user in session.");
|
|
92242
|
+
return await usePersonalEmergencyChainRepo().getByUser(user);
|
|
92243
|
+
}
|
|
92244
|
+
async function updateForUser(user, value) {
|
|
92245
|
+
if (!user)
|
|
92246
|
+
throw new import_node_server_utils305.BadRequestError("No user in session.");
|
|
92247
|
+
return await usePersonalEmergencyChainRepo().replaceForUser(
|
|
92248
|
+
user,
|
|
92249
|
+
value
|
|
92250
|
+
);
|
|
92251
|
+
}
|
|
92252
|
+
return { getForUser, updateForUser };
|
|
92253
|
+
}
|
|
92254
|
+
|
|
92255
|
+
// src/controllers/personal-emergency-chain.controller.ts
|
|
92256
|
+
var import_node_server_utils306 = require("@7365admin1/node-server-utils");
|
|
92257
|
+
function usePersonalEmergencyChainController() {
|
|
92258
|
+
const { getForUser, updateForUser } = usePersonalEmergencyChainService();
|
|
92259
|
+
async function get(req, res, next) {
|
|
92260
|
+
const userId = req.params.userId;
|
|
92261
|
+
try {
|
|
92262
|
+
await requireSelfOrPlatformStaff(req, userId, {
|
|
92263
|
+
resource: "users",
|
|
92264
|
+
action: "see-user-details"
|
|
92265
|
+
});
|
|
92266
|
+
res.status(200).json({ data: await getForUser(userId) });
|
|
92267
|
+
} catch (error) {
|
|
92268
|
+
import_node_server_utils306.logger.log({ level: "error", message: error.message });
|
|
92269
|
+
next(error);
|
|
92270
|
+
}
|
|
92271
|
+
}
|
|
92272
|
+
async function update(req, res, next) {
|
|
92273
|
+
const userId = req.params.userId;
|
|
92274
|
+
try {
|
|
92275
|
+
await requireSelfOrPlatformStaff(req, userId, {
|
|
92276
|
+
resource: "users",
|
|
92277
|
+
action: "see-user-details"
|
|
92278
|
+
});
|
|
92279
|
+
} catch (error2) {
|
|
92280
|
+
import_node_server_utils306.logger.log({ level: "error", message: error2.message });
|
|
92281
|
+
next(error2);
|
|
92282
|
+
return;
|
|
92283
|
+
}
|
|
92284
|
+
const { error, value } = schemaUpdatePersonalEmergencyChain.validate(
|
|
92285
|
+
req.body,
|
|
92286
|
+
{ convert: true }
|
|
92287
|
+
);
|
|
92288
|
+
if (error) {
|
|
92289
|
+
next(new import_node_server_utils306.BadRequestError(error.details[0].message));
|
|
92290
|
+
return;
|
|
92291
|
+
}
|
|
92292
|
+
try {
|
|
92293
|
+
res.status(200).json({
|
|
92294
|
+
message: "success",
|
|
92295
|
+
data: await updateForUser(userId, value)
|
|
92296
|
+
});
|
|
92297
|
+
} catch (err) {
|
|
92298
|
+
import_node_server_utils306.logger.log({ level: "error", message: err.message });
|
|
92299
|
+
next(err);
|
|
92300
|
+
}
|
|
92301
|
+
}
|
|
92302
|
+
return { get, update };
|
|
92303
|
+
}
|
|
92091
92304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
92092
92305
|
0 && (module.exports = {
|
|
92093
92306
|
ANPRMode,
|
|
@@ -92134,11 +92347,13 @@ function useNotificationPreferenceController() {
|
|
|
92134
92347
|
CameraType,
|
|
92135
92348
|
ConsoleAuditAction,
|
|
92136
92349
|
ConsoleAuditTarget,
|
|
92350
|
+
DEFAULT_RING_SECONDS,
|
|
92137
92351
|
DEFAULT_SITE_TIMEZONE,
|
|
92138
92352
|
DEVICE_STATUS,
|
|
92139
92353
|
DOBStatus,
|
|
92140
92354
|
DUPLICATE_TERMS_VERSION_MESSAGE,
|
|
92141
92355
|
DayOfWeek,
|
|
92356
|
+
E164,
|
|
92142
92357
|
EAccessCardTypes,
|
|
92143
92358
|
EAccessCardUserTypes,
|
|
92144
92359
|
EmailSender,
|
|
@@ -92161,6 +92376,8 @@ function useNotificationPreferenceController() {
|
|
|
92161
92376
|
MAX_BULK_CAMERA_ROWS,
|
|
92162
92377
|
MAX_CAMERA_CHANNEL,
|
|
92163
92378
|
MAX_CAMERA_NAME_LENGTH,
|
|
92379
|
+
MAX_PERSONAL_EMERGENCY_CONTACTS,
|
|
92380
|
+
MAX_RING_SECONDS,
|
|
92164
92381
|
MAccessCard,
|
|
92165
92382
|
MAccessCardTransaction,
|
|
92166
92383
|
MAddress,
|
|
@@ -92194,6 +92411,7 @@ function useNotificationPreferenceController() {
|
|
|
92194
92411
|
MHidAmicoReader,
|
|
92195
92412
|
MHidSipAccount,
|
|
92196
92413
|
MHidSitePermissions,
|
|
92414
|
+
MIN_RING_SECONDS,
|
|
92197
92415
|
MIncidentReport,
|
|
92198
92416
|
MManpowerDesignations,
|
|
92199
92417
|
MManpowerMonitoring,
|
|
@@ -92219,6 +92437,7 @@ function useNotificationPreferenceController() {
|
|
|
92219
92437
|
MPatrolQuestion,
|
|
92220
92438
|
MPatrolRoute,
|
|
92221
92439
|
MPerson,
|
|
92440
|
+
MPersonalEmergencyChain,
|
|
92222
92441
|
MPlatformTerms,
|
|
92223
92442
|
MPost,
|
|
92224
92443
|
MPostFavorite,
|
|
@@ -92361,6 +92580,7 @@ function useNotificationPreferenceController() {
|
|
|
92361
92580
|
deviceHttpTimeoutMs,
|
|
92362
92581
|
deviceProbeTtlSeconds,
|
|
92363
92582
|
emitNotificationCreated,
|
|
92583
|
+
emptyPersonalEmergencyChain,
|
|
92364
92584
|
encodeHidPacsCard,
|
|
92365
92585
|
entitledSiteScope,
|
|
92366
92586
|
events_namespace_collection,
|
|
@@ -92417,7 +92637,6 @@ function useNotificationPreferenceController() {
|
|
|
92417
92637
|
online_forms_namespace_collection,
|
|
92418
92638
|
orgLevelRoles,
|
|
92419
92639
|
orgSchema,
|
|
92420
|
-
orgSiteScope,
|
|
92421
92640
|
overnight_parking_requests_namespace_collection,
|
|
92422
92641
|
parseCameraChannel,
|
|
92423
92642
|
parseCameraHost,
|
|
@@ -92544,6 +92763,7 @@ function useNotificationPreferenceController() {
|
|
|
92544
92763
|
schemaPatrolQuestion,
|
|
92545
92764
|
schemaPatrolRoute,
|
|
92546
92765
|
schemaPerson,
|
|
92766
|
+
schemaPersonalEmergencyContact,
|
|
92547
92767
|
schemaPlate,
|
|
92548
92768
|
schemaPlatformTerms,
|
|
92549
92769
|
schemaPost,
|
|
@@ -92589,6 +92809,7 @@ function useNotificationPreferenceController() {
|
|
|
92589
92809
|
schemaUpdatePatrolQuestion,
|
|
92590
92810
|
schemaUpdatePatrolRoute,
|
|
92591
92811
|
schemaUpdatePerson,
|
|
92812
|
+
schemaUpdatePersonalEmergencyChain,
|
|
92592
92813
|
schemaUpdatePost,
|
|
92593
92814
|
schemaUpdatePostFavorite,
|
|
92594
92815
|
schemaUpdateServiceProviderBilling,
|
|
@@ -92769,6 +92990,9 @@ function useNotificationPreferenceController() {
|
|
|
92769
92990
|
usePatrolRouteRepo,
|
|
92770
92991
|
usePersonController,
|
|
92771
92992
|
usePersonRepo,
|
|
92993
|
+
usePersonalEmergencyChainController,
|
|
92994
|
+
usePersonalEmergencyChainRepo,
|
|
92995
|
+
usePersonalEmergencyChainService,
|
|
92772
92996
|
usePlatformTermsController,
|
|
92773
92997
|
usePlatformTermsRepo,
|
|
92774
92998
|
usePlatformTermsService,
|