@corva/chat-core 0.1.3 → 0.1.5
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 +3 -1
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ interface AskCorvaData {
|
|
|
78
78
|
isTruncated?: boolean;
|
|
79
79
|
assetId?: number;
|
|
80
80
|
agentName?: string;
|
|
81
|
+
note?: string;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
type ChatAssetType = 'rig' | 'frac_fleet' | 'intervention_unit';
|
|
@@ -165,6 +166,7 @@ interface AskCorvaWirePayload {
|
|
|
165
166
|
trunc?: boolean;
|
|
166
167
|
assetId?: number;
|
|
167
168
|
agentName?: string;
|
|
169
|
+
n?: string;
|
|
168
170
|
}
|
|
169
171
|
/**
|
|
170
172
|
* One attachment on the wire. Keys are single letters like every other field in these payloads:
|
|
@@ -764,7 +766,7 @@ interface ParsedCorvaMessage {
|
|
|
764
766
|
/**
|
|
765
767
|
* Builds the wire-format content string for an AskCorva response.
|
|
766
768
|
*/
|
|
767
|
-
declare function buildAskCorvaMessageContent(requestId: string, answer: string, answerRef?: string, isTruncated?: boolean, assetId?: number, agentName?: string, companyId?: number): string;
|
|
769
|
+
declare function buildAskCorvaMessageContent(requestId: string, answer: string, answerRef?: string, isTruncated?: boolean, assetId?: number, agentName?: string, companyId?: number, note?: string): string;
|
|
768
770
|
/**
|
|
769
771
|
* Builds the wire-format content string for a forwarded message.
|
|
770
772
|
*/
|
package/dist/index.js
CHANGED
|
@@ -419,7 +419,8 @@ function mapAskCorvaPayload(d) {
|
|
|
419
419
|
companyId: d.cId,
|
|
420
420
|
isTruncated: d.trunc,
|
|
421
421
|
assetId: d.assetId,
|
|
422
|
-
agentName: d.agentName
|
|
422
|
+
agentName: d.agentName,
|
|
423
|
+
note: d.n || void 0
|
|
423
424
|
};
|
|
424
425
|
}
|
|
425
426
|
function mapForwardPayload(d) {
|
|
@@ -450,7 +451,7 @@ function mapAppCommentPayload(d) {
|
|
|
450
451
|
isTruncated: d.trunc
|
|
451
452
|
};
|
|
452
453
|
}
|
|
453
|
-
function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated, assetId, agentName, companyId) {
|
|
454
|
+
function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated, assetId, agentName, companyId, note) {
|
|
454
455
|
const payload = {
|
|
455
456
|
id: requestId,
|
|
456
457
|
a: answerRef ? "" : answer,
|
|
@@ -458,7 +459,8 @@ function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated,
|
|
|
458
459
|
...answerRef && companyId && { cId: companyId },
|
|
459
460
|
...isTruncated && { trunc: true },
|
|
460
461
|
...assetId && { assetId },
|
|
461
|
-
...agentName && { agentName }
|
|
462
|
+
...agentName && { agentName },
|
|
463
|
+
...note?.trim() && { n: note.trim() }
|
|
462
464
|
};
|
|
463
465
|
return `${CORVA_SYS_PREFIX}${JSON.stringify({ t: CORVA_MESSAGE_TYPES.ASK_CORVA, v: 1, d: payload })}`;
|
|
464
466
|
}
|
|
@@ -563,7 +565,7 @@ function enrichWithCorvaData(message) {
|
|
|
563
565
|
if (!parsed) return message;
|
|
564
566
|
return {
|
|
565
567
|
...message,
|
|
566
|
-
msg: parsed.forwardedFrom?.note || "",
|
|
568
|
+
msg: parsed.forwardedFrom?.note || parsed.askCorva?.note || "",
|
|
567
569
|
t: parsed.messageType,
|
|
568
570
|
alert: parsed.alert,
|
|
569
571
|
feedItem: parsed.feedItem,
|
|
@@ -2554,7 +2556,10 @@ function wasRecentlyActive(userId, thresholdDays = DEFAULT_ACTIVITY_THRESHOLD_DA
|
|
|
2554
2556
|
try {
|
|
2555
2557
|
const timestamp = getChatStorage().getItem(getActivityKey(userId));
|
|
2556
2558
|
if (!timestamp) return false;
|
|
2557
|
-
|
|
2559
|
+
const now = Date.now();
|
|
2560
|
+
const then = Number(timestamp);
|
|
2561
|
+
const dstShift = (new Date(now).getTimezoneOffset() - new Date(then).getTimezoneOffset()) * 6e4;
|
|
2562
|
+
return now - then - dstShift < thresholdDays * DAY_MS;
|
|
2558
2563
|
} catch {
|
|
2559
2564
|
return false;
|
|
2560
2565
|
}
|
|
@@ -2740,7 +2745,7 @@ var removeMessageFromList = (messages, messageId) => {
|
|
|
2740
2745
|
};
|
|
2741
2746
|
|
|
2742
2747
|
// src/store/utils/messageHelpers.ts
|
|
2743
|
-
var isUploadFile = (file) => !!file && typeof file.name === "string";
|
|
2748
|
+
var isUploadFile = (file) => !!file && typeof file.name === "string" && typeof file.size === "number" && typeof file.type === "string";
|
|
2744
2749
|
async function uploadAndSend(api, data, nonce) {
|
|
2745
2750
|
if (data.uploadedFileIds?.length) {
|
|
2746
2751
|
const response2 = await api.sendMessage(
|