@ordinatio/entities 1.0.1 → 1.0.4
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/errors.ts
|
|
2
|
+
import { createModuleError } from "@ordinatio/errors";
|
|
2
3
|
var KNOWLEDGE_ERRORS = {
|
|
3
4
|
KNOWLEDGE_300: {
|
|
4
5
|
code: "KNOWLEDGE_300",
|
|
@@ -575,35 +576,40 @@ var AGENTKNOW_ERRORS = {
|
|
|
575
576
|
]
|
|
576
577
|
}
|
|
577
578
|
};
|
|
578
|
-
function
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
585
|
-
module: "KNOWLEDGE",
|
|
586
|
-
description: def.description,
|
|
587
|
-
severity: def.severity,
|
|
588
|
-
recoverable: def.recoverable,
|
|
589
|
-
diagnosis: [...def.diagnosis],
|
|
590
|
-
context: context || {}
|
|
579
|
+
function toSharedErrorRegistry(registry) {
|
|
580
|
+
const severityMap = {
|
|
581
|
+
low: "info",
|
|
582
|
+
medium: "warning",
|
|
583
|
+
high: "error",
|
|
584
|
+
critical: "critical"
|
|
591
585
|
};
|
|
586
|
+
const result = {};
|
|
587
|
+
for (const [code, def] of Object.entries(registry)) {
|
|
588
|
+
result[code] = {
|
|
589
|
+
code: def.code,
|
|
590
|
+
description: def.description,
|
|
591
|
+
severity: severityMap[def.severity],
|
|
592
|
+
recoverable: def.recoverable,
|
|
593
|
+
diagnosis: def.diagnosis.map((d) => `${d.step}: ${d.check}`),
|
|
594
|
+
file: def.file,
|
|
595
|
+
function: def.function
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
return result;
|
|
592
599
|
}
|
|
600
|
+
var _knowledgeError = null;
|
|
601
|
+
function knowledgeError(code, context) {
|
|
602
|
+
if (!_knowledgeError) {
|
|
603
|
+
_knowledgeError = createModuleError("KNOWLEDGE", toSharedErrorRegistry(KNOWLEDGE_ERRORS));
|
|
604
|
+
}
|
|
605
|
+
return _knowledgeError(code, context);
|
|
606
|
+
}
|
|
607
|
+
var _agentKnowledgeError = null;
|
|
593
608
|
function agentKnowledgeError(code, context) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
ref: `${entry.code}-${ts}`,
|
|
599
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
600
|
-
module: "AGENT_KNOWLEDGE",
|
|
601
|
-
description: entry.description,
|
|
602
|
-
severity: entry.severity,
|
|
603
|
-
recoverable: entry.recoverable,
|
|
604
|
-
diagnosis: [...entry.diagnosis],
|
|
605
|
-
context: context || {}
|
|
606
|
-
};
|
|
609
|
+
if (!_agentKnowledgeError) {
|
|
610
|
+
_agentKnowledgeError = createModuleError("AGENT_KNOWLEDGE", AGENTKNOW_ERRORS);
|
|
611
|
+
}
|
|
612
|
+
return _agentKnowledgeError(code, context);
|
|
607
613
|
}
|
|
608
614
|
var ContactNotFoundError = class extends Error {
|
|
609
615
|
constructor(id) {
|