paperlint 11.0.0 → 11.1.1
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/.github/workflows/dependabot-automerge.yml +20 -6
- package/.github/workflows/release.yml +10 -0
- package/dist/adapters/hotcrp/index.d.ts +1 -1
- package/dist/adapters/hotcrp/index.d.ts.map +1 -1
- package/dist/adapters/hotcrp/index.js +1 -1
- package/dist/adapters/hotcrp/index.js.map +1 -1
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +17 -2
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts +7 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +35 -3
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/adapters/hotcrp/site.d.ts +1 -1
- package/dist/adapters/hotcrp/site.d.ts.map +1 -1
- package/dist/adapters/hotcrp/site.js +1 -2
- package/dist/adapters/hotcrp/site.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -1
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission-fields.d.ts +77 -0
- package/dist/domain/submission-fields.d.ts.map +1 -0
- package/dist/domain/submission-fields.js +127 -0
- package/dist/domain/submission-fields.js.map +1 -0
- package/dist/domain/submission.d.ts +10 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js.map +1 -1
- package/dist/lib/paper-config.d.ts.map +1 -1
- package/dist/lib/paper-config.js +2 -0
- package/dist/lib/paper-config.js.map +1 -1
- package/dist/paper-settings.d.ts +5 -0
- package/dist/paper-settings.d.ts.map +1 -1
- package/dist/paper-settings.js +5 -2
- package/dist/paper-settings.js.map +1 -1
- package/dist/ports/submission-portal.d.ts +3 -1
- package/dist/ports/submission-portal.d.ts.map +1 -1
- package/dist/presets.d.ts +3 -0
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +3 -1
- package/dist/presets.js.map +1 -1
- package/dist/submission.d.ts +24 -5
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +140 -50
- package/dist/submission.js.map +1 -1
- package/dist/tex-requirements.d.ts +3 -0
- package/dist/tex-requirements.d.ts.map +1 -1
- package/dist/tex-requirements.js +30 -2
- package/dist/tex-requirements.js.map +1 -1
- package/docs/submission.md +29 -6
- package/lib/paper-config.ts +3 -0
- package/package.json +1 -1
- package/presets/msr.jsonc +66 -0
- package/presets/venue-profile.schema.json +41 -0
- package/scripts/refresh-deadlines/main.test.ts +5 -2
- package/scripts/refresh-deadlines/refresh.test.ts +15 -14
- package/skills/submission-portal/SKILL.md +51 -20
- package/skills/submission-portal/SKILL.md.spec.ts +50 -19
- package/src/adapters/hotcrp/cassette/README.md +7 -6
- package/src/adapters/hotcrp/cassette/get-searchcompletion.json +100 -0
- package/src/adapters/hotcrp/index.ts +1 -0
- package/src/adapters/hotcrp/portal.io.ts +22 -2
- package/src/adapters/hotcrp/portal.test.ts +103 -2
- package/src/adapters/hotcrp/response.ts +45 -4
- package/src/adapters/hotcrp/site.ts +2 -3
- package/src/cli.ts +6 -1
- package/src/cycle-rules.test.ts +14 -6
- package/src/domain/submission-fields.test.ts +183 -0
- package/src/domain/submission-fields.ts +190 -0
- package/src/domain/submission.ts +11 -0
- package/src/new-paper.test.ts +1 -0
- package/src/paper-settings.test.ts +6 -0
- package/src/paper-settings.ts +11 -3
- package/src/ports/submission-portal.ts +3 -0
- package/src/presets.test.ts +34 -24
- package/src/presets.ts +12 -2
- package/src/submission-fields-run.test.ts +247 -0
- package/src/submission-new.test.ts +4 -4
- package/src/submission-show.test.ts +9 -0
- package/src/submission-update.test.ts +7 -1
- package/src/submission.test.ts +1 -1
- package/src/submission.ts +207 -54
- package/src/tex-requirements.test.ts +21 -0
- package/src/tex-requirements.ts +67 -2
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A VENUE'S OWN SUBMISSION FIELDS — what its portal's form asks beyond the title, the abstract, the
|
|
3
|
+
* authors and the PDF: topics, PC conflicts, a corresponding author …
|
|
4
|
+
*
|
|
5
|
+
* Two declarations, each in the file that owns the fact:
|
|
6
|
+
*
|
|
7
|
+
* venue preset `submission_fields` what the edition's form asks, as read: a kind per field
|
|
8
|
+
* paper `fields` what this paper answers
|
|
9
|
+
*
|
|
10
|
+
* The preset is DATA: it names a kind from the fixed set below, never a schema. The one schema of a
|
|
11
|
+
* paper's answers is built here from those kinds, so an unknown topic is refused before anything is
|
|
12
|
+
* sent — the portal itself would drop it without a word (HotCRP: measured 2026-10-20, a topic it
|
|
13
|
+
* does not know leaves `change_list` without `topics` and the submission with none).
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { err, ok, type Result } from "./result.ts";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The kinds a field can be, after the HotCRP form controls they stand for:
|
|
20
|
+
*
|
|
21
|
+
* checkboxes a list of option names (HotCRP's topics: `"Group: Topic"`, the group and the topic)
|
|
22
|
+
* text free text
|
|
23
|
+
* email an email address (a selector of authors that the API takes by email)
|
|
24
|
+
* pc_conflicts PC member's email → conflict type (`true` or a type name the portal checks)
|
|
25
|
+
*/
|
|
26
|
+
export const FIELD_KINDS = [
|
|
27
|
+
"checkboxes",
|
|
28
|
+
"text",
|
|
29
|
+
"email",
|
|
30
|
+
"pc_conflicts",
|
|
31
|
+
] as const;
|
|
32
|
+
export type FieldKind = (typeof FIELD_KINDS)[number];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The keys the submission object carries itself (`src/adapters/hotcrp/portal.io.ts`): a venue field
|
|
36
|
+
* of one of these names would be spread over it — `submission` would drop the PDF's upload.
|
|
37
|
+
*/
|
|
38
|
+
export const RESERVED_FIELD_KEYS = [
|
|
39
|
+
"object",
|
|
40
|
+
"pid",
|
|
41
|
+
"title",
|
|
42
|
+
"abstract",
|
|
43
|
+
"authors",
|
|
44
|
+
"submission",
|
|
45
|
+
"status",
|
|
46
|
+
] as const;
|
|
47
|
+
|
|
48
|
+
/** The first of `keys` that is reserved, or null. Pure. */
|
|
49
|
+
export const reservedKey = (keys: readonly string[]): string | null =>
|
|
50
|
+
keys.find((k) => RESERVED_FIELD_KEYS.some((r) => r === k)) ?? null;
|
|
51
|
+
|
|
52
|
+
/** One field of the form, as the preset records it. */
|
|
53
|
+
export interface FieldDeclaration {
|
|
54
|
+
readonly kind: FieldKind;
|
|
55
|
+
/** The form will not complete without it. */
|
|
56
|
+
readonly required: boolean;
|
|
57
|
+
/** The form's own label, when the API's key is not it. */
|
|
58
|
+
readonly label: string | null;
|
|
59
|
+
/** The choices, for `checkboxes`; empty for every other kind. */
|
|
60
|
+
readonly options: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A venue preset's `submission_fields`: the form's fields, and where and when they were read. */
|
|
64
|
+
export interface VenueFields {
|
|
65
|
+
/** `portal`: read through the portal's API; `form`: copied from its submission form. */
|
|
66
|
+
readonly source: "portal" | "form";
|
|
67
|
+
readonly url: string;
|
|
68
|
+
/** The day it was read, YYYY-MM-DD. */
|
|
69
|
+
readonly read: string;
|
|
70
|
+
/** The API's key → the field. */
|
|
71
|
+
readonly fields: Readonly<Record<string, FieldDeclaration>>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A paper's answers, checked against its venue's fields: the API's key → the value to send. */
|
|
75
|
+
export type FieldValues = Readonly<Record<string, unknown>>;
|
|
76
|
+
|
|
77
|
+
const CONFLICT = z.union([z.literal(true), z.string().trim().min(1)]);
|
|
78
|
+
|
|
79
|
+
/** One field's value schema, from its kind. Pure. */
|
|
80
|
+
function valueSchema(d: FieldDeclaration): Readonly<z.ZodType> {
|
|
81
|
+
switch (d.kind) {
|
|
82
|
+
case "checkboxes":
|
|
83
|
+
return z
|
|
84
|
+
.array(
|
|
85
|
+
z.string().refine((v) => d.options.includes(v), {
|
|
86
|
+
error: (i) =>
|
|
87
|
+
`${JSON.stringify(i.input)} is not one of the form's options`,
|
|
88
|
+
}),
|
|
89
|
+
)
|
|
90
|
+
.min(d.required ? 1 : 0, {
|
|
91
|
+
error: "the form requires at least one",
|
|
92
|
+
})
|
|
93
|
+
.refine((l) => new Set(l).size === l.length, {
|
|
94
|
+
error: "an option is given twice",
|
|
95
|
+
});
|
|
96
|
+
case "text":
|
|
97
|
+
return z
|
|
98
|
+
.string()
|
|
99
|
+
.trim()
|
|
100
|
+
.min(d.required ? 1 : 0);
|
|
101
|
+
case "email":
|
|
102
|
+
return z.email();
|
|
103
|
+
case "pc_conflicts":
|
|
104
|
+
return z.record(z.email(), CONFLICT);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The schema of a paper's `fields` for these venue fields: every key declared, the required ones present. Pure. */
|
|
109
|
+
export const fieldValuesSchema = (
|
|
110
|
+
v: VenueFields,
|
|
111
|
+
): Readonly<z.ZodType<FieldValues>> =>
|
|
112
|
+
z.strictObject(
|
|
113
|
+
Object.fromEntries(
|
|
114
|
+
Object.entries(v.fields).map(([key, d]) => {
|
|
115
|
+
const s = valueSchema(d);
|
|
116
|
+
return [key, d.required ? s : s.optional()];
|
|
117
|
+
}),
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const at = (path: readonly PropertyKey[]): string =>
|
|
122
|
+
path
|
|
123
|
+
.map((p) => (typeof p === "number" ? `[${String(p)}]` : `.${String(p)}`))
|
|
124
|
+
.join("");
|
|
125
|
+
|
|
126
|
+
/** The first problem of a refused `fields`, naming the key, and what the form offers when it is a choice. */
|
|
127
|
+
function problemOf(issue: z.core.$ZodIssue, v: VenueFields): string {
|
|
128
|
+
const key = issue.path[0];
|
|
129
|
+
const declared = typeof key === "string" ? v.fields[key] : undefined;
|
|
130
|
+
const offers =
|
|
131
|
+
declared !== undefined && declared.kind === "checkboxes"
|
|
132
|
+
? ` — the form offers: ${declared.options.map((o) => JSON.stringify(o)).join(", ")}`
|
|
133
|
+
: "";
|
|
134
|
+
const known = Object.keys(v.fields).join(", ");
|
|
135
|
+
return issue.code === "unrecognized_keys"
|
|
136
|
+
? `"fields" has ${issue.keys.map((k) => `"${k}"`).join(", ")}, which the venue's form does not ask (it asks: ${known})`
|
|
137
|
+
: `"fields"${at(issue.path)}: ${issue.message}${offers}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A paper's `fields` key, checked against its venue's form → the values to send, or one line saying
|
|
142
|
+
* what is wrong. Pure. A paper that gives none answers nothing: fine for a venue whose preset records
|
|
143
|
+
* no fields, refused when the venue's form requires one.
|
|
144
|
+
*
|
|
145
|
+
* @param raw the paper's `fields`, null when absent
|
|
146
|
+
* @param venue the venue preset's `submission_fields`; null when it records none
|
|
147
|
+
* @param where where the venue's fields were read from, for the message (the preset chain)
|
|
148
|
+
*/
|
|
149
|
+
export function parsePaperFields(
|
|
150
|
+
raw: unknown,
|
|
151
|
+
venue: VenueFields | null,
|
|
152
|
+
where: string,
|
|
153
|
+
): Result<FieldValues, string> {
|
|
154
|
+
if (venue === null)
|
|
155
|
+
return raw === null
|
|
156
|
+
? ok({})
|
|
157
|
+
: err(
|
|
158
|
+
`"fields" is set, but the venue preset records no "submission_fields" (read: ${where}) — record the form's fields in the venue's preset first, or drop "fields"`,
|
|
159
|
+
);
|
|
160
|
+
const parsed = fieldValuesSchema(venue).safeParse(raw ?? {});
|
|
161
|
+
return parsed.success
|
|
162
|
+
? ok(parsed.data)
|
|
163
|
+
: err(parsed.error.issues.map((i) => problemOf(i, venue)).join("; "));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The checkbox fields the paper sent that the portal did not take: sent non-empty, absent from the
|
|
168
|
+
* answer's changes, and named in a message of the portal's. That is a silent drop — the portal keeps
|
|
169
|
+
* an option it does not know as nothing. Pure.
|
|
170
|
+
*/
|
|
171
|
+
export function droppedFields(
|
|
172
|
+
sent: FieldValues,
|
|
173
|
+
venue: VenueFields | null,
|
|
174
|
+
answer: {
|
|
175
|
+
readonly changes: readonly string[];
|
|
176
|
+
readonly messageFields: readonly (string | null)[];
|
|
177
|
+
},
|
|
178
|
+
): readonly string[] {
|
|
179
|
+
if (venue === null) return [];
|
|
180
|
+
return Object.entries(sent)
|
|
181
|
+
.filter(
|
|
182
|
+
([key, value]) =>
|
|
183
|
+
venue.fields[key]?.kind === "checkboxes" &&
|
|
184
|
+
Array.isArray(value) &&
|
|
185
|
+
value.length > 0 &&
|
|
186
|
+
!answer.changes.includes(key) &&
|
|
187
|
+
answer.messageFields.includes(key),
|
|
188
|
+
)
|
|
189
|
+
.map(([key]) => key);
|
|
190
|
+
}
|
package/src/domain/submission.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { err, ok, type Result } from "./result.ts";
|
|
13
13
|
import { isRecord } from "./record.ts";
|
|
14
14
|
import type { Sha256 } from "./sha256.ts";
|
|
15
|
+
import type { FieldValues } from "./submission-fields.ts";
|
|
15
16
|
|
|
16
17
|
/** The portal kinds an adapter exists for. Any other kind is refused by name. */
|
|
17
18
|
export type PortalKind = "hotcrp";
|
|
@@ -100,6 +101,8 @@ export interface SubmissionChange {
|
|
|
100
101
|
readonly abstract: string | null;
|
|
101
102
|
/** Mark the submission submitted (ready for review). */
|
|
102
103
|
readonly submit: boolean;
|
|
104
|
+
/** The venue's own form fields the paper answers, checked against the preset; empty sends none. */
|
|
105
|
+
readonly fields: FieldValues;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
/** One message from the portal: its text, and the field it is about when it names one. */
|
|
@@ -207,6 +210,14 @@ export interface NewSubmission {
|
|
|
207
210
|
readonly abstract: string;
|
|
208
211
|
readonly authors: readonly Author[];
|
|
209
212
|
readonly pdf: { readonly name: string; readonly bytes: Uint8Array };
|
|
213
|
+
/** The venue's own form fields the paper answers, checked against the preset; empty sends none. */
|
|
214
|
+
readonly fields: FieldValues;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** What the portal lets an author read of its form's choices: only what an author's token can see. */
|
|
218
|
+
export interface PortalOptions {
|
|
219
|
+
/** The topics an author can choose, spelled as the portal takes them. */
|
|
220
|
+
readonly topics: readonly string[];
|
|
210
221
|
}
|
|
211
222
|
|
|
212
223
|
/** What the portal answered to a creation: an update's answer, and the id it chose when it saved. */
|
package/src/new-paper.test.ts
CHANGED
|
@@ -34,6 +34,7 @@ describe("parsePaperSettings", () => {
|
|
|
34
34
|
talk: null,
|
|
35
35
|
submission: null,
|
|
36
36
|
authors: null,
|
|
37
|
+
fields: null,
|
|
37
38
|
cycles: null,
|
|
38
39
|
},
|
|
39
40
|
});
|
|
@@ -48,6 +49,7 @@ describe("parsePaperSettings", () => {
|
|
|
48
49
|
talk: null,
|
|
49
50
|
submission: null,
|
|
50
51
|
authors: null,
|
|
52
|
+
fields: null,
|
|
51
53
|
cycles: null,
|
|
52
54
|
},
|
|
53
55
|
});
|
|
@@ -65,6 +67,7 @@ describe("parsePaperSettings", () => {
|
|
|
65
67
|
talk: null,
|
|
66
68
|
submission: null,
|
|
67
69
|
authors: null,
|
|
70
|
+
fields: null,
|
|
68
71
|
cycles: null,
|
|
69
72
|
},
|
|
70
73
|
});
|
|
@@ -185,6 +188,7 @@ const UNSET = {
|
|
|
185
188
|
talk: null,
|
|
186
189
|
submission: null,
|
|
187
190
|
authors: null,
|
|
191
|
+
fields: null,
|
|
188
192
|
cycles: null,
|
|
189
193
|
};
|
|
190
194
|
|
|
@@ -243,6 +247,7 @@ describe("readPaperSettings — the root paperlint.json's defaults, the paper's
|
|
|
243
247
|
talk: null,
|
|
244
248
|
submission: null,
|
|
245
249
|
authors: null,
|
|
250
|
+
fields: null,
|
|
246
251
|
cycles: null,
|
|
247
252
|
});
|
|
248
253
|
});
|
|
@@ -294,6 +299,7 @@ describe("paperRules — `rules` in paperlint.json", () => {
|
|
|
294
299
|
talk: null,
|
|
295
300
|
submission: null,
|
|
296
301
|
authors: null,
|
|
302
|
+
fields: null,
|
|
297
303
|
cycles: null,
|
|
298
304
|
});
|
|
299
305
|
|
package/src/paper-settings.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* One file name at two levels, one schema (lib/paper-config.mjs → SETTINGS_KEYS):
|
|
5
5
|
*
|
|
6
6
|
* paperlint.json the project (optional): papersDir, rules, defaults
|
|
7
|
-
* <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors } —
|
|
7
|
+
* <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors, fields } —
|
|
8
8
|
* or `cycles`, from whose current attempt extends, kind and submission
|
|
9
9
|
* are DERIVED (src/domain/cycle.ts); the two forms do not mix
|
|
10
10
|
* a venue preset `paperlint:<name>` (shipped) or `./x.jsonc` (src/presets.ts)
|
|
@@ -73,6 +73,11 @@ export interface PaperSettings {
|
|
|
73
73
|
readonly submission: PaperSubmission | null;
|
|
74
74
|
/** The authors as the venue's portal should record them, in order; null when the paper declares none. Never the root's. */
|
|
75
75
|
readonly authors: readonly Author[] | null;
|
|
76
|
+
/**
|
|
77
|
+
* The paper's answers to its venue's own form fields, as written: checked against the venue
|
|
78
|
+
* preset's `submission_fields` where both are known (`paperlint submission`); null when absent.
|
|
79
|
+
*/
|
|
80
|
+
readonly fields: unknown;
|
|
76
81
|
/**
|
|
77
82
|
* The paper's attempts at venues and the current one, when the file declares `cycles`; null for a
|
|
78
83
|
* file in the flat form. With cycles, `extends`, `kind` and `submission` above are the current
|
|
@@ -137,11 +142,11 @@ export function identityField(
|
|
|
137
142
|
);
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
/** `rules` (checked for shape only), `talk`, `submission` and `authors`, each null when absent. */
|
|
145
|
+
/** `rules` (checked for shape only), `talk`, `submission` and `authors`, each null when absent; `fields` as written. */
|
|
141
146
|
function rulesAndTalk(
|
|
142
147
|
json: Readonly<Record<string, unknown>>,
|
|
143
148
|
): Result<
|
|
144
|
-
Pick<PaperSettings, "rules" | "talk" | "submission" | "authors">,
|
|
149
|
+
Pick<PaperSettings, "rules" | "talk" | "submission" | "authors" | "fields">,
|
|
145
150
|
string
|
|
146
151
|
> {
|
|
147
152
|
const rules = json["rules"];
|
|
@@ -160,6 +165,7 @@ function rulesAndTalk(
|
|
|
160
165
|
talk: talk.value,
|
|
161
166
|
submission: submission.value,
|
|
162
167
|
authors: authors.value,
|
|
168
|
+
fields: json["fields"] ?? null,
|
|
163
169
|
})
|
|
164
170
|
: authors;
|
|
165
171
|
}
|
|
@@ -334,6 +340,7 @@ function merge(
|
|
|
334
340
|
talk: null,
|
|
335
341
|
submission: null,
|
|
336
342
|
authors: null,
|
|
343
|
+
fields: null,
|
|
337
344
|
cycles: null,
|
|
338
345
|
};
|
|
339
346
|
const merged: PaperSettings = {
|
|
@@ -345,6 +352,7 @@ function merge(
|
|
|
345
352
|
talk: p.talk,
|
|
346
353
|
submission: p.submission,
|
|
347
354
|
authors: p.authors,
|
|
355
|
+
fields: p.fields,
|
|
348
356
|
cycles: p.cycles,
|
|
349
357
|
};
|
|
350
358
|
return paper === null && Object.values(merged).every((v) => v === null)
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
CreateOutcome,
|
|
10
10
|
NewSubmission,
|
|
11
11
|
PortalFailure,
|
|
12
|
+
PortalOptions,
|
|
12
13
|
SubmissionChange,
|
|
13
14
|
SubmissionView,
|
|
14
15
|
UpdateOutcome,
|
|
@@ -34,6 +35,8 @@ export interface SubmissionPortal {
|
|
|
34
35
|
paper: NewSubmission,
|
|
35
36
|
o: { readonly save: boolean },
|
|
36
37
|
): Promise<Result<CreateOutcome, PortalFailure>>;
|
|
38
|
+
/** What the form offers an author to choose: its topics. */
|
|
39
|
+
options(): Promise<Result<PortalOptions, PortalFailure>>;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/** How an author makes a token for a portal site, in the words the command prints. */
|
package/src/presets.test.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { readdirSync, readFileSync } from "node:fs";
|
|
|
10
10
|
import { join, relative } from "node:path";
|
|
11
11
|
import { describe, expect, it } from "vitest";
|
|
12
12
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
13
|
+
import { frozenText } from "../test/frozen-presets.ts";
|
|
13
14
|
import { presetsDir } from "./package-dirs.ts";
|
|
14
15
|
import { parsePreset } from "./tex-requirements.ts";
|
|
15
16
|
import {
|
|
@@ -23,18 +24,27 @@ import {
|
|
|
23
24
|
} from "./presets.ts";
|
|
24
25
|
|
|
25
26
|
const VENUES = presetsDir();
|
|
26
|
-
const
|
|
27
|
+
const live = Object.fromEntries(
|
|
27
28
|
readdirSync(VENUES)
|
|
28
29
|
.filter((f) => f.endsWith(".jsonc") || f.endsWith(".json"))
|
|
29
30
|
.map((f) => [join(VENUES, f), readFileSync(join(VENUES, f))]),
|
|
30
31
|
);
|
|
32
|
+
// The shipped msr.jsonc's deadlines are rewritten by the scheduled refresh, so the tests of LOGIC
|
|
33
|
+
// read it FROZEN (test/frozen-presets.ts); only the shape test below reads the shipped file.
|
|
34
|
+
const shipped = {
|
|
35
|
+
...live,
|
|
36
|
+
[join(VENUES, "msr.jsonc")]: frozenText("msr.jsonc"),
|
|
37
|
+
};
|
|
31
38
|
const PAPER_FILE = "/work/papers/p/paperlint.json";
|
|
32
|
-
const deps = (extra: Record<string, string> = {}) => ({
|
|
33
|
-
files: memoryFiles({ ...
|
|
39
|
+
const deps = (extra: Record<string, string> = {}, base = shipped) => ({
|
|
40
|
+
files: memoryFiles({ ...base, ...extra }),
|
|
34
41
|
venuesDir: VENUES,
|
|
35
42
|
});
|
|
36
|
-
const resolve = (
|
|
37
|
-
|
|
43
|
+
const resolve = (
|
|
44
|
+
spec: string,
|
|
45
|
+
extra: Record<string, string> = {},
|
|
46
|
+
base = shipped,
|
|
47
|
+
) => resolvePreset(spec, PAPER_FILE, deps(extra, base));
|
|
38
48
|
/** A venue preset of a project's own: the identity every venue declares, then `body`. */
|
|
39
49
|
const venue = (body: Record<string, unknown>, name = "Our Workshop"): string =>
|
|
40
50
|
JSON.stringify({
|
|
@@ -80,7 +90,7 @@ describe("shipped presets", () => {
|
|
|
80
90
|
|
|
81
91
|
describe("shipped presets: paperlint:msr", () => {
|
|
82
92
|
it("paperlint:msr → msr over ieee-conference: one kind, appendices counted as body, compsoc forbidden", () => {
|
|
83
|
-
const r = resolve("paperlint:msr");
|
|
93
|
+
const r = resolve("paperlint:msr", {}, live);
|
|
84
94
|
expect(r.ok).toBe(true);
|
|
85
95
|
if (!r.ok) return;
|
|
86
96
|
expect(r.value.chain.map((f) => f.split("/").pop())).toEqual([
|
|
@@ -103,26 +113,26 @@ describe("shipped presets: paperlint:msr", () => {
|
|
|
103
113
|
kind: "hotcrp",
|
|
104
114
|
url: "https://msr2027.hotcrp.com",
|
|
105
115
|
});
|
|
106
|
-
// The
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
source:
|
|
114
|
-
url:
|
|
115
|
-
read:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
// The deadlines' SHAPE, never their dates: the scheduled refresh rewrites those whenever the
|
|
117
|
+
// portal moves them (deadlines.yml), and a date asserted here turns its pull request red.
|
|
118
|
+
// Guards: the shipped preset keeps a submission deadline, every reading is the portal's own
|
|
119
|
+
// from the venue's deadlines page, with a read day and an instant that carries its zone.
|
|
120
|
+
expect(r.value.deadlines.map((d) => d.what)).toContain("submission");
|
|
121
|
+
expect(
|
|
122
|
+
r.value.deadlines.map((d) => ({
|
|
123
|
+
source: d.source,
|
|
124
|
+
url: d.url,
|
|
125
|
+
read: /^\d{4}-\d{2}-\d{2}$/.test(d.read),
|
|
126
|
+
at: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(d.at),
|
|
127
|
+
})),
|
|
128
|
+
).toEqual(
|
|
129
|
+
r.value.deadlines.map(() => ({
|
|
120
130
|
source: "portal",
|
|
121
131
|
url: "https://msr2027.hotcrp.com/deadlines",
|
|
122
|
-
read:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
read: true,
|
|
133
|
+
at: true,
|
|
134
|
+
})),
|
|
135
|
+
);
|
|
126
136
|
// No rule turned on: the IEEE capitalization rule has not been read and quoted.
|
|
127
137
|
expect(r.value.rules).toEqual({});
|
|
128
138
|
expect(r.value.registerAnchors).toEqual([]);
|
package/src/presets.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* format per key, the child wins; `kinds` by kind name, a child's kind replaces that kind
|
|
27
27
|
* rules per rule id, the child wins; `ruleOrigins` keeps which file set each
|
|
28
28
|
* template the child wins, with its `template_forbids`; so does `name`, and `required_sections`, `register`, `talk`,
|
|
29
|
-
* `portal` and `
|
|
29
|
+
* `portal`, `deadlines` and `submission_fields` (each whole)
|
|
30
30
|
* aliases union, with every `name` — what the venue is called along the chain
|
|
31
31
|
*
|
|
32
32
|
* ── THE ID AND THE LABEL ──────────────────────────────────────────────────────────
|
|
@@ -63,6 +63,7 @@ import { messageOf } from "./domain/text.ts";
|
|
|
63
63
|
import type { RegisterAnchor } from "./domain/register.ts";
|
|
64
64
|
import type { VenueTalk } from "./domain/talk.ts";
|
|
65
65
|
import type { VenuePortal } from "./domain/submission.ts";
|
|
66
|
+
import type { VenueFields } from "./domain/submission-fields.ts";
|
|
66
67
|
import type { Reading } from "./domain/deadline.ts";
|
|
67
68
|
|
|
68
69
|
/** The prefix of a shipped preset's spec. */
|
|
@@ -129,6 +130,8 @@ export interface Preset {
|
|
|
129
130
|
* workflow); empty when no file of the chain names any. A paper's current cycle derives them.
|
|
130
131
|
*/
|
|
131
132
|
readonly deadlines: readonly Reading[];
|
|
133
|
+
/** The fields the edition's submission form asks (`paperlint submission`); null when no file of the chain records any. */
|
|
134
|
+
readonly submissionFields: VenueFields | null;
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
/** Why a spec does not resolve. */
|
|
@@ -300,6 +303,7 @@ const NOTHING_MERGED: Merging = {
|
|
|
300
303
|
talk: null,
|
|
301
304
|
portal: null,
|
|
302
305
|
deadlines: [],
|
|
306
|
+
submissionFields: null,
|
|
303
307
|
};
|
|
304
308
|
|
|
305
309
|
/** The blocks a child replaces whole: the child's when it names one, else its parents'. Pure. */
|
|
@@ -308,13 +312,19 @@ const wholeBlocks = (
|
|
|
308
312
|
p: PresetFile,
|
|
309
313
|
): Pick<
|
|
310
314
|
Merging,
|
|
311
|
-
|
|
315
|
+
| "requiredSections"
|
|
316
|
+
| "registerAnchors"
|
|
317
|
+
| "talk"
|
|
318
|
+
| "portal"
|
|
319
|
+
| "deadlines"
|
|
320
|
+
| "submissionFields"
|
|
312
321
|
> => ({
|
|
313
322
|
requiredSections: p.requiredSections ?? acc.requiredSections,
|
|
314
323
|
registerAnchors: p.registerAnchors ?? acc.registerAnchors,
|
|
315
324
|
talk: p.talk ?? acc.talk,
|
|
316
325
|
portal: p.portal ?? acc.portal,
|
|
317
326
|
deadlines: p.deadlines ?? acc.deadlines,
|
|
327
|
+
submissionFields: p.submissionFields ?? acc.submissionFields,
|
|
318
328
|
});
|
|
319
329
|
|
|
320
330
|
/** One file of the chain, `file`, merged over what its parents gave. Pure. */
|