@7365admin1/core 3.79.1-staging.339 → 3.79.1-staging.340
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/.changeset/hid-sip-account-list.md +17 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +52 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
List a site's HID SIP accounts for the intercom contact picker.
|
|
6
|
+
|
|
7
|
+
`hid-sip-accounts` could only be reached through `ensureSipAccount`, which
|
|
8
|
+
creates and returns the CALLER's own extension together with its password.
|
|
9
|
+
The intercom contact dialog needs the opposite view: every person on the site
|
|
10
|
+
who holds an extension, so a contact names someone the reader can actually
|
|
11
|
+
ring instead of a free-typed label.
|
|
12
|
+
|
|
13
|
+
`listSipAccounts(orgId, siteId)` reads the site's non-disabled accounts, joins
|
|
14
|
+
each to its `users` row for the display name and email, and returns name,
|
|
15
|
+
extension, username and status per account. The SIP password is never in the
|
|
16
|
+
response. The controller guards it with `authorizeSite` in the handler body,
|
|
17
|
+
the same way `listEnrollmentReaders` does, so a router edit cannot expose it.
|
package/dist/index.d.ts
CHANGED
|
@@ -14239,6 +14239,16 @@ declare function useHidAmicoRepo(): {
|
|
|
14239
14239
|
pageRange: string;
|
|
14240
14240
|
}>;
|
|
14241
14241
|
getSipAccount: (orgIdValue: string | ObjectId, siteValue: string | ObjectId, userValue: string | ObjectId) => Promise<mongodb.WithId<bson.Document> | null>;
|
|
14242
|
+
listSipAccounts: (orgIdValue: string | ObjectId, siteValue: string | ObjectId) => Promise<{
|
|
14243
|
+
_id: string;
|
|
14244
|
+
userId: string;
|
|
14245
|
+
name: string;
|
|
14246
|
+
email: string;
|
|
14247
|
+
extension: string;
|
|
14248
|
+
username: string;
|
|
14249
|
+
status: string;
|
|
14250
|
+
provisionedAt: any;
|
|
14251
|
+
}[]>;
|
|
14242
14252
|
nextSipExtension: () => Promise<string>;
|
|
14243
14253
|
reserveSipAccount: (value: THidSipAccount) => Promise<mongodb.WithId<bson.Document>>;
|
|
14244
14254
|
updateSipAccount: (id: string | ObjectId, value: Pick<THidSipAccount, "status" | "provisionedAt" | "lastProvisionError">) => Promise<mongodb.WithId<bson.Document>>;
|
|
@@ -14859,6 +14869,16 @@ declare function useHidAmicoService(): {
|
|
|
14859
14869
|
status: "active" | "failed" | "disabled" | "provisioning" | undefined;
|
|
14860
14870
|
provisionedAt: string | Date;
|
|
14861
14871
|
}>;
|
|
14872
|
+
listSipAccounts: (orgId: string, siteId: string) => Promise<{
|
|
14873
|
+
_id: string;
|
|
14874
|
+
userId: string;
|
|
14875
|
+
name: string;
|
|
14876
|
+
email: string;
|
|
14877
|
+
extension: string;
|
|
14878
|
+
username: string;
|
|
14879
|
+
status: string;
|
|
14880
|
+
provisionedAt: any;
|
|
14881
|
+
}[]>;
|
|
14862
14882
|
};
|
|
14863
14883
|
|
|
14864
14884
|
declare function useHidAmicoController(): {
|
|
@@ -14920,6 +14940,7 @@ declare function useHidAmicoController(): {
|
|
|
14920
14940
|
makeIntercomCall: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14921
14941
|
finalizeIntercomCall: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14922
14942
|
ensureSipAccount: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14943
|
+
listSipAccounts: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14923
14944
|
getSitePermissions: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14924
14945
|
listPermissionCandidates: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
14925
14946
|
updateSitePermissions: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -47078,6 +47078,34 @@ function useHidAmicoRepo() {
|
|
|
47078
47078
|
status: { $ne: "disabled" }
|
|
47079
47079
|
});
|
|
47080
47080
|
}
|
|
47081
|
+
async function listSipAccounts(orgIdValue, siteValue) {
|
|
47082
|
+
const accounts = await sipAccounts().find({
|
|
47083
|
+
orgId: toId3(orgIdValue, "organization ID"),
|
|
47084
|
+
site: toId3(siteValue, "site ID"),
|
|
47085
|
+
status: { $ne: "disabled" }
|
|
47086
|
+
}, {
|
|
47087
|
+
projection: { user: 1, extension: 1, username: 1, status: 1, provisionedAt: 1 }
|
|
47088
|
+
}).sort({ extension: 1 }).toArray();
|
|
47089
|
+
const userIds = accounts.map((account) => optionalObjectId2(account.user)).filter((value) => Boolean(value));
|
|
47090
|
+
const users = userIds.length ? await db2().collection("users").find(
|
|
47091
|
+
{ _id: { $in: userIds } },
|
|
47092
|
+
{ projection: { name: 1, email: 1 } }
|
|
47093
|
+
).toArray() : [];
|
|
47094
|
+
const userMap = new Map(users.map((user) => [String(user._id), user]));
|
|
47095
|
+
return accounts.map((account) => {
|
|
47096
|
+
const user = userMap.get(String(account.user));
|
|
47097
|
+
return {
|
|
47098
|
+
_id: String(account._id),
|
|
47099
|
+
userId: String(account.user),
|
|
47100
|
+
name: String(user?.name || user?.email || ""),
|
|
47101
|
+
email: String(user?.email || ""),
|
|
47102
|
+
extension: String(account.extension || ""),
|
|
47103
|
+
username: String(account.username || ""),
|
|
47104
|
+
status: String(account.status || ""),
|
|
47105
|
+
provisionedAt: account.provisionedAt || ""
|
|
47106
|
+
};
|
|
47107
|
+
});
|
|
47108
|
+
}
|
|
47081
47109
|
async function nextSipExtension() {
|
|
47082
47110
|
const configuredStart = Number.parseInt(process.env.HID_SIP_EXTENSION_START || "7100", 10);
|
|
47083
47111
|
const start = Number.isInteger(configuredStart) && configuredStart > 0 ? configuredStart : 7100;
|
|
@@ -47596,6 +47624,7 @@ function useHidAmicoRepo() {
|
|
|
47596
47624
|
assertPermissionSubject,
|
|
47597
47625
|
listPermissionCandidates,
|
|
47598
47626
|
getSipAccount,
|
|
47627
|
+
listSipAccounts,
|
|
47599
47628
|
nextSipExtension,
|
|
47600
47629
|
reserveSipAccount,
|
|
47601
47630
|
updateSipAccount,
|
|
@@ -52839,6 +52868,10 @@ function useHidAmicoService() {
|
|
|
52839
52868
|
}
|
|
52840
52869
|
return sipAccountResponse(account);
|
|
52841
52870
|
}
|
|
52871
|
+
async function listSipAccounts(orgId, siteId) {
|
|
52872
|
+
await repo.assertOrganizationSiteAccess(siteId, orgId);
|
|
52873
|
+
return repo.listSipAccounts(orgId, siteId);
|
|
52874
|
+
}
|
|
52842
52875
|
return {
|
|
52843
52876
|
authorizeReader,
|
|
52844
52877
|
authorizeReaderUser,
|
|
@@ -52903,7 +52936,8 @@ function useHidAmicoService() {
|
|
|
52903
52936
|
getSitePermissions,
|
|
52904
52937
|
listPermissionCandidates,
|
|
52905
52938
|
updateSitePermissions,
|
|
52906
|
-
ensureSipAccount
|
|
52939
|
+
ensureSipAccount,
|
|
52940
|
+
listSipAccounts
|
|
52907
52941
|
};
|
|
52908
52942
|
}
|
|
52909
52943
|
|
|
@@ -93819,6 +93853,22 @@ function useHidAmicoController() {
|
|
|
93819
93853
|
next(error);
|
|
93820
93854
|
}
|
|
93821
93855
|
}
|
|
93856
|
+
async function listSipAccounts(req, res, next) {
|
|
93857
|
+
const params = schemaHidAmicoSiteIdParams.validate(req.params);
|
|
93858
|
+
const query2 = schemaHidSipAccountRequest.validate(req.query);
|
|
93859
|
+
if (params.error || query2.error) {
|
|
93860
|
+
next(new import_node_server_utils306.BadRequestError(params.error?.message || query2.error?.message));
|
|
93861
|
+
return;
|
|
93862
|
+
}
|
|
93863
|
+
try {
|
|
93864
|
+
await authorizeSite(req, params.value.siteId);
|
|
93865
|
+
res.json({
|
|
93866
|
+
data: await service.listSipAccounts(query2.value.orgId, params.value.siteId)
|
|
93867
|
+
});
|
|
93868
|
+
} catch (error) {
|
|
93869
|
+
next(error);
|
|
93870
|
+
}
|
|
93871
|
+
}
|
|
93822
93872
|
async function getSitePermissions(req, res, next) {
|
|
93823
93873
|
const params = schemaHidAmicoSiteIdParams.validate(req.params);
|
|
93824
93874
|
const query2 = schemaHidPermissionScopeQuery.validate(req.query);
|
|
@@ -93934,6 +93984,7 @@ function useHidAmicoController() {
|
|
|
93934
93984
|
makeIntercomCall,
|
|
93935
93985
|
finalizeIntercomCall,
|
|
93936
93986
|
ensureSipAccount,
|
|
93987
|
+
listSipAccounts,
|
|
93937
93988
|
getSitePermissions,
|
|
93938
93989
|
listPermissionCandidates,
|
|
93939
93990
|
updateSitePermissions
|