@metacensus/library-research 0.14.0 → 0.15.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/README.md +29 -6
- package/dist/commands/add.js +29 -12
- package/dist/commands/dev.js +8 -3
- package/dist/commands/reshape.d.ts +2 -0
- package/dist/commands/reshape.js +21 -0
- package/dist/context.d.ts +3 -1
- package/dist/context.js +2 -0
- package/dist/corpus.d.ts +432 -0
- package/dist/corpus.js +348 -0
- package/dist/data.d.ts +5 -6
- package/dist/data.js +25 -13
- package/dist/datasets.d.ts +2 -1
- package/dist/datasets.js +15 -8
- package/dist/host.d.ts +3 -1
- package/dist/host.js +6 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/mount.d.ts +7 -3
- package/dist/mount.js +7 -7
- package/dist/papers.js +3 -2
- package/dist/playwright.d.ts +1 -1
- package/dist/playwright.js +24 -6
- package/dist/project-id.d.ts +4 -0
- package/dist/project-id.js +7 -0
- package/dist/react.d.ts +13 -20
- package/dist/react.js +45 -30
- package/dist/schema.d.ts +4 -34
- package/dist/schema.js +27 -31
- package/dist/testing.d.ts +1 -1
- package/dist/types.d.ts +47 -9
- package/dist/vite-config.js +2 -12
- package/dist/vite.d.ts +10 -2
- package/dist/vite.js +56 -6
- package/dist/zod.d.ts +2 -0
- package/dist/zod.js +4 -0
- package/package.json +11 -11
- package/schema/corpus.schema.json +3949 -29
- package/schema/project-id.schema.json +6 -0
- package/schema/research.schema.json +4 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A project is this layout, each path fixed, which `npx @metacensus/library-resear
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
research.json title, datasets, private datasets, roles and test people
|
|
11
|
-
corpus.json
|
|
11
|
+
corpus.json works by DOI or citation key: CSL-JSON, editions, papers by sha
|
|
12
12
|
papers/<sha>.<kind> through LFS
|
|
13
13
|
ui/package.json depends on @metacensus/library-research, which brings @playwright/test; scripts dev, check and test
|
|
14
14
|
ui/tsconfig.json extends @metacensus/library-research/tsconfig.json
|
|
@@ -25,8 +25,9 @@ From `ui/`:
|
|
|
25
25
|
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
26
|
| `npm run dev -- [--reader NAME] [--port N]` | serves the project at `/<path>/` and `ui/local/`'s at `/local/<path>/`, live from the files, as reader `NAME` (else `local`) to a context that names none, under the host's CSP |
|
|
27
27
|
| `npm run check` | gates the project, one line per failure, as a host's build does |
|
|
28
|
-
| `npx playwright test` | runs `browser/` in Chromium on a dev server; a CSP or
|
|
28
|
+
| `npx playwright test` | runs `browser/` in Chromium on a dev server; a CSP, WCAG 2.2, console-error or other-origin violation fails its spec unless `violations` lists it |
|
|
29
29
|
| `npx library-research add <file> [--title T] [--citation C] [--open]` | adds a paper to `papers/` and `corpus.json` |
|
|
30
|
+
| `npx library-research reshape` | rewrites a legacy `corpus.json`, one sha per paper, as works under placeholder keys, and prints what waits on a person |
|
|
30
31
|
| `npx library-research candidate` | runs `check`, then tags a clean `HEAD` on `origin/main` as `<id>-YYYY-MM-DD[.N]`, pushes it, and prints the service's `make pin` line |
|
|
31
32
|
|
|
32
33
|
## Rendering
|
|
@@ -37,11 +38,31 @@ A project renders in the browser only: the host is one single-page app and each
|
|
|
37
38
|
|
|
38
39
|
Each key of research.json's `data` is a dataset, and `ui/datasets.ts` exports `datasets`, one Zod schema per dataset over the dataset's whole value; a glob dataset's is a `z.record` keyed by what its wildcard matched. The UI parses with it and `check` fails, one line per record file, on data that does not. A dataset with no schema fails, and `corpus.json` is no dataset: library-research's `Corpus` parses it.
|
|
39
40
|
|
|
41
|
+
`defineProject` takes `datasets` as its third argument, and `useData('items')` and `useDatas(['items', 'decisions'])` return what each name's schema parses, with no parser at the call. A project registers the types by augmenting `Register` beside its `defineProject`:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// ui/datasets.ts
|
|
45
|
+
export const roles = ['author', 'leader'] as const
|
|
46
|
+
export const datasets = { items: z.record(z.string(), Item) /* … */ }
|
|
47
|
+
|
|
48
|
+
// ui/index.tsx
|
|
49
|
+
declare module '@metacensus/library-research' {
|
|
50
|
+
interface Register {
|
|
51
|
+
datasets: typeof datasets
|
|
52
|
+
roles: (typeof roles)[number]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
An undeclared name or a wrong result type then fails to compile. `roles` is the tuple research.json's `roles` copies: `check` fails when they differ.
|
|
58
|
+
|
|
59
|
+
A glob in `data` is relative, holds no `..`, at most one `*` and none of `?[]{}()!`; the grammar is in `schema/research.schema.json`.
|
|
60
|
+
|
|
40
61
|
## Private data
|
|
41
62
|
|
|
42
|
-
`research.json`'s `private` maps a dataset to a glob holding exactly one
|
|
63
|
+
`research.json`'s `private` maps a dataset to a glob holding exactly one `*` and otherwise the `data` grammar, such as `{ "private": { "ask": "research_notes/coauthors/*/questions.json" } }`. What the `*` matches is the page key, and the build emits each match at `/projects/<id>/private/<page>/<dataset>.json`, never among the shared `data/` files. A host serves that path only to the people who hold the page. A page key matches `^[a-z0-9][a-z0-9-]*$` and a dataset is in `data` or `private`, not both; `check` fails otherwise, naming the dataset.
|
|
43
64
|
|
|
44
|
-
`usePrivate(dataset
|
|
65
|
+
`usePrivate(dataset)` returns `{ page: parsed }` for the pages the host names for the person the project is viewed as: none, one or several, and a page not yet built is left out. `Object.values(usePrivate('ask'))` is that person's questions. The dataset's schema in `ui/datasets.ts` parses one page's file, and `load` returns the dataset as `{ page: parsed }`. A host's `private(dataset)` returns the page-to-URL map.
|
|
45
66
|
|
|
46
67
|
In `dev` and `testHost`, a reader holds the pages [`people`](#people) gives them, and `testHost`'s `private: { dataset: { page: json } }` holds each page's JSON.
|
|
47
68
|
|
|
@@ -51,14 +72,14 @@ Node loads `ui/datasets.ts` by stripping its types: no `enum` or namespace, rela
|
|
|
51
72
|
|
|
52
73
|
`research.json`'s optional `roles` lists the roles a person of the project holds one of, each matching `^[a-z][a-z0-9-]*$`, none repeated: `{ "roles": ["author", "leader"] }`.
|
|
53
74
|
|
|
54
|
-
- `useReader()` returns the host's `reader`, the person the project is viewed as: `{ username, name, role, self }`. `role` is one of `roles
|
|
75
|
+
- `useReader()` returns the host's `reader`, the person the project is viewed as: `{ username, name, role, self }`. `role` is one of `roles` (`Register`'s union where the project declares it), or null in a project that declares none. `self` is false while the host views the project as a person other than the one signed in.
|
|
55
76
|
- `useMembers()` returns the host's `members`, every person of the project, each `{ username, name, role }`.
|
|
56
77
|
|
|
57
78
|
In `dev` and `testHost`, `research.json`'s optional `people` stands in for production's people.json: it maps a username to `{ name, role, pages }`, `role` and `pages` optional, as `{ "people": { "dan.hertz": { "name": "Hertz", "role": "author", "pages": ["hertz"] } } }`. Every entry is a member. `dev --reader dan.hertz` and `testHost`'s `reader: 'dan.hertz'` serve that person as `reader` with `self` true, holding `hertz`'s page; another page answers 403. In a project that declares `roles`, a reader `people` omits is refused, naming them: by `testHost`, by `dev` before it serves when `--reader` names them, and by a `dev` page read as them, the default `local` included; in one that declares none, such a reader is served with their username as `name`, no role and no pages, and is no member. `check` fails, naming the person, on a role not in `roles`, on a person with no role where the project declares roles, and on a person with a role where it declares none. Production ignores `people`.
|
|
58
79
|
|
|
59
80
|
## Routes
|
|
60
81
|
|
|
61
|
-
A project default-exports `defineProject('<path>', routes)`: its first URL segment, matching `^[a-z0-9][a-z0-9-]*$` and not `projects`, `local` or `pdfjs` (dev and the host reserve them), and its routes created against the `parent` it is handed, a route at that path; the host owns the router. `Register` types the project's own links. A link names its path in full and passes `from="/<path>"`, so a wrong path fails to compile:
|
|
82
|
+
A project default-exports `defineProject('<path>', routes, datasets)`: its first URL segment, a project id matching `^[a-z0-9][a-z0-9-]*$` (`projectIdPattern` from `@metacensus/library-research/host`, and `schema/project-id.schema.json`) and not `projects`, `local` or `pdfjs` (dev and the host reserve them), and its routes created against the `parent` it is handed, a route at that path; the host owns the router. `Register` types the project's own links. A link names its path in full and passes `from="/<path>"`, so a wrong path fails to compile:
|
|
62
83
|
|
|
63
84
|
```tsx
|
|
64
85
|
const dpyd = defineProject('dpyd', (parent) => [
|
|
@@ -75,6 +96,8 @@ declare module '@tanstack/react-router' {
|
|
|
75
96
|
|
|
76
97
|
A host mounts each project with `mount(parent, project, options)` from `@metacensus/library-research/host`: it creates the route at the path the project names, with `options` as the route's options, adds the project's routes, and returns it. Two projects at one path are refused by TanStack's duplicate-route-id check, in development builds only.
|
|
77
98
|
|
|
99
|
+
A host builds with `research({ projects })` and `tailwind({ projects })` from `@metacensus/library-research/vite`, `projects` mapping each project's id to its directory: `plugins: [react(), research({ projects }), tailwind({ projects })]`. It builds with library-research's `tailwindcss` and `@tailwindcss/vite`, and carries neither of its own. The host's stylesheet opens with `@layer theme, base, mc, components, utilities;`, then `@import "tailwindcss";` and `@import "@metacensus/library-ui/theme.css";`; each project's `ui/` becomes a source of the stylesheet a module or `index.html` loads, not of one reached through a nested CSS `@import`. A project's stylesheets `@apply` Tailwind's and library-ui's utilities as they are.
|
|
100
|
+
|
|
78
101
|
`options` takes `frame(useHost)`, spread in: it provides the `Host` that `useHost` returns, shows a resettable error and an announced loading state. A host sets no `defaultPendingComponent` or `defaultErrorComponent` on its router, which would override the frame's for a project's routes. A host serves `@metacensus/library-research/csp.json` as its Content-Security-Policy (directive → sources, adding its own origins and nonces) and `pdfAssets`, `/pdfjs/`, for `configurePdf({ assets })`.
|
|
79
102
|
|
|
80
103
|
## Saving
|
package/dist/commands/add.js
CHANGED
|
@@ -2,10 +2,10 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { parseArgs } from 'node:util';
|
|
5
|
+
import { kinds, papers, placeholderOf, workOf } from '../corpus.js';
|
|
6
|
+
import { readCorpus, writeCorpus } from '../data.js';
|
|
5
7
|
import { git, kindOf, paperPath } from '../papers.js';
|
|
6
|
-
import { readCorpus } from '../data.js';
|
|
7
8
|
import { findRoot } from '../root.js';
|
|
8
|
-
import { Corpus, kinds } from '../schema.js';
|
|
9
9
|
export default function add(args) {
|
|
10
10
|
const { positionals, values } = parseArgs({
|
|
11
11
|
args,
|
|
@@ -29,19 +29,36 @@ export default function add(args) {
|
|
|
29
29
|
if (git(root, 'check-attr', 'filter', '--', path) !== `${path}: filter: lfs\n`)
|
|
30
30
|
throw new Error(`.gitattributes: papers/** doesn't go through LFS; run git lfs track 'papers/**'`);
|
|
31
31
|
const corpus = readCorpus(root);
|
|
32
|
-
const listed = corpus
|
|
33
|
-
if (listed && listed !== kind)
|
|
34
|
-
throw new Error(`${file}: already listed as ${paperPath(sha, listed)}`);
|
|
32
|
+
const listed = papers(corpus).get(sha);
|
|
33
|
+
if (listed && listed.paper.kind !== kind)
|
|
34
|
+
throw new Error(`${file}: already listed as ${paperPath(sha, listed.paper.kind)}`);
|
|
35
|
+
if (listed) {
|
|
36
|
+
const { work, paper } = listed;
|
|
37
|
+
const pending = new Set(work.pending);
|
|
38
|
+
if (values.title !== undefined) {
|
|
39
|
+
work.csl.title = values.title;
|
|
40
|
+
pending.delete('title');
|
|
41
|
+
}
|
|
42
|
+
if (values.citation !== undefined) {
|
|
43
|
+
work.csl.note = values.citation;
|
|
44
|
+
pending.add('note');
|
|
45
|
+
}
|
|
46
|
+
if (values.open)
|
|
47
|
+
paper.open = true;
|
|
48
|
+
work.pending = [...pending];
|
|
49
|
+
if (!pending.size)
|
|
50
|
+
delete work.pending;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const key = placeholderOf(sha);
|
|
54
|
+
if (corpus[key])
|
|
55
|
+
throw new Error(`${key}: already a work, and ${sha} shares its key`);
|
|
56
|
+
corpus[key] = workOf(sha, { kind, ...values });
|
|
57
|
+
}
|
|
35
58
|
mkdirSync(join(root, 'papers'), { recursive: true });
|
|
36
59
|
if (!existsSync(join(root, path)))
|
|
37
60
|
writeFileSync(join(root, path), bytes);
|
|
38
|
-
writeCorpus(root,
|
|
61
|
+
writeCorpus(root, corpus);
|
|
39
62
|
git(root, 'add', '--', path, 'corpus.json');
|
|
40
63
|
console.log(path);
|
|
41
64
|
}
|
|
42
|
-
function writeCorpus(root, corpus) {
|
|
43
|
-
const lines = Object.entries(Corpus.parse(corpus))
|
|
44
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
45
|
-
.map(([sha, paper]) => ` "${sha}": ${JSON.stringify(paper)}`);
|
|
46
|
-
writeFileSync(join(root, 'corpus.json'), `{\n${lines.join(',\n')}\n}\n`);
|
|
47
|
-
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -5,6 +5,7 @@ import { extname, join } from 'node:path';
|
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
7
|
import { createServer, mergeConfig } from 'vite';
|
|
8
|
+
import { papers as held } from '../corpus.js';
|
|
8
9
|
import { documentStore } from '../document-store.js';
|
|
9
10
|
import { paperPath } from '../papers.js';
|
|
10
11
|
import { project, read, readCorpus } from '../data.js';
|
|
@@ -87,10 +88,14 @@ function devHost(root, named) {
|
|
|
87
88
|
resolveId: (id) => ([entry, css].includes(id) ? '\0' + id : undefined),
|
|
88
89
|
load(id) {
|
|
89
90
|
if (id === '\0' + css)
|
|
90
|
-
return
|
|
91
|
+
return [
|
|
92
|
+
'@layer theme, base, mc, components, utilities;',
|
|
93
|
+
`@import 'tailwindcss';`,
|
|
94
|
+
`@import '@metacensus/library-ui/theme.css';`,
|
|
95
|
+
].join('\n');
|
|
91
96
|
if (id === '\0' + entry)
|
|
92
97
|
return [
|
|
93
|
-
// First, so
|
|
98
|
+
// First, so its layer line sets the order before library-ui's CSS declares `mc`.
|
|
94
99
|
`import '${css}'`,
|
|
95
100
|
`import '@metacensus/library-ui/fonts.css'`,
|
|
96
101
|
`import '@metacensus/library-ui/tokens.css'`,
|
|
@@ -164,7 +169,7 @@ function devHost(root, named) {
|
|
|
164
169
|
const sha = path?.match(papers)?.[1];
|
|
165
170
|
if (!sha)
|
|
166
171
|
return next();
|
|
167
|
-
const kind = readCorpus(root)
|
|
172
|
+
const kind = held(readCorpus(root)).get(sha)?.paper.kind;
|
|
168
173
|
if (!kind)
|
|
169
174
|
return notFound(res, `${sha}: not in corpus.json`);
|
|
170
175
|
const file = paperPath(sha, kind);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import * as loader from '../corpus.js';
|
|
3
|
+
import { read, readCorpus, writeCorpus } from '../data.js';
|
|
4
|
+
import { findRoot } from '../root.js';
|
|
5
|
+
/** Rewrites a legacy corpus.json in the new shape, leaving one already in it, and prints what waits on a person. */
|
|
6
|
+
export default function reshape(args) {
|
|
7
|
+
parseArgs({ args });
|
|
8
|
+
const root = findRoot(process.cwd());
|
|
9
|
+
let corpus;
|
|
10
|
+
try {
|
|
11
|
+
corpus = readCorpus(root);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const legacy = loader.LegacyCorpus.safeParse(read(root, 'corpus.json'));
|
|
15
|
+
if (!legacy.success)
|
|
16
|
+
throw error;
|
|
17
|
+
corpus = loader.reshape(legacy.data).corpus;
|
|
18
|
+
writeCorpus(root, corpus);
|
|
19
|
+
}
|
|
20
|
+
console.log(JSON.stringify(loader.pending(corpus), null, 2));
|
|
21
|
+
}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Host } from './types.js';
|
|
1
|
+
import type { Host, Schema } from './types.js';
|
|
2
2
|
export declare const HostContext: import("react").Context<Host | null>;
|
|
3
3
|
/** Where the document hooks fetch from; the test host sets its in-memory store, a host leaves the global. */
|
|
4
4
|
export declare const FetchContext: import("react").Context<typeof fetch | null>;
|
|
5
|
+
/** The schemas `defineProject` was given, which `useData` and `usePrivate` look a dataset up in. */
|
|
6
|
+
export declare const DatasetsContext: import("react").Context<Record<string, Schema>>;
|
package/dist/context.js
CHANGED
|
@@ -2,3 +2,5 @@ import { createContext } from 'react';
|
|
|
2
2
|
export const HostContext = createContext(null);
|
|
3
3
|
/** Where the document hooks fetch from; the test host sets its in-memory store, a host leaves the global. */
|
|
4
4
|
export const FetchContext = createContext(null);
|
|
5
|
+
/** The schemas `defineProject` was given, which `useData` and `usePrivate` look a dataset up in. */
|
|
6
|
+
export const DatasetsContext = createContext({});
|
package/dist/corpus.d.ts
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { z } from './zod.js';
|
|
2
|
+
export declare const kinds: {
|
|
3
|
+
readonly pdf: "application/pdf";
|
|
4
|
+
readonly doc: "application/msword";
|
|
5
|
+
readonly docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
6
|
+
readonly xls: "application/vnd.ms-excel";
|
|
7
|
+
readonly xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
8
|
+
readonly zip: "application/zip";
|
|
9
|
+
readonly gif: "image/gif";
|
|
10
|
+
readonly jpg: "image/jpeg";
|
|
11
|
+
readonly tif: "image/tiff";
|
|
12
|
+
readonly txt: "text/plain";
|
|
13
|
+
readonly html: "text/plain";
|
|
14
|
+
readonly xml: "text/plain";
|
|
15
|
+
};
|
|
16
|
+
declare const names: readonly ["author", "chair", "collection-editor", "compiler", "composer", "container-author", "contributor", "curator", "director", "editor", "editorial-director", "executive-producer", "guest", "host", "illustrator", "interviewer", "narrator", "organizer", "original-author", "performer", "producer", "recipient", "reviewed-author", "script-writer", "series-creator", "translator"];
|
|
17
|
+
declare const dates: readonly ["accessed", "available-date", "event-date", "issued", "original-date", "submitted"];
|
|
18
|
+
declare const numbers: readonly ["chapter-number", "citation-number", "collection-number", "edition", "first-reference-note-number", "issue", "number", "number-of-pages", "number-of-volumes", "page", "page-first", "part", "printing", "supplement", "version", "volume"];
|
|
19
|
+
declare const strings: readonly ["abstract", "annote", "archive", "archive_collection", "archive_location", "archive-place", "authority", "call-number", "citation-label", "collection-title", "container-title", "container-title-short", "dimensions", "division", "event", "event-place", "event-title", "genre", "ISBN", "ISSN", "journalAbbreviation", "jurisdiction", "keyword", "language", "locator", "medium", "note", "original-publisher", "original-publisher-place", "original-title", "part-title", "PMCID", "PMID", "publisher", "publisher-place", "references", "reviewed-genre", "reviewed-title", "scale", "section", "shortTitle", "source", "status", "title", "title-short", "URL", "volume-title", "volume-title-short", "year-suffix"];
|
|
20
|
+
declare const name: z.ZodArray<z.ZodObject<{
|
|
21
|
+
family: z.ZodOptional<z.ZodString>;
|
|
22
|
+
given: z.ZodOptional<z.ZodString>;
|
|
23
|
+
'dropping-particle': z.ZodOptional<z.ZodString>;
|
|
24
|
+
'non-dropping-particle': z.ZodOptional<z.ZodString>;
|
|
25
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
26
|
+
'comma-suffix': z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
27
|
+
'static-ordering': z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
28
|
+
literal: z.ZodOptional<z.ZodString>;
|
|
29
|
+
'parse-names': z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
30
|
+
}, z.core.$strict>>;
|
|
31
|
+
declare const date: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
32
|
+
'date-parts': z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>>;
|
|
33
|
+
season: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
34
|
+
circa: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
35
|
+
literal: z.ZodOptional<z.ZodString>;
|
|
36
|
+
raw: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strict>]>;
|
|
38
|
+
declare const number: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
39
|
+
declare const string: z.ZodString;
|
|
40
|
+
type Variables<K extends string, T extends z.ZodType> = {
|
|
41
|
+
[P in K]: z.ZodOptional<T>;
|
|
42
|
+
};
|
|
43
|
+
declare const base: {
|
|
44
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
article: "article";
|
|
46
|
+
"article-journal": "article-journal";
|
|
47
|
+
"article-magazine": "article-magazine";
|
|
48
|
+
"article-newspaper": "article-newspaper";
|
|
49
|
+
bill: "bill";
|
|
50
|
+
book: "book";
|
|
51
|
+
broadcast: "broadcast";
|
|
52
|
+
chapter: "chapter";
|
|
53
|
+
classic: "classic";
|
|
54
|
+
collection: "collection";
|
|
55
|
+
dataset: "dataset";
|
|
56
|
+
document: "document";
|
|
57
|
+
entry: "entry";
|
|
58
|
+
"entry-dictionary": "entry-dictionary";
|
|
59
|
+
"entry-encyclopedia": "entry-encyclopedia";
|
|
60
|
+
event: "event";
|
|
61
|
+
figure: "figure";
|
|
62
|
+
graphic: "graphic";
|
|
63
|
+
hearing: "hearing";
|
|
64
|
+
interview: "interview";
|
|
65
|
+
legal_case: "legal_case";
|
|
66
|
+
legislation: "legislation";
|
|
67
|
+
manuscript: "manuscript";
|
|
68
|
+
map: "map";
|
|
69
|
+
motion_picture: "motion_picture";
|
|
70
|
+
musical_score: "musical_score";
|
|
71
|
+
pamphlet: "pamphlet";
|
|
72
|
+
"paper-conference": "paper-conference";
|
|
73
|
+
patent: "patent";
|
|
74
|
+
performance: "performance";
|
|
75
|
+
periodical: "periodical";
|
|
76
|
+
personal_communication: "personal_communication";
|
|
77
|
+
post: "post";
|
|
78
|
+
"post-weblog": "post-weblog";
|
|
79
|
+
regulation: "regulation";
|
|
80
|
+
report: "report";
|
|
81
|
+
review: "review";
|
|
82
|
+
"review-book": "review-book";
|
|
83
|
+
software: "software";
|
|
84
|
+
song: "song";
|
|
85
|
+
speech: "speech";
|
|
86
|
+
standard: "standard";
|
|
87
|
+
thesis: "thesis";
|
|
88
|
+
treaty: "treaty";
|
|
89
|
+
webpage: "webpage";
|
|
90
|
+
}>>;
|
|
91
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
92
|
+
custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
93
|
+
};
|
|
94
|
+
type CslShape = typeof base & Variables<(typeof names)[number], typeof name> & Variables<(typeof dates)[number], typeof date> & Variables<(typeof numbers)[number], typeof number> & Variables<(typeof strings)[number], typeof string>;
|
|
95
|
+
export declare const Csl: z.ZodObject<CslShape, z.core.$strict>;
|
|
96
|
+
type Field = keyof CslShape;
|
|
97
|
+
export declare const Paper: z.ZodObject<{
|
|
98
|
+
kind: z.ZodEnum<{
|
|
99
|
+
pdf: "pdf";
|
|
100
|
+
doc: "doc";
|
|
101
|
+
docx: "docx";
|
|
102
|
+
xls: "xls";
|
|
103
|
+
xlsx: "xlsx";
|
|
104
|
+
zip: "zip";
|
|
105
|
+
gif: "gif";
|
|
106
|
+
jpg: "jpg";
|
|
107
|
+
tif: "tif";
|
|
108
|
+
txt: "txt";
|
|
109
|
+
html: "html";
|
|
110
|
+
xml: "xml";
|
|
111
|
+
}>;
|
|
112
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
export declare const Edition: z.ZodObject<{
|
|
115
|
+
csl: z.ZodOptional<z.ZodObject<CslShape, z.core.$strict>>;
|
|
116
|
+
papers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
117
|
+
kind: z.ZodEnum<{
|
|
118
|
+
pdf: "pdf";
|
|
119
|
+
doc: "doc";
|
|
120
|
+
docx: "docx";
|
|
121
|
+
xls: "xls";
|
|
122
|
+
xlsx: "xlsx";
|
|
123
|
+
zip: "zip";
|
|
124
|
+
gif: "gif";
|
|
125
|
+
jpg: "jpg";
|
|
126
|
+
tif: "tif";
|
|
127
|
+
txt: "txt";
|
|
128
|
+
html: "html";
|
|
129
|
+
xml: "xml";
|
|
130
|
+
}>;
|
|
131
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
132
|
+
}, z.core.$strict>>;
|
|
133
|
+
}, z.core.$strict>;
|
|
134
|
+
export declare const Work: z.ZodObject<{
|
|
135
|
+
csl: z.ZodObject<CslShape, z.core.$strict>;
|
|
136
|
+
editions: z.ZodArray<z.ZodObject<{
|
|
137
|
+
csl: z.ZodOptional<z.ZodObject<CslShape, z.core.$strict>>;
|
|
138
|
+
papers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
139
|
+
kind: z.ZodEnum<{
|
|
140
|
+
pdf: "pdf";
|
|
141
|
+
doc: "doc";
|
|
142
|
+
docx: "docx";
|
|
143
|
+
xls: "xls";
|
|
144
|
+
xlsx: "xlsx";
|
|
145
|
+
zip: "zip";
|
|
146
|
+
gif: "gif";
|
|
147
|
+
jpg: "jpg";
|
|
148
|
+
tif: "tif";
|
|
149
|
+
txt: "txt";
|
|
150
|
+
html: "html";
|
|
151
|
+
xml: "xml";
|
|
152
|
+
}>;
|
|
153
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
154
|
+
}, z.core.$strict>>;
|
|
155
|
+
}, z.core.$strict>>;
|
|
156
|
+
pending: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
157
|
+
number: "number";
|
|
158
|
+
type: "type";
|
|
159
|
+
event: "event";
|
|
160
|
+
author: "author";
|
|
161
|
+
chair: "chair";
|
|
162
|
+
"collection-editor": "collection-editor";
|
|
163
|
+
compiler: "compiler";
|
|
164
|
+
composer: "composer";
|
|
165
|
+
"container-author": "container-author";
|
|
166
|
+
contributor: "contributor";
|
|
167
|
+
curator: "curator";
|
|
168
|
+
director: "director";
|
|
169
|
+
editor: "editor";
|
|
170
|
+
"editorial-director": "editorial-director";
|
|
171
|
+
"executive-producer": "executive-producer";
|
|
172
|
+
guest: "guest";
|
|
173
|
+
host: "host";
|
|
174
|
+
illustrator: "illustrator";
|
|
175
|
+
interviewer: "interviewer";
|
|
176
|
+
narrator: "narrator";
|
|
177
|
+
organizer: "organizer";
|
|
178
|
+
"original-author": "original-author";
|
|
179
|
+
performer: "performer";
|
|
180
|
+
producer: "producer";
|
|
181
|
+
recipient: "recipient";
|
|
182
|
+
"reviewed-author": "reviewed-author";
|
|
183
|
+
"script-writer": "script-writer";
|
|
184
|
+
"series-creator": "series-creator";
|
|
185
|
+
translator: "translator";
|
|
186
|
+
accessed: "accessed";
|
|
187
|
+
"available-date": "available-date";
|
|
188
|
+
"event-date": "event-date";
|
|
189
|
+
issued: "issued";
|
|
190
|
+
"original-date": "original-date";
|
|
191
|
+
submitted: "submitted";
|
|
192
|
+
"chapter-number": "chapter-number";
|
|
193
|
+
"citation-number": "citation-number";
|
|
194
|
+
"collection-number": "collection-number";
|
|
195
|
+
edition: "edition";
|
|
196
|
+
"first-reference-note-number": "first-reference-note-number";
|
|
197
|
+
issue: "issue";
|
|
198
|
+
"number-of-pages": "number-of-pages";
|
|
199
|
+
"number-of-volumes": "number-of-volumes";
|
|
200
|
+
page: "page";
|
|
201
|
+
"page-first": "page-first";
|
|
202
|
+
part: "part";
|
|
203
|
+
printing: "printing";
|
|
204
|
+
supplement: "supplement";
|
|
205
|
+
version: "version";
|
|
206
|
+
volume: "volume";
|
|
207
|
+
abstract: "abstract";
|
|
208
|
+
annote: "annote";
|
|
209
|
+
archive: "archive";
|
|
210
|
+
archive_collection: "archive_collection";
|
|
211
|
+
archive_location: "archive_location";
|
|
212
|
+
"archive-place": "archive-place";
|
|
213
|
+
authority: "authority";
|
|
214
|
+
"call-number": "call-number";
|
|
215
|
+
"citation-label": "citation-label";
|
|
216
|
+
"collection-title": "collection-title";
|
|
217
|
+
"container-title": "container-title";
|
|
218
|
+
"container-title-short": "container-title-short";
|
|
219
|
+
dimensions: "dimensions";
|
|
220
|
+
division: "division";
|
|
221
|
+
"event-place": "event-place";
|
|
222
|
+
"event-title": "event-title";
|
|
223
|
+
genre: "genre";
|
|
224
|
+
ISBN: "ISBN";
|
|
225
|
+
ISSN: "ISSN";
|
|
226
|
+
journalAbbreviation: "journalAbbreviation";
|
|
227
|
+
jurisdiction: "jurisdiction";
|
|
228
|
+
keyword: "keyword";
|
|
229
|
+
language: "language";
|
|
230
|
+
locator: "locator";
|
|
231
|
+
medium: "medium";
|
|
232
|
+
note: "note";
|
|
233
|
+
"original-publisher": "original-publisher";
|
|
234
|
+
"original-publisher-place": "original-publisher-place";
|
|
235
|
+
"original-title": "original-title";
|
|
236
|
+
"part-title": "part-title";
|
|
237
|
+
PMCID: "PMCID";
|
|
238
|
+
PMID: "PMID";
|
|
239
|
+
publisher: "publisher";
|
|
240
|
+
"publisher-place": "publisher-place";
|
|
241
|
+
references: "references";
|
|
242
|
+
"reviewed-genre": "reviewed-genre";
|
|
243
|
+
"reviewed-title": "reviewed-title";
|
|
244
|
+
scale: "scale";
|
|
245
|
+
section: "section";
|
|
246
|
+
shortTitle: "shortTitle";
|
|
247
|
+
source: "source";
|
|
248
|
+
status: "status";
|
|
249
|
+
title: "title";
|
|
250
|
+
"title-short": "title-short";
|
|
251
|
+
URL: "URL";
|
|
252
|
+
"volume-title": "volume-title";
|
|
253
|
+
"volume-title-short": "volume-title-short";
|
|
254
|
+
"year-suffix": "year-suffix";
|
|
255
|
+
custom: "custom";
|
|
256
|
+
categories: "categories";
|
|
257
|
+
}>>>;
|
|
258
|
+
}, z.core.$strict>;
|
|
259
|
+
export declare const Corpus: z.ZodRecord<z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodString]>, z.ZodObject<{
|
|
260
|
+
csl: z.ZodObject<CslShape, z.core.$strict>;
|
|
261
|
+
editions: z.ZodArray<z.ZodObject<{
|
|
262
|
+
csl: z.ZodOptional<z.ZodObject<CslShape, z.core.$strict>>;
|
|
263
|
+
papers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
264
|
+
kind: z.ZodEnum<{
|
|
265
|
+
pdf: "pdf";
|
|
266
|
+
doc: "doc";
|
|
267
|
+
docx: "docx";
|
|
268
|
+
xls: "xls";
|
|
269
|
+
xlsx: "xlsx";
|
|
270
|
+
zip: "zip";
|
|
271
|
+
gif: "gif";
|
|
272
|
+
jpg: "jpg";
|
|
273
|
+
tif: "tif";
|
|
274
|
+
txt: "txt";
|
|
275
|
+
html: "html";
|
|
276
|
+
xml: "xml";
|
|
277
|
+
}>;
|
|
278
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
279
|
+
}, z.core.$strict>>;
|
|
280
|
+
}, z.core.$strict>>;
|
|
281
|
+
pending: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
282
|
+
number: "number";
|
|
283
|
+
type: "type";
|
|
284
|
+
event: "event";
|
|
285
|
+
author: "author";
|
|
286
|
+
chair: "chair";
|
|
287
|
+
"collection-editor": "collection-editor";
|
|
288
|
+
compiler: "compiler";
|
|
289
|
+
composer: "composer";
|
|
290
|
+
"container-author": "container-author";
|
|
291
|
+
contributor: "contributor";
|
|
292
|
+
curator: "curator";
|
|
293
|
+
director: "director";
|
|
294
|
+
editor: "editor";
|
|
295
|
+
"editorial-director": "editorial-director";
|
|
296
|
+
"executive-producer": "executive-producer";
|
|
297
|
+
guest: "guest";
|
|
298
|
+
host: "host";
|
|
299
|
+
illustrator: "illustrator";
|
|
300
|
+
interviewer: "interviewer";
|
|
301
|
+
narrator: "narrator";
|
|
302
|
+
organizer: "organizer";
|
|
303
|
+
"original-author": "original-author";
|
|
304
|
+
performer: "performer";
|
|
305
|
+
producer: "producer";
|
|
306
|
+
recipient: "recipient";
|
|
307
|
+
"reviewed-author": "reviewed-author";
|
|
308
|
+
"script-writer": "script-writer";
|
|
309
|
+
"series-creator": "series-creator";
|
|
310
|
+
translator: "translator";
|
|
311
|
+
accessed: "accessed";
|
|
312
|
+
"available-date": "available-date";
|
|
313
|
+
"event-date": "event-date";
|
|
314
|
+
issued: "issued";
|
|
315
|
+
"original-date": "original-date";
|
|
316
|
+
submitted: "submitted";
|
|
317
|
+
"chapter-number": "chapter-number";
|
|
318
|
+
"citation-number": "citation-number";
|
|
319
|
+
"collection-number": "collection-number";
|
|
320
|
+
edition: "edition";
|
|
321
|
+
"first-reference-note-number": "first-reference-note-number";
|
|
322
|
+
issue: "issue";
|
|
323
|
+
"number-of-pages": "number-of-pages";
|
|
324
|
+
"number-of-volumes": "number-of-volumes";
|
|
325
|
+
page: "page";
|
|
326
|
+
"page-first": "page-first";
|
|
327
|
+
part: "part";
|
|
328
|
+
printing: "printing";
|
|
329
|
+
supplement: "supplement";
|
|
330
|
+
version: "version";
|
|
331
|
+
volume: "volume";
|
|
332
|
+
abstract: "abstract";
|
|
333
|
+
annote: "annote";
|
|
334
|
+
archive: "archive";
|
|
335
|
+
archive_collection: "archive_collection";
|
|
336
|
+
archive_location: "archive_location";
|
|
337
|
+
"archive-place": "archive-place";
|
|
338
|
+
authority: "authority";
|
|
339
|
+
"call-number": "call-number";
|
|
340
|
+
"citation-label": "citation-label";
|
|
341
|
+
"collection-title": "collection-title";
|
|
342
|
+
"container-title": "container-title";
|
|
343
|
+
"container-title-short": "container-title-short";
|
|
344
|
+
dimensions: "dimensions";
|
|
345
|
+
division: "division";
|
|
346
|
+
"event-place": "event-place";
|
|
347
|
+
"event-title": "event-title";
|
|
348
|
+
genre: "genre";
|
|
349
|
+
ISBN: "ISBN";
|
|
350
|
+
ISSN: "ISSN";
|
|
351
|
+
journalAbbreviation: "journalAbbreviation";
|
|
352
|
+
jurisdiction: "jurisdiction";
|
|
353
|
+
keyword: "keyword";
|
|
354
|
+
language: "language";
|
|
355
|
+
locator: "locator";
|
|
356
|
+
medium: "medium";
|
|
357
|
+
note: "note";
|
|
358
|
+
"original-publisher": "original-publisher";
|
|
359
|
+
"original-publisher-place": "original-publisher-place";
|
|
360
|
+
"original-title": "original-title";
|
|
361
|
+
"part-title": "part-title";
|
|
362
|
+
PMCID: "PMCID";
|
|
363
|
+
PMID: "PMID";
|
|
364
|
+
publisher: "publisher";
|
|
365
|
+
"publisher-place": "publisher-place";
|
|
366
|
+
references: "references";
|
|
367
|
+
"reviewed-genre": "reviewed-genre";
|
|
368
|
+
"reviewed-title": "reviewed-title";
|
|
369
|
+
scale: "scale";
|
|
370
|
+
section: "section";
|
|
371
|
+
shortTitle: "shortTitle";
|
|
372
|
+
source: "source";
|
|
373
|
+
status: "status";
|
|
374
|
+
title: "title";
|
|
375
|
+
"title-short": "title-short";
|
|
376
|
+
URL: "URL";
|
|
377
|
+
"volume-title": "volume-title";
|
|
378
|
+
"volume-title-short": "volume-title-short";
|
|
379
|
+
"year-suffix": "year-suffix";
|
|
380
|
+
custom: "custom";
|
|
381
|
+
categories: "categories";
|
|
382
|
+
}>>>;
|
|
383
|
+
}, z.core.$strict>>;
|
|
384
|
+
/** The corpus before works: one entry per file, by sha. */
|
|
385
|
+
export declare const LegacyCorpus: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
386
|
+
kind: z.ZodEnum<{
|
|
387
|
+
pdf: "pdf";
|
|
388
|
+
doc: "doc";
|
|
389
|
+
docx: "docx";
|
|
390
|
+
xls: "xls";
|
|
391
|
+
xlsx: "xlsx";
|
|
392
|
+
zip: "zip";
|
|
393
|
+
gif: "gif";
|
|
394
|
+
jpg: "jpg";
|
|
395
|
+
tif: "tif";
|
|
396
|
+
txt: "txt";
|
|
397
|
+
html: "html";
|
|
398
|
+
xml: "xml";
|
|
399
|
+
}>;
|
|
400
|
+
title: z.ZodOptional<z.ZodString>;
|
|
401
|
+
citation: z.ZodOptional<z.ZodString>;
|
|
402
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
403
|
+
}, z.core.$strict>>;
|
|
404
|
+
type Corpus = z.infer<typeof Corpus>;
|
|
405
|
+
type Work = z.infer<typeof Work>;
|
|
406
|
+
type Legacy = Omit<z.infer<typeof LegacyCorpus>[string], 'open'> & {
|
|
407
|
+
open?: boolean;
|
|
408
|
+
};
|
|
409
|
+
type Judgment = {
|
|
410
|
+
work: string;
|
|
411
|
+
shas: string[];
|
|
412
|
+
judgment: Field | 'key';
|
|
413
|
+
};
|
|
414
|
+
/** Every held file by sha, with the work and edition holding it. */
|
|
415
|
+
export declare function papers(corpus: Corpus): Map<string, {
|
|
416
|
+
key: string;
|
|
417
|
+
work: Work;
|
|
418
|
+
edition: Work["editions"][number];
|
|
419
|
+
paper: z.infer<typeof Paper>;
|
|
420
|
+
}>;
|
|
421
|
+
/** What waits on a person: each placeholder's key, and each pending field. */
|
|
422
|
+
export declare function pending(corpus: Corpus): Judgment[];
|
|
423
|
+
/** The placeholder key of the file `sha`. */
|
|
424
|
+
export declare const placeholderOf: (sha: string) => string;
|
|
425
|
+
/** One legacy entry as a work of one edition, judging nothing. */
|
|
426
|
+
export declare function workOf(sha: string, { kind, title, citation, open }: Legacy): Work;
|
|
427
|
+
/** Today's corpus in the new shape, one work per sha, and the judgments it leaves. */
|
|
428
|
+
export declare function reshape(legacy: z.infer<typeof LegacyCorpus>): {
|
|
429
|
+
corpus: Corpus;
|
|
430
|
+
judgments: Judgment[];
|
|
431
|
+
};
|
|
432
|
+
export {};
|