paperlint 18.4.1 → 18.5.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 +5 -1
- package/dist/adapters/latex/abstract.d.ts +11 -0
- package/dist/adapters/latex/abstract.d.ts.map +1 -1
- package/dist/adapters/latex/abstract.js +1 -1
- package/dist/adapters/latex/abstract.js.map +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +3 -0
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/macros.d.ts +6 -0
- package/dist/adapters/latex/macros.d.ts.map +1 -0
- package/dist/adapters/latex/macros.js +27 -0
- package/dist/adapters/latex/macros.js.map +1 -0
- package/dist/adapters/osf/host.io.d.ts +12 -0
- package/dist/adapters/osf/host.io.d.ts.map +1 -0
- package/dist/adapters/osf/host.io.js +119 -0
- package/dist/adapters/osf/host.io.js.map +1 -0
- package/dist/adapters/osf/index.d.ts +10 -0
- package/dist/adapters/osf/index.d.ts.map +1 -0
- package/dist/adapters/osf/index.js +10 -0
- package/dist/adapters/osf/index.js.map +1 -0
- package/dist/adapters/osf/response.d.ts +11 -0
- package/dist/adapters/osf/response.d.ts.map +1 -0
- package/dist/adapters/osf/response.js +87 -0
- package/dist/adapters/osf/response.js.map +1 -0
- package/dist/artifact-upload-rule.d.ts +66 -0
- package/dist/artifact-upload-rule.d.ts.map +1 -0
- package/dist/artifact-upload-rule.js +151 -0
- package/dist/artifact-upload-rule.js.map +1 -0
- package/dist/artifact.d.ts +35 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +251 -0
- package/dist/artifact.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +94 -4
- package/dist/cli.js.map +1 -1
- package/dist/domain/artifact-upload.d.ts +44 -0
- package/dist/domain/artifact-upload.d.ts.map +1 -0
- package/dist/domain/artifact-upload.js +80 -0
- package/dist/domain/artifact-upload.js.map +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/ports/artifact-host.d.ts +54 -0
- package/dist/ports/artifact-host.d.ts.map +1 -0
- package/dist/ports/artifact-host.js +2 -0
- package/dist/ports/artifact-host.js.map +1 -0
- package/dist/ports/latex.d.ts +9 -0
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/submission-confirm-hook.d.ts +11 -1
- package/dist/submission-confirm-hook.d.ts.map +1 -1
- package/dist/submission-confirm-hook.js +83 -21
- package/dist/submission-confirm-hook.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/artifact-upload.md +124 -0
- package/docs/optional-rules.md +1 -0
- package/docs/osf-artifact.md +4 -1
- package/docs/rules/artifact/upload-current.md +85 -0
- package/docs/rules.md +1 -0
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/package.json +1 -1
- package/src/adapters/latex/abstract.ts +3 -1
- package/src/adapters/latex/index.ts +3 -0
- package/src/adapters/latex/macros.test.ts +31 -0
- package/src/adapters/latex/macros.ts +43 -0
- package/src/adapters/osf/cassette/README.md +20 -0
- package/src/adapters/osf/cassette/get-file.json +108 -0
- package/src/adapters/osf/cassette/get-listing.json +111 -0
- package/src/adapters/osf/cassette/get-missing.json +1 -0
- package/src/adapters/osf/cassette/put-new.json +31 -0
- package/src/adapters/osf/host.io.ts +156 -0
- package/src/adapters/osf/host.test.ts +274 -0
- package/src/adapters/osf/index.ts +14 -0
- package/src/adapters/osf/response.ts +105 -0
- package/src/artifact-upload-rule.test.ts +213 -0
- package/src/artifact-upload-rule.ts +213 -0
- package/src/artifact.test.ts +504 -0
- package/src/artifact.ts +402 -0
- package/src/cli.test.ts +149 -1
- package/src/cli.ts +116 -5
- package/src/domain/artifact-upload.test.ts +80 -0
- package/src/domain/artifact-upload.ts +111 -0
- package/src/ports/artifact-host.ts +65 -0
- package/src/ports/latex.ts +10 -0
- package/src/rule-cases.test.ts +44 -0
- package/src/submission-confirm-hook.test.ts +113 -1
- package/src/submission-confirm-hook.ts +120 -27
- package/src/types.ts +6 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# artifact/upload-current
|
|
2
|
+
|
|
3
|
+
**OPT-IN: off unless you turn it on with its options.** **Level:** whatever you give it; `warn` is
|
|
4
|
+
meant · **Reads:** the paper's upload record (`submission/artifact-upload.json`), its numbers file,
|
|
5
|
+
`paper.tex` and the body files of the last build · **Reported on:** the first line of the paper's
|
|
6
|
+
`PIPELINE-STATUS.md`
|
|
7
|
+
|
|
8
|
+
## What it catches
|
|
9
|
+
|
|
10
|
+
The paper prints a number its uploaded artifact was not built for. The upload record
|
|
11
|
+
([format](../../artifact-upload.md)) holds the paper's number macros as they were when the artifact
|
|
12
|
+
was uploaded; the rule compares them with the numbers file now and reports, once:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
papers/my-paper/PIPELINE-STATUS.md
|
|
16
|
+
1:1 warning the paper prints 4 numbers the upload of 2026-11-01 (https://osf.io/abcde/) was not
|
|
17
|
+
built for: 3 new (nA, nB, nC), 1 changed (nRepos) — rebuild and upload the artifact,
|
|
18
|
+
then record it again (`paperlint artifact record <zip> --url <url>`)
|
|
19
|
+
artifact/upload-current
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Only the macros the paper's source uses count: a macro defined in the numbers file and printed
|
|
23
|
+
nowhere never fires. A key is _new_ when the record lacks it, _changed_ when the record holds
|
|
24
|
+
another value.
|
|
25
|
+
|
|
26
|
+
Turned on and missing what it needs, it says so once and judges nothing else: no `numbers` option;
|
|
27
|
+
the numbers file missing, or defining no macro without arguments; no record (it names
|
|
28
|
+
`paperlint artifact record`); a record that is not one (it says which field and why).
|
|
29
|
+
|
|
30
|
+
## Why
|
|
31
|
+
|
|
32
|
+
A reviewer runs the archive the paper links. When the paper's numbers move after the upload (a
|
|
33
|
+
rerun, a new study, a fixed bug), the archive reproduces numbers the paper no longer prints, and
|
|
34
|
+
nothing in the build says so. The record is the one fact that survives the upload: what the paper
|
|
35
|
+
printed when the archive was made.
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
Turning it on, in the paper's `paperlint.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"rules": {
|
|
44
|
+
"artifact/upload-current": ["warn", { "numbers": "numbersdef.tex" }]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Failing: `numbersdef.tex` says `\newcommand{\nRepos}{64}`, the body prints `\nRepos`, and the
|
|
50
|
+
record's `numbers` has `"nRepos": "63"`.
|
|
51
|
+
|
|
52
|
+
Passing: the record's `numbers` holds `"nRepos": "64"`; or the rule is not turned on.
|
|
53
|
+
|
|
54
|
+
## Options
|
|
55
|
+
|
|
56
|
+
| option | required | what |
|
|
57
|
+
| --------- | -------- | ----------------------------------------------------------------------------------- |
|
|
58
|
+
| `numbers` | yes | the paper's file of number macros, relative to the paper |
|
|
59
|
+
| `record` | no | the upload record, relative to the paper; default `submission/artifact-upload.json` |
|
|
60
|
+
|
|
61
|
+
The numbers file holds `\newcommand{\key}{value}` lines (`\newcommand*`, `\renewcommand`,
|
|
62
|
+
`\providecommand` and `\def\key{value}` too); a macro with arguments is skipped. A value is compared
|
|
63
|
+
as written in its definition, so `41.2\%` and `41.2 \%` differ.
|
|
64
|
+
|
|
65
|
+
## What it does not check
|
|
66
|
+
|
|
67
|
+
- **The host.** The rule never calls the network: it trusts the record. Whether the host still holds
|
|
68
|
+
the file the record names is `paperlint artifact show` (by hash, where the host gives one).
|
|
69
|
+
- **The archive's inside.** Whether the uploaded archive computes those numbers is not looked at;
|
|
70
|
+
the record says what the paper printed when it was uploaded, not what the archive produces.
|
|
71
|
+
- **Numbers typed into the prose.** A number not printed through a macro of the numbers file is
|
|
72
|
+
invisible here (opt-in `tex/claim-provenance` looks at those).
|
|
73
|
+
- **Uses outside the paper's files.** Uses are read in `paper.tex` and, when the last build's record
|
|
74
|
+
(`_build/sources.json`) is fresh, the body files it lists; with no record or a stale one,
|
|
75
|
+
`paper.tex` alone, and `paper/sources-fresh` says so.
|
|
76
|
+
- **Which definition TeX keeps.** A macro defined twice keeps its last definition here, whatever
|
|
77
|
+
the definer (`\providecommand` keeps the first in TeX).
|
|
78
|
+
|
|
79
|
+
## How to fix
|
|
80
|
+
|
|
81
|
+
Rebuild the artifact, upload it, and record the upload: `paperlint artifact record <zip> --url <url>`
|
|
82
|
+
(any host), or `paperlint artifact upload --to osf <zip> --save`, which writes the same record. Do
|
|
83
|
+
not re-record without uploading: the record would then claim an archive that was never built. If the
|
|
84
|
+
archive deliberately stays as it is, turn the rule off for the paper, or silence the finding with a
|
|
85
|
+
disable comment and its reason at the top of `PIPELINE-STATUS.md`.
|
package/docs/rules.md
CHANGED
|
@@ -22,6 +22,7 @@ reads and when it fails. Errors fail `paperlint lint`; warnings print and do not
|
|
|
22
22
|
| [`paper/edition-over`](rules/paper/edition-over.md) | warn | `paperlint.json` → the venue preset, and the clock | every deadline the paper's edition preset records has passed: the edition is over; names the newer editions of the series paperlint ships — [page](rules/paper/edition-over.md) |
|
|
23
23
|
| [`artifact/required-files`](rules/artifact/required-files.md) | error; silent without `artifact.required` | `paperlint.json` (`artifact`) → the artifact's folder or its committed list of paths | a name the paper requires at the artifact's top level (`README`, `LICENSE`; any extension) is not there, or the folder or list is missing — [page](rules/artifact/required-files.md) |
|
|
24
24
|
| [`artifact/promised`](rules/artifact/promised.md) | error; silent without `artifact.promises` | `paperlint.json` (`artifact`) → the artifact's folder or its committed list of paths | a promise of the paper (a label and a glob) matches no path of the artifact, or the folder or list is missing — [page](rules/artifact/promised.md) |
|
|
25
|
+
| [`artifact/upload-current`](rules/artifact/upload-current.md) | opt-in; off unless turned on with its options | the upload record and the paper's numbers file | the paper prints number macros its uploaded artifact was not built for (new keys, changed values), by the record written at upload; never calls the network — [page](rules/artifact/upload-current.md) |
|
|
25
26
|
| [`paper/allowed-files-only`](rules/paper/allowed-files-only.md) | error | the paper folder's root listing → `paperlint.json` | a file or folder at the paper's root is not part of the layout (`PLAN.md`, `archive/`, a stray PDF); reported on `PIPELINE-STATUS.md`, once per entry, with where it goes; `extra/` takes anything — [page](rules/paper/allowed-files-only.md) |
|
|
26
27
|
| [`repro/allowed-files-only`](rules/repro/allowed-files-only.md) | error | the listing of the paper's `repro/` | an entry at the top of `repro/` is not `README.md`, `studies.json`, `.gitignore`, `tools/`, `data/` or a study folder named `<id>-<slug>` (or, in a paper without the registry, `<slug>-YYYY-MM-DD`), or a study folder has no `README.md`; reported on `PIPELINE-STATUS.md`, once per entry, with where it goes by kind (a script → `repro/tools/`, data → `repro/data/`, a note → its study or `research/`) — [page](rules/repro/allowed-files-only.md) |
|
|
27
28
|
| [`repro/study-registered`](rules/repro/study-registered.md) | error | the listing of the paper's `repro/`, `repro/studies.json`, `repro/README.md`, each study's `plan.json` | a study folder with no row in `repro/studies.json`, a row whose folder is missing or not `<id>-<slug>`, a bad or repeated id, a title over 8 words, `done` without a result and an existing result file, `superseded` without an existing successor, a row naming a measurement the registry does not declare, a measurement with no study or an unknown requirement, a headline measurement not approved by the author, a plan that is missing, malformed or — once the study runs — unfilled, a headline study that has run without the author's check in its plan, or the index in `repro/README.md` out of sync with the registry; `paperlint studies new` and `paperlint studies index` write both — [page](rules/repro/study-registered.md) |
|
package/eslint-rules/CLAUDE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- vigiles:sha256:
|
|
1
|
+
<!-- vigiles:sha256:a24e4a23a4caaf86 compiled from eslint-rules/CLAUDE.md.spec.ts -->
|
|
2
2
|
|
|
3
3
|
# CLAUDE.md
|
|
4
4
|
|
|
@@ -43,3 +43,7 @@ the checks push every paper toward a blog post.
|
|
|
43
43
|
### Lint Rule Over Script
|
|
44
44
|
|
|
45
45
|
**Guidance only** — A check over a syntax tree is a lint rule, not a script. It fires in the editor on save, gets the AST for free, and has a suppression syntax people already know. A script is for corpus-wide questions — index connectivity, ratios across many files. When the work has to run a program, a script may do the work and write facts to a JSON file, and a rule judges that file: the verdict still lands in the engine.
|
|
46
|
+
|
|
47
|
+
### A Rule Is Configured The Eslint Way
|
|
48
|
+
|
|
49
|
+
**Guidance only** — Provisional, pending #599 (the author is not sure it is right). A rule's own switches (what to require, a threshold, a file to compare) come from its options where it is turned on: `["warn", { … }]`. A new rule is not on by default and silent until some key of `paperlint.json` is declared: that hides a check behind a setting nobody sees in the rule list. A fact several rules share about a paper (its venue, cycles, artifact, talk) reaches them through ESLint's `settings`, filled once by `buildConfig` from `paperlint.json`; a rule does not open `paperlint.json` itself. A rule whose subject IS `paperlint.json` (it validates the config) is exempt. Where an outside service varies (an artifact host, a portal), the rule reads a file of facts a command wrote and never the service; the services are adapters behind a port, as `src/ports/submission-portal.ts` and `src/adapters/hotcrp/` are, and eslint-plugin-import's `settings["import/resolver"]` is the ESLint precedent. About 25 existing rules predate this; #599 decides whether to move them, narrow this rule, or drop it and allow a rule to read `paperlint.json`. The author proposed this on 2026-11-21.
|
|
@@ -40,5 +40,8 @@ the checks push every paper toward a blog post.
|
|
|
40
40
|
"lint-rule-over-script": guidance(
|
|
41
41
|
"A check over a syntax tree is a lint rule, not a script. It fires in the editor on save, gets the AST for free, and has a suppression syntax people already know. A script is for corpus-wide questions — index connectivity, ratios across many files. When the work has to run a program, a script may do the work and write facts to a JSON file, and a rule judges that file: the verdict still lands in the engine.",
|
|
42
42
|
),
|
|
43
|
+
"a-rule-is-configured-the-eslint-way": guidance(
|
|
44
|
+
'Provisional, pending #599 (the author is not sure it is right). A rule\'s own switches (what to require, a threshold, a file to compare) come from its options where it is turned on: `["warn", { … }]`. A new rule is not on by default and silent until some key of `paperlint.json` is declared: that hides a check behind a setting nobody sees in the rule list. A fact several rules share about a paper (its venue, cycles, artifact, talk) reaches them through ESLint\'s `settings`, filled once by `buildConfig` from `paperlint.json`; a rule does not open `paperlint.json` itself. A rule whose subject IS `paperlint.json` (it validates the config) is exempt. Where an outside service varies (an artifact host, a portal), the rule reads a file of facts a command wrote and never the service; the services are adapters behind a port, as `src/ports/submission-portal.ts` and `src/adapters/hotcrp/` are, and eslint-plugin-import\'s `settings["import/resolver"]` is the ESLint precedent. About 25 existing rules predate this; #599 decides whether to move them, narrow this rule, or drop it and allow a rule to read `paperlint.json`. The author proposed this on 2026-11-21.',
|
|
45
|
+
),
|
|
43
46
|
},
|
|
44
47
|
});
|
package/package.json
CHANGED
|
@@ -77,7 +77,9 @@ function defDefinition(m: Macro): readonly [string, Definition["body"]][] {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** `\newcommand` and its kin, read by util-macros. */
|
|
80
|
-
function definitionOf(
|
|
80
|
+
export function definitionOf(
|
|
81
|
+
m: Macro,
|
|
82
|
+
): readonly [string, Definition["body"]][] {
|
|
81
83
|
if (DEF_MACROS.has(m.content)) return defDefinition(m);
|
|
82
84
|
// A \newcommand the parser gave no name has none here either: util-macros answers "".
|
|
83
85
|
const name = newcommandMatcher(m) ? newcommandMacroToName(m) : "";
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { citeKeysOf, macroTextsOf, registeredNumbersOf } from "./facts.ts";
|
|
34
34
|
import { captionProse } from "./captions.ts";
|
|
35
35
|
import { headingsOf } from "./headings.ts";
|
|
36
|
+
import { macroValuesOf, macrosUsedOf } from "./macros.ts";
|
|
36
37
|
import { documentBodyOf, includesOf } from "./includes.ts";
|
|
37
38
|
import { outlineOf } from "./outline.ts";
|
|
38
39
|
import { parseLatex } from "./parse.ts";
|
|
@@ -93,4 +94,6 @@ export const latexReader: LatexReader = {
|
|
|
93
94
|
citeKeys: (src) => citeKeysOf(parseLatex(src)),
|
|
94
95
|
registeredNumbers: registeredNumbersOf,
|
|
95
96
|
macroTexts: macroTextsOf,
|
|
97
|
+
macroValues: macroValuesOf,
|
|
98
|
+
macrosUsed: macrosUsedOf,
|
|
96
99
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { latexReader } from "./index.ts";
|
|
3
|
+
|
|
4
|
+
const NUMBERS = [
|
|
5
|
+
"\\newcommand{\\nRepos}{63}",
|
|
6
|
+
"\\newcommand*{\\pctPass}{ 41.2\\% }",
|
|
7
|
+
"\\def\\nRuns{7}",
|
|
8
|
+
"\\renewcommand\\nRepos{64}",
|
|
9
|
+
"\\newcommand{\\twice}[1]{#1#1}",
|
|
10
|
+
"% \\newcommand{\\commented}{1}",
|
|
11
|
+
].join("\n");
|
|
12
|
+
|
|
13
|
+
test("macroValues: each argument-less definition with its body as written, in source order", () => {
|
|
14
|
+
// Guards: \newcommand, \newcommand*, \def and \renewcommand read; one with arguments and one in a comment not.
|
|
15
|
+
expect(latexReader.macroValues(NUMBERS)).toEqual([
|
|
16
|
+
{ name: "nRepos", value: "63" },
|
|
17
|
+
{ name: "pctPass", value: "41.2\\%" },
|
|
18
|
+
{ name: "nRuns", value: "7" },
|
|
19
|
+
{ name: "nRepos", value: "64" },
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("macrosUsed: a name counts where it is used, not where it is defined", () => {
|
|
24
|
+
const src =
|
|
25
|
+
"\\newcommand{\\local}{x}\\newcommand{\\pct}{\\nRuns\\%}\n\\begin{document}\nWe saw \\nRepos{} repos, \\pct.\n% \\pctPass\n\\end{document}\n";
|
|
26
|
+
// Guards: \local is only defined; \nRuns counts through \pct's body; a comment holds no use;
|
|
27
|
+
// the definers and \% are macros too, which no numbers file defines.
|
|
28
|
+
expect([...latexReader.macrosUsed(src)].sort()).toEqual(
|
|
29
|
+
["%", "nRepos", "nRuns", "newcommand", "pct"].sort(),
|
|
30
|
+
);
|
|
31
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The author's own macros, read off the parse tree for `artifact/upload-current`: the value each
|
|
3
|
+
* argument-less one is defined to (`\newcommand`, `\newcommand*`, `\renewcommand`, `\providecommand`,
|
|
4
|
+
* `\def` and its kin), and the names a source uses. Pure.
|
|
5
|
+
*
|
|
6
|
+
* A value is the definition's body as written (`41.2\%`), not what TeX prints: two definitions that
|
|
7
|
+
* print alike but are written differently are two values. A name defined twice keeps its last value.
|
|
8
|
+
* A use is any occurrence of the name that is not its own definition, wherever it stands (a
|
|
9
|
+
* definition's body included): the name in `\newcommand{\x}` is not a use of `\x`.
|
|
10
|
+
*/
|
|
11
|
+
import { printRaw } from "@unified-latex/unified-latex-util-print-raw";
|
|
12
|
+
import { countBy } from "remeda";
|
|
13
|
+
import type { MacroValue } from "../../ports/latex.ts";
|
|
14
|
+
import { definitionOf } from "./abstract.ts";
|
|
15
|
+
import { isNode, visited, type Macro } from "./nodes.ts";
|
|
16
|
+
import { parseLatex } from "./parse.ts";
|
|
17
|
+
|
|
18
|
+
/** Every macro node of the source, in document order. */
|
|
19
|
+
const macrosIn = (src: string): readonly Macro[] =>
|
|
20
|
+
visited(parseLatex(src).root, () => false).flatMap((v) =>
|
|
21
|
+
isNode(v) && v.type === "macro" ? [v] : [],
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/** Each name `src` defines without arguments, and its body as written, in source order. */
|
|
25
|
+
export const macroValuesOf = (src: string): readonly MacroValue[] =>
|
|
26
|
+
macrosIn(src).flatMap((m) =>
|
|
27
|
+
definitionOf(m).flatMap(([name, body]) =>
|
|
28
|
+
body === null ? [] : [{ name, value: printRaw([...body]).trim() }],
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/** The names `src` uses: occurring more often than it defines them. */
|
|
33
|
+
export const macrosUsedOf = (src: string): readonly string[] => {
|
|
34
|
+
const macros = macrosIn(src);
|
|
35
|
+
const seen = countBy(macros, (m) => m.content);
|
|
36
|
+
const defined = countBy(
|
|
37
|
+
macros.flatMap((m) => definitionOf(m).map(([name]) => name)),
|
|
38
|
+
(n) => n,
|
|
39
|
+
);
|
|
40
|
+
return Object.entries(seen).flatMap(([n, c]) =>
|
|
41
|
+
c > (defined[n] ?? 0) ? [n] : [],
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# OSF cassette
|
|
2
|
+
|
|
3
|
+
Answers to the requests `paperlint artifact upload|show` sends, replayed by `host.test.ts` from a
|
|
4
|
+
local server on 127.0.0.1 and parsed by the adapter's real schemas: no test reaches OSF.
|
|
5
|
+
|
|
6
|
+
Recorded from the live API on 2026-11-21 without a token, from a public project (`curl`, read-only).
|
|
7
|
+
Identifying values are replaced with fakes of the same type — the project's guid (`abcde`), the
|
|
8
|
+
file's id, guid, name, size, dates and hashes (the hashes are those of the 15 bytes
|
|
9
|
+
`artifact bytes\n`, which the tests upload); OSF's keys, value types and statuses are verbatim.
|
|
10
|
+
|
|
11
|
+
| file | request | HTTP | how |
|
|
12
|
+
| ------------------ | ------------------------------------------------------------------------------------------ | ---: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
13
|
+
| `get-file.json` | `GET https://api.osf.io/v2/files/<id>/` | 200 | recorded |
|
|
14
|
+
| `get-listing.json` | `GET https://api.osf.io/v2/nodes/<guid>/files/osfstorage/?filter[name]=<name>` | 200 | recorded; the file's `guid` is `null`, as OSF answered for it |
|
|
15
|
+
| `get-missing.json` | `GET https://api.osf.io/v2/files/000000000000000000000000/` | 404 | recorded verbatim |
|
|
16
|
+
| `put-new.json` | `PUT https://files.osf.io/v1/resources/<guid>/providers/osfstorage/?kind=file&name=<name>` | 201 | **not recorded** (it needs a token and writes): written from WaterButler's source — `{"data": <entity>}`, `id` = provider + path, `path` = `/<id>`, `extra.hashes` |
|
|
17
|
+
|
|
18
|
+
To re-record the three reads: `curl -sS -g -o <file> '<url>'` against a public project, then fake
|
|
19
|
+
every identifying value. Recording `put-new.json` needs a project of your own and a token with
|
|
20
|
+
`osf.full_write`; replace its values the same way.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"id": "0123456789abcdef01234567",
|
|
4
|
+
"type": "files",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"guid": "fgh12",
|
|
7
|
+
"checkout": null,
|
|
8
|
+
"name": "artifact.zip",
|
|
9
|
+
"kind": "file",
|
|
10
|
+
"path": "/0123456789abcdef01234567",
|
|
11
|
+
"size": 15,
|
|
12
|
+
"provider": "osfstorage",
|
|
13
|
+
"materialized_path": "/artifact.zip",
|
|
14
|
+
"last_touched": null,
|
|
15
|
+
"date_modified": "2026-11-01T10:00:00.000000",
|
|
16
|
+
"date_created": "2026-11-01T10:00:00.000000Z",
|
|
17
|
+
"extra": {
|
|
18
|
+
"hashes": {
|
|
19
|
+
"md5": "3f395fbbb68716f38f5ff7fa9d740e3b",
|
|
20
|
+
"sha256": "59bd16dfc39e768f82bb8ec74467e571e80ed284683b586f077dbf1aa2483ecd"
|
|
21
|
+
},
|
|
22
|
+
"downloads": 1
|
|
23
|
+
},
|
|
24
|
+
"tags": [],
|
|
25
|
+
"current_user_can_comment": false,
|
|
26
|
+
"current_version": 1,
|
|
27
|
+
"show_as_unviewed": false
|
|
28
|
+
},
|
|
29
|
+
"relationships": {
|
|
30
|
+
"parent_folder": {
|
|
31
|
+
"links": {
|
|
32
|
+
"related": {
|
|
33
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef00000000/",
|
|
34
|
+
"meta": {}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"data": {
|
|
38
|
+
"id": "0123456789abcdef00000000",
|
|
39
|
+
"type": "files"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"versions": {
|
|
43
|
+
"links": {
|
|
44
|
+
"related": {
|
|
45
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef01234567/versions/",
|
|
46
|
+
"meta": {}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"comments": {
|
|
51
|
+
"links": {
|
|
52
|
+
"related": {
|
|
53
|
+
"href": "https://api.osf.io/v2/nodes/abcde/comments/?filter%5Btarget%5D=fgh12",
|
|
54
|
+
"meta": {}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"node": {
|
|
59
|
+
"links": {
|
|
60
|
+
"related": {
|
|
61
|
+
"href": "https://api.osf.io/v2/nodes/abcde/",
|
|
62
|
+
"meta": {}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"data": {
|
|
66
|
+
"id": "abcde",
|
|
67
|
+
"type": "nodes"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"target": {
|
|
71
|
+
"links": {
|
|
72
|
+
"related": {
|
|
73
|
+
"href": "https://api.osf.io/v2/nodes/abcde/",
|
|
74
|
+
"meta": {
|
|
75
|
+
"type": "nodes"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"data": {
|
|
80
|
+
"type": "nodes",
|
|
81
|
+
"id": "abcde"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"cedar_metadata_records": {
|
|
85
|
+
"links": {
|
|
86
|
+
"related": {
|
|
87
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef01234567/cedar_metadata_records/",
|
|
88
|
+
"meta": {}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"links": {
|
|
94
|
+
"info": "https://api.osf.io/v2/files/0123456789abcdef01234567/",
|
|
95
|
+
"move": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
96
|
+
"upload": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
97
|
+
"delete": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
98
|
+
"download": "https://osf.io/download/fgh12/",
|
|
99
|
+
"render": "https://mfr.osf.io/render?url=https%3A%2F%2Fosf.io%2Fdownload%2Ffgh12%2F%3Fdirect%26mode%3Drender",
|
|
100
|
+
"html": "https://osf.io/abcde/files/osfstorage/0123456789abcdef01234567",
|
|
101
|
+
"self": "https://api.osf.io/v2/files/0123456789abcdef01234567/",
|
|
102
|
+
"iri": "https://osf.io/fgh12"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"meta": {
|
|
106
|
+
"version": "2.0"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": "0123456789abcdef01234567",
|
|
5
|
+
"type": "files",
|
|
6
|
+
"attributes": {
|
|
7
|
+
"guid": null,
|
|
8
|
+
"checkout": null,
|
|
9
|
+
"name": "artifact.zip",
|
|
10
|
+
"kind": "file",
|
|
11
|
+
"path": "/0123456789abcdef01234567",
|
|
12
|
+
"size": 15,
|
|
13
|
+
"provider": "osfstorage",
|
|
14
|
+
"materialized_path": "/artifact.zip",
|
|
15
|
+
"last_touched": null,
|
|
16
|
+
"date_modified": "2026-11-01T10:00:00.000000",
|
|
17
|
+
"date_created": "2026-11-01T10:00:00.000000Z",
|
|
18
|
+
"extra": {
|
|
19
|
+
"hashes": {
|
|
20
|
+
"md5": "3f395fbbb68716f38f5ff7fa9d740e3b",
|
|
21
|
+
"sha256": "59bd16dfc39e768f82bb8ec74467e571e80ed284683b586f077dbf1aa2483ecd"
|
|
22
|
+
},
|
|
23
|
+
"downloads": 0
|
|
24
|
+
},
|
|
25
|
+
"tags": [],
|
|
26
|
+
"current_user_can_comment": false,
|
|
27
|
+
"current_version": 1,
|
|
28
|
+
"show_as_unviewed": false
|
|
29
|
+
},
|
|
30
|
+
"relationships": {
|
|
31
|
+
"parent_folder": {
|
|
32
|
+
"links": {
|
|
33
|
+
"related": {
|
|
34
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef00000000/",
|
|
35
|
+
"meta": {}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"data": {
|
|
39
|
+
"id": "0123456789abcdef00000000",
|
|
40
|
+
"type": "files"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"versions": {
|
|
44
|
+
"links": {
|
|
45
|
+
"related": {
|
|
46
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef01234567/versions/",
|
|
47
|
+
"meta": {}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"node": {
|
|
52
|
+
"links": {
|
|
53
|
+
"related": {
|
|
54
|
+
"href": "https://api.osf.io/v2/nodes/abcde/",
|
|
55
|
+
"meta": {}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"data": {
|
|
59
|
+
"id": "abcde",
|
|
60
|
+
"type": "nodes"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"target": {
|
|
64
|
+
"links": {
|
|
65
|
+
"related": {
|
|
66
|
+
"href": "https://api.osf.io/v2/nodes/abcde/",
|
|
67
|
+
"meta": {
|
|
68
|
+
"type": "nodes"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"data": {
|
|
73
|
+
"type": "nodes",
|
|
74
|
+
"id": "abcde"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"cedar_metadata_records": {
|
|
78
|
+
"links": {
|
|
79
|
+
"related": {
|
|
80
|
+
"href": "https://api.osf.io/v2/files/0123456789abcdef01234567/cedar_metadata_records/",
|
|
81
|
+
"meta": {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"links": {
|
|
87
|
+
"info": "https://api.osf.io/v2/files/0123456789abcdef01234567/",
|
|
88
|
+
"move": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
89
|
+
"upload": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
90
|
+
"delete": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
91
|
+
"download": "https://osf.io/download/0123456789abcdef01234567/",
|
|
92
|
+
"render": "https://mfr.osf.io/render?url=https%3A%2F%2Fosf.io%2Fdownload%2F0123456789abcdef01234567%2F%3Fdirect%26mode%3Drender",
|
|
93
|
+
"html": "https://osf.io/abcde/files/osfstorage/0123456789abcdef01234567",
|
|
94
|
+
"self": "https://api.osf.io/v2/files/0123456789abcdef01234567/"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"links": {
|
|
99
|
+
"first": null,
|
|
100
|
+
"last": null,
|
|
101
|
+
"prev": null,
|
|
102
|
+
"next": null,
|
|
103
|
+
"meta": {
|
|
104
|
+
"total": 1,
|
|
105
|
+
"per_page": 10
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"meta": {
|
|
109
|
+
"version": "2.0"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "errors": [{ "detail": "Not found." }], "meta": { "version": "2.0" } }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"id": "osfstorage/0123456789abcdef01234567",
|
|
4
|
+
"type": "files",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"extra": {
|
|
7
|
+
"guid": null,
|
|
8
|
+
"version": 1,
|
|
9
|
+
"downloads": 0,
|
|
10
|
+
"checkout": null,
|
|
11
|
+
"latestVersionSeen": null,
|
|
12
|
+
"hashes": {
|
|
13
|
+
"md5": "3f395fbbb68716f38f5ff7fa9d740e3b",
|
|
14
|
+
"sha256": "59bd16dfc39e768f82bb8ec74467e571e80ed284683b586f077dbf1aa2483ecd"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"kind": "file",
|
|
18
|
+
"name": "artifact.zip",
|
|
19
|
+
"path": "/0123456789abcdef01234567",
|
|
20
|
+
"provider": "osfstorage",
|
|
21
|
+
"materialized": "/artifact.zip",
|
|
22
|
+
"size": 15
|
|
23
|
+
},
|
|
24
|
+
"links": {
|
|
25
|
+
"move": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
26
|
+
"upload": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567?kind=file",
|
|
27
|
+
"delete": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567",
|
|
28
|
+
"download": "https://files.osf.io/v1/resources/abcde/providers/osfstorage/0123456789abcdef01234567"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|