paperlint 18.5.0 → 18.6.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/CLAUDE.md +2 -2
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +1 -0
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +15 -0
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -3
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission.d.ts +4 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js.map +1 -1
- package/dist/submission.d.ts +19 -2
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +121 -17
- package/dist/submission.js.map +1 -1
- package/docs/submission.md +19 -4
- package/package.json +1 -1
- package/src/adapters/hotcrp/portal.io.ts +1 -0
- package/src/adapters/hotcrp/portal.test.ts +43 -2
- package/src/adapters/hotcrp/response.ts +21 -0
- package/src/cli.ts +5 -3
- package/src/domain/submission.ts +4 -0
- package/src/submission-fields-run.test.ts +1 -0
- package/src/submission-prior-reviews.test.ts +9 -1
- package/src/submission-show.test.ts +81 -0
- package/src/submission-update.test.ts +164 -6
- package/src/submission.ts +208 -24
package/src/submission.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* adapter per portal kind does the talking (`src/adapters/hotcrp/`).
|
|
9
9
|
*
|
|
10
10
|
* show status, id, title, paper type, topics, abstract length, the PDF the portal holds — and
|
|
11
|
-
* whether it is the local `paper.pdf`, by sha256
|
|
12
|
-
*
|
|
11
|
+
* whether it is the local `paper.pdf`, by sha256; the paper's title, abstract and authors
|
|
12
|
+
* where they differ
|
|
13
|
+
* update send the PDF, the paper's title and abstract each when the portal holds another (or
|
|
14
|
+
* `--abstract`'s file), "submitted" if asked. A DRY RUN unless `--save`:
|
|
13
15
|
* the portal checks the change and keeps nothing
|
|
14
16
|
* topics the topics the portal offers, against the ones the venue preset records
|
|
15
17
|
*
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
* 🔴 THE TOKEN IS AN INPUT, AND ONLY AN INPUT. It comes from the environment (the root reads it), is
|
|
27
29
|
* handed to the adapter, and never appears in anything printed here.
|
|
28
30
|
*/
|
|
31
|
+
import { zip } from "remeda";
|
|
29
32
|
import { venueCycleOf } from "./domain/cycle.ts";
|
|
30
33
|
import { basename, join, resolve } from "node:path";
|
|
31
34
|
import { absolutePath } from "./domain/paths.ts";
|
|
@@ -164,8 +167,8 @@ export interface SubmissionArgs {
|
|
|
164
167
|
/** `--pdf <file>`, relative to `cwd`; null: the paper's own PDF. */
|
|
165
168
|
readonly pdf: string | null;
|
|
166
169
|
/**
|
|
167
|
-
* `--abstract <file>`, relative to `cwd`; null: `update`
|
|
168
|
-
* it
|
|
170
|
+
* `--abstract <file>`, relative to `cwd`; null: `new` and `update` read the abstract from the
|
|
171
|
+
* paper's source, and `update` sends it only when the portal holds another.
|
|
169
172
|
*/
|
|
170
173
|
readonly abstract: string | null;
|
|
171
174
|
readonly submit: boolean;
|
|
@@ -372,19 +375,70 @@ export function deadlineLine(d: InForce): string {
|
|
|
372
375
|
return `deadline ${d.what} ${set}${also}`;
|
|
373
376
|
}
|
|
374
377
|
|
|
378
|
+
/** A text the paper sets, said when the portal holds another; nothing when they match or it is unread. */
|
|
379
|
+
const notThePortals = (
|
|
380
|
+
label: string,
|
|
381
|
+
paper: string | null,
|
|
382
|
+
portal: string | null,
|
|
383
|
+
shown: (text: string) => string,
|
|
384
|
+
): readonly string[] =>
|
|
385
|
+
paper === null || sameText(paper, portal)
|
|
386
|
+
? []
|
|
387
|
+
: [
|
|
388
|
+
`${label} ${shown(paper)} — NOT the portal's; \`paperlint submission update\` sends it`,
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
const words = (text: string): string => `${String(wordCount(text))} words`;
|
|
392
|
+
|
|
393
|
+
const authorText = (a: Author): string =>
|
|
394
|
+
`${a.name} <${a.email}>${a.affiliation === null ? "" : `, ${a.affiliation}`}`;
|
|
395
|
+
|
|
396
|
+
/** One author on both sides: the email in any case, the name in any spacing, the affiliation. Pure. */
|
|
397
|
+
const sameAuthor = ([a, b]: readonly [Author, Author]): boolean =>
|
|
398
|
+
a.email.toLowerCase() === b.email.toLowerCase() &&
|
|
399
|
+
sameText(a.name, b.name) &&
|
|
400
|
+
(a.affiliation ?? "") === (b.affiliation ?? "");
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The paper's authors (`paperlint.json`) said when the portal records others; nothing when either
|
|
404
|
+
* side names none. `update` never changes them: that is the site's, and the line says so. Pure.
|
|
405
|
+
*/
|
|
406
|
+
function authorsLines(
|
|
407
|
+
paper: readonly Author[] | null,
|
|
408
|
+
portal: readonly Author[] | null,
|
|
409
|
+
): readonly string[] {
|
|
410
|
+
if (paper === null || portal === null) return [];
|
|
411
|
+
const same =
|
|
412
|
+
paper.length === portal.length && zip(paper, portal).every(sameAuthor);
|
|
413
|
+
return same
|
|
414
|
+
? []
|
|
415
|
+
: [
|
|
416
|
+
`paper authors ${paper.map(authorText).join("; ")} — NOT the portal's (${portal.map(authorText).join("; ")}); \`paperlint submission update\` does not change the authors: change them on the site`,
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
|
|
375
420
|
/** `show`'s report. Pure. */
|
|
376
421
|
export function showLines(
|
|
377
422
|
t: SubmissionTarget,
|
|
378
423
|
view: SubmissionView,
|
|
379
|
-
local: {
|
|
424
|
+
local: {
|
|
425
|
+
readonly shown: string;
|
|
426
|
+
readonly sha256: Sha256 | null;
|
|
427
|
+
/** The paper's own title and abstract; null when paperlint cannot read one. */
|
|
428
|
+
readonly title: string | null;
|
|
429
|
+
readonly abstract: string | null;
|
|
430
|
+
},
|
|
380
431
|
): readonly string[] {
|
|
381
432
|
return [
|
|
382
433
|
`submission ${String(view.id)} on ${t.portal.url} (${t.portal.kind})`,
|
|
383
434
|
`status ${view.status}${view.submittedAt === null ? "" : `, submitted ${iso(view.submittedAt)}`}`,
|
|
384
435
|
`title ${view.title ?? "—"}`,
|
|
436
|
+
...notThePortals("paper title ", local.title, view.title, (x) => x),
|
|
385
437
|
`paper type ${view.paperType ?? "—"}`,
|
|
386
438
|
`topics ${view.topics.length ? view.topics.join("; ") : "—"}`,
|
|
387
|
-
`abstract ${view.abstract === null ? "—" :
|
|
439
|
+
`abstract ${view.abstract === null ? "—" : words(view.abstract)}`,
|
|
440
|
+
...notThePortals("paper abstract", local.abstract, view.abstract, words),
|
|
441
|
+
...authorsLines(t.authors, view.authors),
|
|
388
442
|
pdfLine(view),
|
|
389
443
|
`local PDF ${local.shown} ${local.sha256 === null ? "(missing)" : `sha2-${local.sha256}`}`,
|
|
390
444
|
matchLine(view, local.sha256),
|
|
@@ -489,9 +543,12 @@ async function runShow(
|
|
|
489
543
|
const view = await portal.show(t.id);
|
|
490
544
|
if (!view.ok) return failed(view.error, deps);
|
|
491
545
|
const bytes = bytesAt(deps.files, pdfPath);
|
|
546
|
+
const text = paperText(t.paperDir, bytes, deps);
|
|
492
547
|
const local = {
|
|
493
548
|
shown: shownPath(deps.cwd, pdfPath),
|
|
494
549
|
sha256: bytes === null ? null : sha256Hex(bytes),
|
|
550
|
+
title: text.title.ok ? text.title.value : null,
|
|
551
|
+
abstract: text.abstract.ok ? text.abstract.value : null,
|
|
495
552
|
};
|
|
496
553
|
// With `cycles`, the frozen versions beside the portal's copy: which is under review, which is history.
|
|
497
554
|
const versions = versionLines(t.paperDir, deps);
|
|
@@ -517,15 +574,15 @@ function abstractOf(
|
|
|
517
574
|
: ok(new TextDecoder().decode(bytes).trim());
|
|
518
575
|
}
|
|
519
576
|
|
|
520
|
-
/** What `update` sends: the PDF's bytes, the abstract's text, whether to mark it submitted, the fields. */
|
|
577
|
+
/** What `update` sends: the PDF's bytes, the title, the abstract's text, whether to mark it submitted, the fields. */
|
|
521
578
|
const changeOf = (
|
|
522
579
|
a: SubmissionArgs & { readonly pdfPath: string },
|
|
523
580
|
bytes: Uint8Array,
|
|
524
|
-
abstract: string | null,
|
|
581
|
+
text: { readonly title: string | null; readonly abstract: string | null },
|
|
525
582
|
fields: FieldValues,
|
|
526
583
|
) => ({
|
|
527
584
|
pdf: { name: basename(a.pdfPath), bytes },
|
|
528
|
-
|
|
585
|
+
...text,
|
|
529
586
|
submit: a.submit,
|
|
530
587
|
fields,
|
|
531
588
|
});
|
|
@@ -619,7 +676,7 @@ const VENUE_RULES = "venue rules at their default options";
|
|
|
619
676
|
const REBUILD_REFUSAL =
|
|
620
677
|
"refused: no build facts describe this PDF (none, unreadable, or of other bytes), so the venue rules did not see it — rebuild (`paperlint build`), run the dry run again, and read its venue check; nothing was sent";
|
|
621
678
|
|
|
622
|
-
/** `update`: send the PDF
|
|
679
|
+
/** `update`: send the PDF, a changed title and abstract, and "submitted" when asked; a dry run unless saving. */
|
|
623
680
|
async function runUpdate(
|
|
624
681
|
t: SubmissionTarget & { readonly id: number },
|
|
625
682
|
portal: SubmissionPortal,
|
|
@@ -641,8 +698,8 @@ async function runUpdate(
|
|
|
641
698
|
if (refused) return 2;
|
|
642
699
|
const plan = planFor(t, a.save, deps);
|
|
643
700
|
if (!plan.ok) return (deps.err(plan.error), 2);
|
|
644
|
-
const
|
|
645
|
-
const r = await
|
|
701
|
+
const sent = { a, bytes, abstract: abstract.value };
|
|
702
|
+
const r = await sendChange(t, portal, sent, deps);
|
|
646
703
|
if (!r.ok) return failed(r.error, deps);
|
|
647
704
|
return afterUpdate(t, r.value, sentOf(a, { shown, bytes }, plan.value), deps);
|
|
648
705
|
}
|
|
@@ -654,6 +711,118 @@ const sentOf = (
|
|
|
654
711
|
plan: FreezePlan | null,
|
|
655
712
|
) => ({ ...file, save: a.save, submit: a.submit, plan });
|
|
656
713
|
|
|
714
|
+
/** Two texts that differ only in spacing are one text. Pure. */
|
|
715
|
+
const sameText = (paper: string, portal: string | null): boolean =>
|
|
716
|
+
portal !== null &&
|
|
717
|
+
paper.replace(/\s+/g, " ").trim() === portal.replace(/\s+/g, " ").trim();
|
|
718
|
+
|
|
719
|
+
/** One text `update` may send: the text (null: none), and the line saying what happens to it. */
|
|
720
|
+
interface TextChange {
|
|
721
|
+
readonly send: string | null;
|
|
722
|
+
readonly line: string;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** How a text is named in `update`'s line: its label, the paper's text, and the portal's when it differs. */
|
|
726
|
+
interface Shown {
|
|
727
|
+
readonly label: string;
|
|
728
|
+
readonly paper: (text: string) => string;
|
|
729
|
+
readonly portal: (text: string) => string;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const TITLE: Shown = {
|
|
733
|
+
label: "title ",
|
|
734
|
+
paper: (x) => `«${x}»`,
|
|
735
|
+
portal: (x) => `«${x}»`,
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
const ABSTRACT: Shown = {
|
|
739
|
+
label: "abstract ",
|
|
740
|
+
paper: (x) => `the paper's (${words(x)})`,
|
|
741
|
+
portal: (x) => `another (${words(x)})`,
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
/** What `update` does about one text the paper sets: sends it when the portal holds another. Pure. */
|
|
745
|
+
export function textChange(
|
|
746
|
+
shown: Shown,
|
|
747
|
+
paper: Result<string, string>,
|
|
748
|
+
portal: string | null,
|
|
749
|
+
): TextChange {
|
|
750
|
+
if (!paper.ok)
|
|
751
|
+
return { send: null, line: `${shown.label}not checked — ${paper.error}` };
|
|
752
|
+
return sameText(paper.value, portal)
|
|
753
|
+
? {
|
|
754
|
+
send: null,
|
|
755
|
+
line: `${shown.label}unchanged — the portal holds ${shown.paper(paper.value)}`,
|
|
756
|
+
}
|
|
757
|
+
: {
|
|
758
|
+
send: paper.value,
|
|
759
|
+
line: `${shown.label}sends ${shown.paper(paper.value)} — the portal has ${portal === null ? "none" : shown.portal(portal)}`,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** What `update` sends: the PDF and its name, `--abstract`'s text (null: the paper's is compared). */
|
|
764
|
+
interface Sent {
|
|
765
|
+
readonly a: SubmissionArgs & { readonly pdfPath: string };
|
|
766
|
+
readonly bytes: Uint8Array;
|
|
767
|
+
readonly abstract: string | null;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** `--abstract`'s text, sent whatever the portal holds, and said. Pure. */
|
|
771
|
+
const fromFile = (sent: Sent, abstract: string): TextChange => ({
|
|
772
|
+
send: abstract,
|
|
773
|
+
line: `${ABSTRACT.label}sends ${String(sent.a.abstract)} (${words(abstract)}), from --abstract`,
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* The title and abstract `update` sends: the paper's, each when the portal holds another (#619);
|
|
778
|
+
* `--abstract`'s file whatever it holds. The portal is read once, and only when there is something
|
|
779
|
+
* of the paper's to compare; a failed read stops the update.
|
|
780
|
+
*/
|
|
781
|
+
async function textsToSend(
|
|
782
|
+
t: SubmissionTarget & { readonly id: number },
|
|
783
|
+
portal: SubmissionPortal,
|
|
784
|
+
sent: Sent,
|
|
785
|
+
deps: RunDeps,
|
|
786
|
+
): Promise<
|
|
787
|
+
Result<
|
|
788
|
+
{ readonly title: TextChange; readonly abstract: TextChange },
|
|
789
|
+
PortalFailure
|
|
790
|
+
>
|
|
791
|
+
> {
|
|
792
|
+
const text = paperText(t.paperDir, sent.bytes, deps);
|
|
793
|
+
const read = text.title.ok || (sent.abstract === null && text.abstract.ok);
|
|
794
|
+
const view = read ? await portal.show(t.id) : ok(null);
|
|
795
|
+
if (!view.ok) return err(view.error);
|
|
796
|
+
const held = view.value;
|
|
797
|
+
return ok({
|
|
798
|
+
title: textChange(TITLE, text.title, held === null ? null : held.title),
|
|
799
|
+
abstract:
|
|
800
|
+
sent.abstract === null
|
|
801
|
+
? textChange(
|
|
802
|
+
ABSTRACT,
|
|
803
|
+
text.abstract,
|
|
804
|
+
held === null ? null : held.abstract,
|
|
805
|
+
)
|
|
806
|
+
: fromFile(sent, sent.abstract),
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** The change sent, its title and abstract lines printed first: the portal's answer, or why there is none. */
|
|
811
|
+
async function sendChange(
|
|
812
|
+
t: SubmissionTarget & { readonly id: number },
|
|
813
|
+
portal: SubmissionPortal,
|
|
814
|
+
sent: Sent,
|
|
815
|
+
deps: RunDeps,
|
|
816
|
+
): Promise<Result<UpdateOutcome, PortalFailure>> {
|
|
817
|
+
const texts = await textsToSend(t, portal, sent, deps);
|
|
818
|
+
if (!texts.ok) return err(texts.error);
|
|
819
|
+
const { title, abstract } = texts.value;
|
|
820
|
+
logAll([title.line, abstract.line], deps);
|
|
821
|
+
const text = { title: title.send, abstract: abstract.send };
|
|
822
|
+
const change = changeOf(sent.a, sent.bytes, text, t.fields);
|
|
823
|
+
return portal.update(t.id, change, { save: sent.a.save });
|
|
824
|
+
}
|
|
825
|
+
|
|
657
826
|
/** The portal's answer to `update` printed, and what it kept frozen: the exit code. */
|
|
658
827
|
function afterUpdate(
|
|
659
828
|
t: SubmissionTarget,
|
|
@@ -950,6 +1119,30 @@ function assembledPaper(
|
|
|
950
1119
|
: readPaper(join(paperDir, MAIN), new TextDecoder().decode(bytes), deps);
|
|
951
1120
|
}
|
|
952
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* The paper's title (`titleOf`, falling back on the build's facts about `pdf`, none without one)
|
|
1124
|
+
* and its abstract (`sourceAbstract`): what `new` sends, and what `update` and `show` compare.
|
|
1125
|
+
*/
|
|
1126
|
+
function paperText(
|
|
1127
|
+
paperDir: string,
|
|
1128
|
+
pdf: Uint8Array | null,
|
|
1129
|
+
deps: SubmissionDeps,
|
|
1130
|
+
): {
|
|
1131
|
+
readonly title: Result<string, string>;
|
|
1132
|
+
readonly abstract: Result<string, string>;
|
|
1133
|
+
} {
|
|
1134
|
+
const paper = assembledPaper(paperDir, deps);
|
|
1135
|
+
const facts = pdf === null ? null : factsOfSent(paperDir, pdf, deps);
|
|
1136
|
+
const title = titleOf(
|
|
1137
|
+
paper === null
|
|
1138
|
+
? null
|
|
1139
|
+
: { text: paper.text, where: (o: number) => placeIn(paper, o) },
|
|
1140
|
+
deps.latex,
|
|
1141
|
+
facts?.text.metadata ?? null,
|
|
1142
|
+
);
|
|
1143
|
+
return { title, abstract: sourceAbstract(paper, deps) };
|
|
1144
|
+
}
|
|
1145
|
+
|
|
953
1146
|
/** The title and the abstract: the paper's `\title`, and `--abstract`'s file or the source's abstract. */
|
|
954
1147
|
function titleAndAbstract(
|
|
955
1148
|
a: SubmissionArgs & { readonly paperDir: string },
|
|
@@ -958,20 +1151,11 @@ function titleAndAbstract(
|
|
|
958
1151
|
): Result<{ readonly title: string; readonly abstract: string }, string> {
|
|
959
1152
|
const own = abstractOf(a, deps);
|
|
960
1153
|
if (!own.ok) return own;
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
const title = titleOf(
|
|
964
|
-
paper === null
|
|
965
|
-
? null
|
|
966
|
-
: { text: paper.text, where: (o: number) => placeIn(paper, o) },
|
|
967
|
-
deps.latex,
|
|
968
|
-
metadata,
|
|
969
|
-
);
|
|
1154
|
+
const text = paperText(a.paperDir, pdf, deps);
|
|
1155
|
+
const title = text.title;
|
|
970
1156
|
if (!title.ok) return title;
|
|
971
1157
|
const abstract =
|
|
972
|
-
own.value === null
|
|
973
|
-
? sourceAbstract(paper, deps)
|
|
974
|
-
: ok(own.value.replace(/\s+/g, " "));
|
|
1158
|
+
own.value === null ? text.abstract : ok(own.value.replace(/\s+/g, " "));
|
|
975
1159
|
return abstract.ok
|
|
976
1160
|
? ok({ title: title.value, abstract: abstract.value })
|
|
977
1161
|
: abstract;
|