narrarium-engine 0.1.24 → 0.1.25
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/README.md +9 -1
- package/dist/autopilot/campaign.d.ts +9 -2
- package/dist/autopilot/campaign.d.ts.map +1 -1
- package/dist/autopilot/campaign.js +84 -14
- package/dist/autopilot/campaign.js.map +1 -1
- package/dist/autopilot/estimate.d.ts +6 -1
- package/dist/autopilot/estimate.d.ts.map +1 -1
- package/dist/autopilot/estimate.js +24 -10
- package/dist/autopilot/estimate.js.map +1 -1
- package/dist/autopilot/frozen.d.ts +2 -0
- package/dist/autopilot/frozen.d.ts.map +1 -1
- package/dist/autopilot/frozen.js.map +1 -1
- package/dist/autopilot/planner.d.ts +1 -0
- package/dist/autopilot/planner.d.ts.map +1 -1
- package/dist/autopilot/planner.js +133 -12
- package/dist/autopilot/planner.js.map +1 -1
- package/dist/autopilot/review-policy.d.ts +25 -5
- package/dist/autopilot/review-policy.d.ts.map +1 -1
- package/dist/autopilot/review-policy.js +84 -2
- package/dist/autopilot/review-policy.js.map +1 -1
- package/dist/autopilot/review-readers.d.ts +69 -0
- package/dist/autopilot/review-readers.d.ts.map +1 -0
- package/dist/autopilot/review-readers.js +79 -0
- package/dist/autopilot/review-readers.js.map +1 -0
- package/dist/autopilot/state.d.ts +11 -0
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js +60 -5
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/tasks.d.ts.map +1 -1
- package/dist/autopilot/tasks.js +63 -5
- package/dist/autopilot/tasks.js.map +1 -1
- package/dist/autopilot/types.d.ts +76 -8
- package/dist/autopilot/types.d.ts.map +1 -1
- package/dist/autopilot/types.js +2 -0
- package/dist/autopilot/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/client.js +9 -2
- package/dist/server/client.js.map +1 -1
- package/dist/server/protocol.d.ts +18 -0
- package/dist/server/protocol.d.ts.map +1 -1
- package/dist/server/protocol.js +24 -0
- package/dist/server/protocol.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ReaderTargets } from "./review-policy.js";
|
|
2
|
+
import type { ChapterRound } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* What the readers say of a chapter, compared with the targets the author set for them (`ReviewPolicy.readersTarget`, `readerTargets`, `readersExcluded`): the average of
|
|
5
|
+
* the readers that count, what is under its target, and whether a vote the chapter has is still the vote of its text. Pure: the review (`planner.ts`, `tasks.ts`) and the
|
|
6
|
+
* review of the book (`campaign.ts`) read the same rules from here, and a host that shows the votes reads them too.
|
|
7
|
+
*/
|
|
8
|
+
/** The vote of one reader. */
|
|
9
|
+
export interface ReaderVote {
|
|
10
|
+
slug: string;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
/** The average of the votes of the readers that count, to a tenth; `null` when none does. */
|
|
14
|
+
export declare function countingAverage(votes: readonly ReaderVote[], excluded: ReadonlySet<string>): number | null;
|
|
15
|
+
/** What stands between a chapter and a target of the readers: their average, or one reader. */
|
|
16
|
+
export type ReaderBlocker = {
|
|
17
|
+
subject: "average";
|
|
18
|
+
vote: number;
|
|
19
|
+
target: number;
|
|
20
|
+
} | {
|
|
21
|
+
subject: "reader";
|
|
22
|
+
slug: string;
|
|
23
|
+
vote: number;
|
|
24
|
+
target: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* How the votes of the readers stand against their targets: the average of those that count, what is under its target (the average first, then the readers in the order
|
|
28
|
+
* they voted), and how far it all is from the targets in tenths of a vote (the sum of what each lacks): a round of corrections got closer when it is smaller.
|
|
29
|
+
*/
|
|
30
|
+
export interface ReaderStanding {
|
|
31
|
+
average: number | null;
|
|
32
|
+
blockers: ReaderBlocker[];
|
|
33
|
+
shortfall: number;
|
|
34
|
+
}
|
|
35
|
+
/** Judge the votes of the readers by their targets. A reader that does not count has no say, whatever its vote or its target; with no vote there is nothing under a target. */
|
|
36
|
+
export declare function readerStanding(votes: readonly ReaderVote[], targets: ReaderTargets): ReaderStanding;
|
|
37
|
+
/** What the readers last said of a chapter, from the rounds of its review: the entry, the votes it has, and whether they are of the text as it is now. */
|
|
38
|
+
export interface ChapterReading {
|
|
39
|
+
/** The vote of each reader, when the round recorded them (`ChapterRound.readerVotes`); an older round has the average alone. */
|
|
40
|
+
votes?: ReaderVote[];
|
|
41
|
+
/** The average the round recorded: of the readers that counted when it was made; `null` when none did. */
|
|
42
|
+
average: number | null;
|
|
43
|
+
/** The round of the review it belongs to, when the round says it. */
|
|
44
|
+
round?: number;
|
|
45
|
+
reading?: ChapterRound["reading"];
|
|
46
|
+
/** Nothing was corrected after they read: this is the vote of the text as it is. */
|
|
47
|
+
current: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The last reading of a chapter among its rounds (`null` when the readers never read it). It is the vote of the text as it is while it is the last entry and no
|
|
51
|
+
* correction followed it: a reading of its own is the last thing that happened, and the round of the director that read it has no fix accepted (`accepted`); any
|
|
52
|
+
* later round, or fixes after it, make it a vote of the text before.
|
|
53
|
+
*/
|
|
54
|
+
export declare function chapterReading(rounds: readonly ChapterRound[] | undefined): ChapterReading | null;
|
|
55
|
+
/**
|
|
56
|
+
* Where a chapter stands against the readers' targets: the standing, when there is a vote of the text as it is that the targets can be read from (`null` otherwise), and
|
|
57
|
+
* whether the readers must read it for that (`needsReading`: they never did, what they said is of the text before the corrections, or a target is for one reader, or
|
|
58
|
+
* some readers do not count, and the round only has the average of them all).
|
|
59
|
+
*/
|
|
60
|
+
export declare function chapterStanding(rounds: readonly ChapterRound[] | undefined, targets: ReaderTargets): {
|
|
61
|
+
standing: ReaderStanding | null;
|
|
62
|
+
reading: ChapterReading | null;
|
|
63
|
+
needsReading: boolean;
|
|
64
|
+
};
|
|
65
|
+
/** What stands in the way, in words: «the readers' average 6.4/10 is under 7.5/10», «Anna's 5/10 is under the 8/10 asked of her». `names` says a reader by its slug. */
|
|
66
|
+
export declare function blockerText(blocker: ReaderBlocker, language: string, names?: (slug: string) => string): string;
|
|
67
|
+
/** All that stands in the way in one sentence («the readers' average 6.4/10 is under 7.5/10; Anna gives 5/10, under the 8/10 asked of this reader»). */
|
|
68
|
+
export declare function blockersText(blockers: readonly ReaderBlocker[], language: string, names?: (slug: string) => string): string;
|
|
69
|
+
//# sourceMappingURL=review-readers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-readers.d.ts","sourceRoot":"","sources":["../../src/autopilot/review-readers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAID,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAG1G;AAED,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErJ;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACv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"../util/text.js";
|
|
2
|
+
const tenth = (value) => Math.round(value * 10) / 10;
|
|
3
|
+
/** The average of the votes of the readers that count, to a tenth; `null` when none does. */
|
|
4
|
+
export function countingAverage(votes, excluded) {
|
|
5
|
+
const counting = votes.filter((vote) => !excluded.has(vote.slug));
|
|
6
|
+
return counting.length ? tenth(counting.reduce((sum, vote) => sum + vote.score, 0) / counting.length) : null;
|
|
7
|
+
}
|
|
8
|
+
/** Judge the votes of the readers by their targets. A reader that does not count has no say, whatever its vote or its target; with no vote there is nothing under a target. */
|
|
9
|
+
export function readerStanding(votes, targets) {
|
|
10
|
+
const average = countingAverage(votes, targets.excluded);
|
|
11
|
+
const blockers = [];
|
|
12
|
+
if (targets.average !== undefined && average !== null && average < targets.average)
|
|
13
|
+
blockers.push({ subject: "average", vote: average, target: targets.average });
|
|
14
|
+
for (const vote of votes) {
|
|
15
|
+
const target = targets.each[vote.slug];
|
|
16
|
+
const score = tenth(vote.score);
|
|
17
|
+
if (target !== undefined && !targets.excluded.has(vote.slug) && score < target)
|
|
18
|
+
blockers.push({ subject: "reader", slug: vote.slug, vote: score, target });
|
|
19
|
+
}
|
|
20
|
+
return { average, blockers, shortfall: blockers.reduce((sum, blocker) => sum + Math.round((blocker.target - blocker.vote) * 10), 0) };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The last reading of a chapter among its rounds (`null` when the readers never read it). It is the vote of the text as it is while it is the last entry and no
|
|
24
|
+
* correction followed it: a reading of its own is the last thing that happened, and the round of the director that read it has no fix accepted (`accepted`); any
|
|
25
|
+
* later round, or fixes after it, make it a vote of the text before.
|
|
26
|
+
*/
|
|
27
|
+
export function chapterReading(rounds) {
|
|
28
|
+
if (!rounds?.length)
|
|
29
|
+
return null;
|
|
30
|
+
for (let index = rounds.length - 1; index >= 0; index -= 1) {
|
|
31
|
+
const entry = rounds[index];
|
|
32
|
+
if (entry?.readers === undefined && !entry?.readerVotes)
|
|
33
|
+
continue;
|
|
34
|
+
const votes = entry.readerVotes ? Object.entries(entry.readerVotes).map(([slug, score]) => ({ slug, score })) : undefined;
|
|
35
|
+
return {
|
|
36
|
+
...(votes ? { votes } : {}),
|
|
37
|
+
average: entry.readers ?? null,
|
|
38
|
+
...(entry.round !== undefined ? { round: entry.round } : {}),
|
|
39
|
+
...(entry.reading ? { reading: entry.reading } : {}),
|
|
40
|
+
current: index === rounds.length - 1 && (entry.reading !== undefined || !((entry.accepted ?? 0) > 0)),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Where a chapter stands against the readers' targets: the standing, when there is a vote of the text as it is that the targets can be read from (`null` otherwise), and
|
|
47
|
+
* whether the readers must read it for that (`needsReading`: they never did, what they said is of the text before the corrections, or a target is for one reader, or
|
|
48
|
+
* some readers do not count, and the round only has the average of them all).
|
|
49
|
+
*/
|
|
50
|
+
export function chapterStanding(rounds, targets) {
|
|
51
|
+
const reading = chapterReading(rounds);
|
|
52
|
+
if (!reading || !reading.current)
|
|
53
|
+
return { standing: null, reading, needsReading: true };
|
|
54
|
+
if (reading.votes)
|
|
55
|
+
return { standing: readerStanding(reading.votes, targets), reading, needsReading: false };
|
|
56
|
+
const detailed = Object.keys(targets.each).length > 0 || targets.excluded.size > 0;
|
|
57
|
+
if (detailed || reading.average === null)
|
|
58
|
+
return { standing: null, reading, needsReading: true };
|
|
59
|
+
return { standing: readerStanding([{ slug: "", score: reading.average }], { ...targets, each: {}, excluded: new Set() }), reading, needsReading: false };
|
|
60
|
+
}
|
|
61
|
+
const vote = (value) => `${value}/10`;
|
|
62
|
+
/** What stands in the way, in words: «the readers' average 6.4/10 is under 7.5/10», «Anna's 5/10 is under the 8/10 asked of her». `names` says a reader by its slug. */
|
|
63
|
+
export function blockerText(blocker, language, names = (slug) => slug) {
|
|
64
|
+
const italian = isItalian(language);
|
|
65
|
+
if (blocker.subject === "average") {
|
|
66
|
+
return italian
|
|
67
|
+
? `la media dei lettori ${vote(blocker.vote)} è sotto ${vote(blocker.target)}`
|
|
68
|
+
: `the readers' average ${vote(blocker.vote)} is under ${vote(blocker.target)}`;
|
|
69
|
+
}
|
|
70
|
+
const name = names(blocker.slug);
|
|
71
|
+
return italian
|
|
72
|
+
? `${name} dà ${vote(blocker.vote)}, sotto i ${vote(blocker.target)} chiesti a questo lettore`
|
|
73
|
+
: `${name} gives ${vote(blocker.vote)}, under the ${vote(blocker.target)} asked of this reader`;
|
|
74
|
+
}
|
|
75
|
+
/** All that stands in the way in one sentence («the readers' average 6.4/10 is under 7.5/10; Anna gives 5/10, under the 8/10 asked of this reader»). */
|
|
76
|
+
export function blockersText(blockers, language, names) {
|
|
77
|
+
return blockers.map((blocker) => blockerText(blocker, language, names)).join("; ");
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=review-readers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-readers.js","sourceRoot":"","sources":["../../src/autopilot/review-readers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgB5C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;AAErE,6FAA6F;AAC7F,MAAM,UAAU,eAAe,CAAC,KAA4B,EAAE,QAA6B;IACzF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,C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M,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,OAAO;YACZ,CAAC,CAAC,wBAAwB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC9E,CAAC,CAAC,wBAAwB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACpF,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,OAAO;QACZ,CAAC,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,2BAA2B;QAC9F,CAAC,CAAC,GAAG,IAAI,UAAU,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;AACpG,CAAC;AAED,wJAAwJ;AACxJ,MAAM,UAAU,YAAY,CAAC,QAAkC,EAAE,QAAgB,EAAE,KAAgC;IACjH,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -91,6 +91,17 @@ export declare function closedRound(input: {
|
|
|
91
91
|
verdict?: ChapterRound["verdict"];
|
|
92
92
|
accepted: number;
|
|
93
93
|
rejected: number;
|
|
94
|
+
reading?: ReadingRecord;
|
|
95
|
+
}): ChapterRound;
|
|
96
|
+
/** What the readers said in a round, for a policy with targets for them: the votes by reader, the readers that do not count, and the round. */
|
|
97
|
+
export interface ReadingRecord {
|
|
98
|
+
votes: Record<string, number>;
|
|
99
|
+
excluded: ReadonlySet<string>;
|
|
100
|
+
round: number;
|
|
101
|
+
}
|
|
102
|
+
/** The record of the readers reading a chapter on their own (`ChapterRound.reading`): the average of those that count, the vote of each, and the round it follows. */
|
|
103
|
+
export declare function readingRound(input: ReadingRecord & {
|
|
104
|
+
reading: "end" | "check";
|
|
94
105
|
}): ChapterRound;
|
|
95
106
|
/** Add a round to the history of a chapter, which keeps at most `MAX_CHAPTER_ROUNDS`: the oldest leave first. */
|
|
96
107
|
export declare function recordChapterRound(chapter: PlannedChapter, round: ChapterRound): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/autopilot/state.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EAItB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EAGpB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EAGrB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EAIrB,kBAAkB,EAElB,YAAY,EAUZ,cAAc,EAEd,gBAAgB,EAUhB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,yHAAyH;AACzH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,yGAAyG;AACzG,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,+BAA+B,MAAM,CAAC;AACnD,wHAAwH;AACxH,eAAO,MAAM,0BAA0B,MAAM,C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AAM,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACvC,0FAA0F;IAC1F,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,qGAAqG;IACrG,KAAK,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAClC,oIAAoI;IACpI,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAQD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,uBAA4B,GAAG,qBAAqB,CAwB3H;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,kBAAkB,EAAE,CAExE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C"}
|
package/dist/autopilot/state.js
CHANGED
|
@@ -4,7 +4,7 @@ import { asArray, asBoolean, asInteger, asNumber, asOneOf, asRecord, asString, a
|
|
|
4
4
|
import { clipText, countWords } from "../util/text.js";
|
|
5
5
|
import { normalizeErrorDetail, normalizeErrorKind } from "./errors.js";
|
|
6
6
|
import { normalizeReviewPolicy } from "./review-policy.js";
|
|
7
|
-
import { AUTOPILOT_PUBLISH_MODES, DESIGN_DEFAULT_ROUNDS, FROZEN_CHANGE_ACTIONS, FROZEN_EDITS_MODES, LAST_ERROR_CODES, LONG_RETRY_MAX_CYCLES, LONG_RETRY_MAX_MINUTES, REVIEW_MAX_CAMPAIGN_ROUNDS, REVIEW_MAX_ROUNDS, REVISION_CHAPTER_MODES, REVISION_CHAPTER_STATUSES, REVISION_REASONS } from "./types.js";
|
|
7
|
+
import { AUTOPILOT_PUBLISH_MODES, DESIGN_DEFAULT_ROUNDS, FROZEN_CHANGE_ACTIONS, FROZEN_EDITS_MODES, LAST_ERROR_CODES, LONG_RETRY_MAX_CYCLES, LONG_RETRY_MAX_MINUTES, REVIEW_MAX_CAMPAIGN_ROUNDS, REVIEW_MAX_READER_ENTRIES, REVIEW_MAX_ROUNDS, REVISION_CHAPTER_MODES, REVISION_CHAPTER_STATUSES, REVISION_REASONS } from "./types.js";
|
|
8
8
|
export const MAX_ACTIVITIES = 200;
|
|
9
9
|
export const MAX_INTERVENTIONS = 100;
|
|
10
10
|
export const MAX_DIRECTOR_NOTES = 12;
|
|
@@ -241,21 +241,39 @@ function readMoment(value) {
|
|
|
241
241
|
function readActivityId(value) {
|
|
242
242
|
return typeof value === "string" && /^[A-Za-z0-9_.:-]{1,120}$/.test(value) ? value : undefined;
|
|
243
243
|
}
|
|
244
|
-
/**
|
|
244
|
+
/** The vote of each reader of a round, by slug: the valid votes of the readers it names, at most as many as a policy keeps; `undefined` when there is none. */
|
|
245
|
+
function readReaderVotes(value) {
|
|
246
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
247
|
+
return undefined;
|
|
248
|
+
const votes = {};
|
|
249
|
+
for (const [slug, entry] of Object.entries(value)) {
|
|
250
|
+
const vote = readVote(entry);
|
|
251
|
+
if (slug.trim() && slug.length <= 120 && vote !== undefined && Object.keys(votes).length < REVIEW_MAX_READER_ENTRIES)
|
|
252
|
+
votes[slug] = vote;
|
|
253
|
+
}
|
|
254
|
+
return Object.keys(votes).length ? votes : undefined;
|
|
255
|
+
}
|
|
256
|
+
/** One round as a plan keeps it: the numbers and the verdict, valid. `null` when the entry holds no number (a verdict alone is no round). */
|
|
245
257
|
function normalizeRound(value) {
|
|
246
258
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
247
259
|
return null;
|
|
248
260
|
const source = value;
|
|
249
261
|
const director = readVote(source.director);
|
|
250
262
|
const readers = readVote(source.readers);
|
|
263
|
+
const readerVotes = readReaderVotes(source.readerVotes);
|
|
251
264
|
const verdict = readVerdict(source.verdict);
|
|
252
265
|
const accepted = readCount(source.accepted);
|
|
253
266
|
const rejected = readCount(source.rejected);
|
|
254
|
-
if (director === undefined && readers === undefined && accepted === undefined && rejected === undefined)
|
|
267
|
+
if (director === undefined && readers === undefined && readerVotes === undefined && accepted === undefined && rejected === undefined)
|
|
255
268
|
return null;
|
|
269
|
+
const round = readCount(source.round);
|
|
270
|
+
const reading = source.reading === "end" || source.reading === "check" ? source.reading : undefined;
|
|
256
271
|
return {
|
|
257
272
|
...(director !== undefined ? { director } : {}),
|
|
258
273
|
...(readers !== undefined ? { readers } : {}),
|
|
274
|
+
...(readerVotes ? { readerVotes } : {}),
|
|
275
|
+
...(round ? { round } : {}),
|
|
276
|
+
...(reading ? { reading } : {}),
|
|
259
277
|
...(verdict ? { verdict } : {}),
|
|
260
278
|
...(accepted !== undefined ? { accepted } : {}),
|
|
261
279
|
...(rejected !== undefined ? { rejected } : {}),
|
|
@@ -273,7 +291,24 @@ function normalizeRounds(value) {
|
|
|
273
291
|
*/
|
|
274
292
|
export function closedRound(input) {
|
|
275
293
|
const readers = input.readers?.length ? input.readers.reduce((sum, vote) => sum + vote, 0) / input.readers.length : undefined;
|
|
276
|
-
|
|
294
|
+
// With a target for the readers the round says which round it is and how each reader voted, and the average is of the readers that count.
|
|
295
|
+
const counted = input.reading ? readingAverage(input.reading) : readers;
|
|
296
|
+
return normalizeRound({
|
|
297
|
+
director: input.director,
|
|
298
|
+
readers: counted,
|
|
299
|
+
...(input.reading ? { readerVotes: input.reading.votes, round: input.reading.round } : {}),
|
|
300
|
+
verdict: input.verdict,
|
|
301
|
+
accepted: input.accepted,
|
|
302
|
+
rejected: input.rejected,
|
|
303
|
+
}) ?? {};
|
|
304
|
+
}
|
|
305
|
+
const readingAverage = (reading) => {
|
|
306
|
+
const counting = Object.entries(reading.votes).filter(([slug]) => !reading.excluded.has(slug)).map(([, score]) => score);
|
|
307
|
+
return counting.length ? counting.reduce((sum, score) => sum + score, 0) / counting.length : undefined;
|
|
308
|
+
};
|
|
309
|
+
/** The record of the readers reading a chapter on their own (`ChapterRound.reading`): the average of those that count, the vote of each, and the round it follows. */
|
|
310
|
+
export function readingRound(input) {
|
|
311
|
+
return normalizeRound({ readers: readingAverage(input), readerVotes: input.votes, round: input.round, reading: input.reading }) ?? {};
|
|
277
312
|
}
|
|
278
313
|
/** Add a round to the history of a chapter, which keeps at most `MAX_CHAPTER_ROUNDS`: the oldest leave first. */
|
|
279
314
|
export function recordChapterRound(chapter, round) {
|
|
@@ -380,6 +415,11 @@ function normalizeSecrets(value) {
|
|
|
380
415
|
return { slug: asString(secret.slug), title: asString(secret.title), revealChapter: revealChapter || undefined };
|
|
381
416
|
}).filter((secret) => secret.slug);
|
|
382
417
|
}
|
|
418
|
+
/** What each closing reading of a review lacked of the targets, in tenths of a vote (at most as many as the rounds a review can have); `undefined` when there is none. */
|
|
419
|
+
function readTenths(value) {
|
|
420
|
+
const reads = asArray(value).filter((entry) => typeof entry === "number" && Number.isFinite(entry)).map((entry) => asInteger(entry, 0, 0, 100_000)).slice(-REVIEW_MAX_ROUNDS - 1);
|
|
421
|
+
return reads.length ? reads : undefined;
|
|
422
|
+
}
|
|
383
423
|
function normalizeReview(value) {
|
|
384
424
|
if (!value || typeof value !== "object")
|
|
385
425
|
return null;
|
|
@@ -435,6 +475,12 @@ function normalizeReview(value) {
|
|
|
435
475
|
repairQueue: asArray(source.repairQueue).map((entry) => asInteger(entry, 0, 0, 999)).filter((entry) => entry > 0),
|
|
436
476
|
previousFixes: asStringList(source.previousFixes, 40),
|
|
437
477
|
...(asInteger(source.readersRound, 0, 0, 99) ? { readersRound: asInteger(source.readersRound, 0, 0, 99) } : {}),
|
|
478
|
+
...(asInteger(source.repairs, 0, 0, 9999) ? { repairs: asInteger(source.repairs, 0, 0, 9999) } : {}),
|
|
479
|
+
...(source.readText !== undefined && readCount(source.readText) !== undefined ? { readText: readCount(source.readText) } : {}),
|
|
480
|
+
...(source.reading === "end" || source.reading === "check" ? { reading: source.reading } : {}),
|
|
481
|
+
...(source.readRecorded === true ? { readRecorded: true } : {}),
|
|
482
|
+
...(readTenths(source.reads) ? { reads: readTenths(source.reads) } : {}),
|
|
483
|
+
...(source.gateStop === "rounds" || source.gateStop === "plateau" ? { gateStop: source.gateStop } : {}),
|
|
438
484
|
history: asArray(source.history).map((entry) => {
|
|
439
485
|
const item = asRecord(entry);
|
|
440
486
|
return {
|
|
@@ -534,7 +580,9 @@ function normalizeCampaignChapter(value) {
|
|
|
534
580
|
/** The votes of a review, as a file says them: a vote is on the 0-10 scale (or `null`), the chapters under the target a whole number. */
|
|
535
581
|
function normalizeReviewVotes(value) {
|
|
536
582
|
const source = asRecord(value);
|
|
537
|
-
|
|
583
|
+
// The readers' vote is there only for a review that has a target for the readers (`null`: none of its chapters has a current vote of theirs).
|
|
584
|
+
const readers = source.readers === null ? null : readVote(source.readers);
|
|
585
|
+
return { lowest: readVote(source.lowest) ?? null, book: readVote(source.book) ?? null, below: asInteger(source.below, 0, 0, MAX_BOOK_CHAPTERS), ...(readers !== undefined ? { readers } : {}) };
|
|
538
586
|
}
|
|
539
587
|
/** A review of the book as a campaign keeps it; anything that is not one (no target, no round) is none, and the campaign is no review. */
|
|
540
588
|
function normalizeReviewCampaign(value) {
|
|
@@ -550,6 +598,7 @@ function normalizeReviewCampaign(value) {
|
|
|
550
598
|
const chapterList = (list) => [...new Set(asArray(list).map((entry) => asInteger(entry, 0, 0, MAX_BOOK_CHAPTERS)).filter((entry) => entry > 0))].sort((left, right) => left - right).slice(0, MAX_CAMPAIGN_CHAPTERS);
|
|
551
599
|
const include = chapterList(source.include);
|
|
552
600
|
const scope = chapterList(source.scope);
|
|
601
|
+
const readerPolicy = normalizeReviewPolicy({ readersTarget: source.readersTarget, readerTargets: source.readerTargets, readersExcluded: source.readersExcluded });
|
|
553
602
|
const history = asArray(source.history).map((entry) => {
|
|
554
603
|
const record = asRecord(entry);
|
|
555
604
|
const at = readMoment(record.endedAt);
|
|
@@ -563,6 +612,9 @@ function normalizeReviewCampaign(value) {
|
|
|
563
612
|
targetScore,
|
|
564
613
|
...(maxRounds ? { maxRounds } : {}),
|
|
565
614
|
...(readerRounds !== undefined ? { readerRounds } : {}),
|
|
615
|
+
...(readerPolicy?.readersTarget !== undefined ? { readersTarget: readerPolicy.readersTarget } : {}),
|
|
616
|
+
...(readerPolicy?.readerTargets ? { readerTargets: readerPolicy.readerTargets } : {}),
|
|
617
|
+
...(readerPolicy?.readersExcluded ? { readersExcluded: readerPolicy.readersExcluded } : {}),
|
|
566
618
|
...(include.length ? { include } : {}),
|
|
567
619
|
scope,
|
|
568
620
|
round,
|
|
@@ -657,6 +709,9 @@ export function summarizeCampaign(campaign, options) {
|
|
|
657
709
|
lowest: last?.lowest ?? null,
|
|
658
710
|
book: last?.book ?? null,
|
|
659
711
|
budgetLimit: options?.budgetLimit ?? 0,
|
|
712
|
+
// With a target for the readers: the lowest average of the readers that count in the latest votes, and the target of that average.
|
|
713
|
+
...(last?.readers !== undefined ? { readers: last.readers } : {}),
|
|
714
|
+
...((review.readersTarget ?? options?.review?.readersTarget) !== undefined ? { readersTarget: review.readersTarget ?? options?.review?.readersTarget } : {}),
|
|
660
715
|
},
|
|
661
716
|
}
|
|
662
717
|
: {}),
|