@handong66/evidoc-review-log 0.1.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/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +51 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DriftFinding } from "@handong66/evidoc-core";
|
|
2
|
+
export type ReviewDecision = "accepted" | "false_positive" | "deferred" | "fixed";
|
|
3
|
+
export interface ReviewLogEntry {
|
|
4
|
+
findingId: string;
|
|
5
|
+
decision: ReviewDecision;
|
|
6
|
+
reviewer: string;
|
|
7
|
+
reviewedAt: string;
|
|
8
|
+
expiresAt?: string;
|
|
9
|
+
note?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function serializeReviewLogEntry(entry: ReviewLogEntry): string;
|
|
12
|
+
export declare function parseReviewLog(text: string): ReviewLogEntry[];
|
|
13
|
+
export declare function appendReviewLogEntry(text: string, entry: ReviewLogEntry): string;
|
|
14
|
+
export declare function isFindingReviewed(finding: DriftFinding, entries: ReviewLogEntry[], now?: Date): boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function serializeReviewLogEntry(entry) {
|
|
2
|
+
return JSON.stringify(entry);
|
|
3
|
+
}
|
|
4
|
+
export function parseReviewLog(text) {
|
|
5
|
+
const entries = [];
|
|
6
|
+
for (const line of text.split(/\r?\n/)) {
|
|
7
|
+
const trimmed = line.trim();
|
|
8
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
9
|
+
continue;
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(trimmed);
|
|
12
|
+
if (typeof parsed.findingId === "string" &&
|
|
13
|
+
isReviewDecision(parsed.decision) &&
|
|
14
|
+
typeof parsed.reviewer === "string" &&
|
|
15
|
+
typeof parsed.reviewedAt === "string") {
|
|
16
|
+
entries.push({
|
|
17
|
+
findingId: parsed.findingId,
|
|
18
|
+
decision: parsed.decision,
|
|
19
|
+
reviewer: parsed.reviewer,
|
|
20
|
+
reviewedAt: parsed.reviewedAt,
|
|
21
|
+
expiresAt: typeof parsed.expiresAt === "string" ? parsed.expiresAt : undefined,
|
|
22
|
+
note: typeof parsed.note === "string" ? parsed.note : undefined
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return entries;
|
|
31
|
+
}
|
|
32
|
+
export function appendReviewLogEntry(text, entry) {
|
|
33
|
+
const prefix = text.endsWith("\n") || text.length === 0 ? text : `${text}\n`;
|
|
34
|
+
return `${prefix}${serializeReviewLogEntry(entry)}\n`;
|
|
35
|
+
}
|
|
36
|
+
export function isFindingReviewed(finding, entries, now = new Date()) {
|
|
37
|
+
return entries.some((entry) => {
|
|
38
|
+
if (entry.findingId !== finding.id)
|
|
39
|
+
return false;
|
|
40
|
+
if (entry.decision !== "accepted" && entry.decision !== "false_positive" && entry.decision !== "fixed") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (!entry.expiresAt)
|
|
44
|
+
return true;
|
|
45
|
+
return Date.parse(entry.expiresAt) >= now.getTime();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function isReviewDecision(value) {
|
|
49
|
+
return value === "accepted" || value === "false_positive" || value === "deferred" || value === "fixed";
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,uBAAuB,CAAC,KAAqB;IAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,KAAK,MAAM,IAAI,IAAI,IAAI,C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AAG,MAAM,GAAG,uBAAuB,CAAC,KAAK,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAAqB,EACrB,OAAyB,EACzB,GAAG,GAAG,IAAI,IAAI,EAAE;IAEhB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,IAAI,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE;YAAE,OAAO,KAAK,CAAC;QACjD,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,QAAQ,KAAK,gBAAgB,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACvG,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,gBAAgB,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,OAAO,CAAC;AACzG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@handong66/evidoc-review-log",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"prepublishOnly": "node ../../scripts/ensure-built-package.mjs"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"types": "./dist/src/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/src"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@handong66/evidoc-core": "0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/handong66/Evidoc.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/handong66/Evidoc/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/handong66/Evidoc#readme"
|
|
27
|
+
}
|