@7365admin1/core 3.13.0 → 3.14.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.js +29 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -8716,6 +8716,7 @@ var APP_POOL_MAINTENANCE = process.env.APP_POOL_MAINTENANCE ?? "http://localhost
|
|
|
8716
8716
|
var ENCRYPTION_KEY = process.env.ENCRYPTION_KEY ?? "";
|
|
8717
8717
|
var DOMAIN = process.env.DOMAIN ?? "localhost";
|
|
8718
8718
|
var OPEN_AI_API_KEY = process.env.OPEN_AI_API_KEY;
|
|
8719
|
+
var ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
|
8719
8720
|
var STORAGE_API = process.env.STORAGE_API;
|
|
8720
8721
|
|
|
8721
8722
|
// src/services/auth.service.ts
|
|
@@ -9216,59 +9217,41 @@ function useMemberRepo() {
|
|
|
9216
9217
|
try {
|
|
9217
9218
|
const items = await collection.aggregate([
|
|
9218
9219
|
{ $match: query },
|
|
9219
|
-
{ $sort: { _id: -1 } },
|
|
9220
|
-
{ $skip: page * limit },
|
|
9221
|
-
{ $limit: limit },
|
|
9222
|
-
{
|
|
9223
|
-
$lookup: {
|
|
9224
|
-
from: "organizations",
|
|
9225
|
-
localField: "org",
|
|
9226
|
-
foreignField: "_id",
|
|
9227
|
-
as: "orgData"
|
|
9228
|
-
}
|
|
9229
|
-
},
|
|
9230
|
-
{
|
|
9231
|
-
$unwind: {
|
|
9232
|
-
path: "$orgData",
|
|
9233
|
-
preserveNullAndEmptyArrays: true
|
|
9234
|
-
}
|
|
9235
|
-
},
|
|
9236
9220
|
{
|
|
9237
9221
|
$lookup: {
|
|
9238
9222
|
from: "organizations",
|
|
9239
9223
|
localField: "org",
|
|
9240
9224
|
foreignField: "_id",
|
|
9241
|
-
as: "
|
|
9225
|
+
as: "org"
|
|
9242
9226
|
}
|
|
9243
9227
|
},
|
|
9244
9228
|
{
|
|
9245
9229
|
$unwind: {
|
|
9246
|
-
path: "$
|
|
9230
|
+
path: "$org",
|
|
9247
9231
|
preserveNullAndEmptyArrays: true
|
|
9248
9232
|
}
|
|
9249
9233
|
},
|
|
9250
9234
|
{
|
|
9251
9235
|
$group: {
|
|
9252
|
-
_id: "$org",
|
|
9253
|
-
text: { $first: "$
|
|
9254
|
-
value: { $first: "$org" },
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
},
|
|
9259
|
-
|
|
9260
|
-
$first: "$orgData.onboardingCompleted"
|
|
9261
|
-
},
|
|
9262
|
-
onboardingCompletedAt: {
|
|
9263
|
-
$first: "$orgData.onboardingCompletedAt"
|
|
9264
|
-
}
|
|
9236
|
+
_id: "$org._id",
|
|
9237
|
+
text: { $first: "$org.name" },
|
|
9238
|
+
value: { $first: "$org._id" },
|
|
9239
|
+
type: { $first: "$org.type" },
|
|
9240
|
+
defaultSite: { $first: "$org.defaultSite" },
|
|
9241
|
+
onboardingRequired: { $first: "$org.onboardingRequired" },
|
|
9242
|
+
onboardingCompleted: { $first: "$org.onboardingCompleted" },
|
|
9243
|
+
onboardingCompletedAt: { $first: "$org.onboardingCompletedAt" }
|
|
9265
9244
|
}
|
|
9266
9245
|
},
|
|
9246
|
+
{ $sort: { _id: -1 } },
|
|
9247
|
+
{ $skip: page * limit },
|
|
9248
|
+
{ $limit: limit },
|
|
9267
9249
|
{
|
|
9268
9250
|
$project: {
|
|
9269
9251
|
_id: 0,
|
|
9270
9252
|
text: 1,
|
|
9271
9253
|
value: 1,
|
|
9254
|
+
type: 1,
|
|
9272
9255
|
defaultSite: 1,
|
|
9273
9256
|
onboardingRequired: 1,
|
|
9274
9257
|
onboardingCompleted: 1,
|
|
@@ -11159,21 +11142,10 @@ function useSiteRepo() {
|
|
|
11159
11142
|
throw new BadRequestError18("Invalid site ID format.");
|
|
11160
11143
|
}
|
|
11161
11144
|
try {
|
|
11162
|
-
const cacheKey = makeCacheKey9(namespace_collection, { _id });
|
|
11163
|
-
const cachedData = await getCache(cacheKey);
|
|
11164
|
-
if (cachedData) {
|
|
11165
|
-
logger12.info(`Cache hit for key: ${cacheKey}`);
|
|
11166
|
-
return cachedData;
|
|
11167
|
-
}
|
|
11168
11145
|
const data = await collection.aggregate([{ $match: { _id, status: { $ne: "deleted" } } }]).toArray();
|
|
11169
11146
|
if (!data || !data.length) {
|
|
11170
11147
|
throw new NotFoundError8("Site not found.");
|
|
11171
11148
|
}
|
|
11172
|
-
setCache(cacheKey, data[0], 15 * 60).then(() => {
|
|
11173
|
-
logger12.info(`Cache set for key: ${cacheKey}`);
|
|
11174
|
-
}).catch((err) => {
|
|
11175
|
-
logger12.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
11176
|
-
});
|
|
11177
11149
|
return data[0];
|
|
11178
11150
|
} catch (error) {
|
|
11179
11151
|
throw error;
|
|
@@ -54671,7 +54643,7 @@ function useIncidentReportRepo() {
|
|
|
54671
54643
|
}
|
|
54672
54644
|
|
|
54673
54645
|
// src/services/incident-report.service.ts
|
|
54674
|
-
import
|
|
54646
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
54675
54647
|
function useIncidentReportService() {
|
|
54676
54648
|
const {
|
|
54677
54649
|
add: _add,
|
|
@@ -54764,20 +54736,12 @@ function useIncidentReportService() {
|
|
|
54764
54736
|
}
|
|
54765
54737
|
}
|
|
54766
54738
|
async function createIncidentSummary(value) {
|
|
54767
|
-
const session = useAtlas91.getClient()?.startSession();
|
|
54768
|
-
session?.startTransaction();
|
|
54769
54739
|
const sample = `On August 4, 2024, an incident report labeled IR10 was submitted following an earthquake that occurred between 10:00 AM and 10:30 AM at a designated test site. The report indicated that the incident was reported by a complainant named Maryam, who provided her contact information as +65-123456789. The recipient of the complaint was Rash, whose contact number is +65-987654321. The description of the complaint detailed a historical context regarding the origins of Lorem Ipsum text, an academic piece that has been referenced throughout centuries.
|
|
54770
|
-
|
|
54771
|
-
|
|
54772
|
-
|
|
54773
|
-
'
|
|
54774
|
-
|
|
54775
|
-
'
|
|
54776
|
-
' +
|
|
54777
|
-
"No authorities were called, and the incident's resolution was marked at 11:00 AM, with actions taken by Ola, the shift in charge during the incident. The management was informed of the incident at 10:08 AM, and security implications were considered but not detailed. The report remains pending and does not mention a reason for rejection or approval status. The incident is documented with attached photographs. The overall status of the report remains pending as of the latest update.`;
|
|
54778
|
-
const openai = new OpenAI({
|
|
54779
|
-
apiKey: OPEN_AI_API_KEY
|
|
54780
|
-
});
|
|
54740
|
+
|
|
54741
|
+
The report highlighted that no individuals were directly affected or injured in the incident. However, there was damage to property associated with the incident, particularly mentioning an individual named Ruzzy, with contact +65-34567777889, who experienced property damage. The report states that this damage was also elaborated upon with historical context, reiterating similar pieces of information on the classical literature that influenced the Lorem Ipsum narrative.
|
|
54742
|
+
|
|
54743
|
+
No authorities were called, and the incident's resolution was marked at 11:00 AM, with actions taken by Ola, the shift in charge during the incident. The management was informed of the incident at 10:08 AM, and security implications were considered but not detailed. The report remains pending and does not mention a reason for rejection or approval status. The incident is documented with attached photographs. The overall status of the report remains pending as of the latest update.`;
|
|
54744
|
+
const anthropic = new Anthropic({ apiKey: ANTHROPIC_API_KEY });
|
|
54781
54745
|
try {
|
|
54782
54746
|
if (value?.incidentInformation?.siteInfo?.site) {
|
|
54783
54747
|
const site = await _getSiteById(
|
|
@@ -54794,19 +54758,15 @@ function useIncidentReportService() {
|
|
|
54794
54758
|
value.organization = org.name;
|
|
54795
54759
|
}
|
|
54796
54760
|
}
|
|
54797
|
-
const
|
|
54798
|
-
model: "
|
|
54799
|
-
|
|
54800
|
-
|
|
54801
|
-
|
|
54802
|
-
content: `You write a comprehensive summary for incident reports, exclude the attachment, and make it in essay format, and don't add any explaination to how the summary is about, and don't use the mongodb id number for the summary and Must include the following answers to What happened ?, Where did it happened ?, Who was involved ?, How did it happened?, Why did it happened?, Is there any security implications due to incident ?, just keep it plain since we will save it directly into the database. here's a sample: ${sample}`
|
|
54803
|
-
},
|
|
54804
|
-
{ role: "user", content: JSON.stringify(value) }
|
|
54805
|
-
]
|
|
54761
|
+
const response = await anthropic.messages.create({
|
|
54762
|
+
model: "claude-sonnet-4-6",
|
|
54763
|
+
max_tokens: 1024,
|
|
54764
|
+
system: `You write a comprehensive summary for incident reports, exclude the attachment, and make it in essay format, and don't add any explaination to how the summary is about, and don't use the mongodb id number for the summary and Must include the following answers to What happened ?, Where did it happened ?, Who was involved ?, How did it happened?, Why did it happened?, Is there any security implications due to incident ?, just keep it plain since we will save it directly into the database. here's a sample: ${sample}`,
|
|
54765
|
+
messages: [{ role: "user", content: JSON.stringify(value) }]
|
|
54806
54766
|
});
|
|
54807
|
-
const
|
|
54808
|
-
if (
|
|
54809
|
-
return
|
|
54767
|
+
const briefSummary = response.content[0].type === "text" ? response.content[0].text : null;
|
|
54768
|
+
if (briefSummary) {
|
|
54769
|
+
return briefSummary;
|
|
54810
54770
|
} else {
|
|
54811
54771
|
return "Failed to generate a summary.";
|
|
54812
54772
|
}
|