@alisio/plugin-thesis 0.1.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/.agents/agents/thesis-architect.md +38 -0
- package/.agents/agents/thesis-coordinator.md +39 -0
- package/.agents/agents/thesis-editor.md +35 -0
- package/.agents/agents/thesis-evidence-auditor.md +37 -0
- package/.agents/agents/thesis-librarian.md +38 -0
- package/.agents/agents/thesis-methodologist.md +39 -0
- package/.agents/agents/thesis-reviewer.md +36 -0
- package/.agents/agents/thesis-writer.md +38 -0
- package/.agents/skills/thesis-build/SKILL.md +48 -0
- package/.agents/skills/thesis-citations/SKILL.md +49 -0
- package/.agents/skills/thesis-csl-authoring/SKILL.md +48 -0
- package/.agents/skills/thesis-editing/SKILL.md +49 -0
- package/.agents/skills/thesis-evidence/SKILL.md +48 -0
- package/.agents/skills/thesis-figures/SKILL.md +50 -0
- package/.agents/skills/thesis-institution-norms/SKILL.md +50 -0
- package/.agents/skills/thesis-intake/SKILL.md +48 -0
- package/.agents/skills/thesis-math/SKILL.md +48 -0
- package/.agents/skills/thesis-methodology/SKILL.md +49 -0
- package/.agents/skills/thesis-outline/SKILL.md +48 -0
- package/.agents/skills/thesis-policy/SKILL.md +48 -0
- package/.agents/skills/thesis-review/SKILL.md +49 -0
- package/.agents/skills/thesis-search/SKILL.md +47 -0
- package/.agents/skills/thesis-writing/SKILL.md +52 -0
- package/LICENSE +21 -0
- package/README.es.md +242 -0
- package/README.md +235 -0
- package/THIRD_PARTY_NOTICES.md +94 -0
- package/assets/architecture.svg +1 -0
- package/assets/evidence-pipeline.svg +1 -0
- package/assets/lifecycle.svg +1 -0
- package/assets/policy-resolution.svg +1 -0
- package/cover.webp +0 -0
- package/dist/authoring.d.ts +30 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +681 -0
- package/dist/authoring.js.map +1 -0
- package/dist/brief.d.ts +40 -0
- package/dist/brief.d.ts.map +1 -0
- package/dist/brief.js +566 -0
- package/dist/brief.js.map +1 -0
- package/dist/cache.d.ts +8 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +20 -0
- package/dist/cache.js.map +1 -0
- package/dist/checks/brief.d.ts +5 -0
- package/dist/checks/brief.d.ts.map +1 -0
- package/dist/checks/brief.js +38 -0
- package/dist/checks/brief.js.map +1 -0
- package/dist/checks/citations.d.ts +14 -0
- package/dist/checks/citations.d.ts.map +1 -0
- package/dist/checks/citations.js +87 -0
- package/dist/checks/citations.js.map +1 -0
- package/dist/checks/claims.d.ts +16 -0
- package/dist/checks/claims.d.ts.map +1 -0
- package/dist/checks/claims.js +147 -0
- package/dist/checks/claims.js.map +1 -0
- package/dist/checks/closing.d.ts +20 -0
- package/dist/checks/closing.d.ts.map +1 -0
- package/dist/checks/closing.js +168 -0
- package/dist/checks/closing.js.map +1 -0
- package/dist/checks/design.d.ts +5 -0
- package/dist/checks/design.d.ts.map +1 -0
- package/dist/checks/design.js +107 -0
- package/dist/checks/design.js.map +1 -0
- package/dist/checks/document.d.ts +17 -0
- package/dist/checks/document.d.ts.map +1 -0
- package/dist/checks/document.js +213 -0
- package/dist/checks/document.js.map +1 -0
- package/dist/checks/evidence.d.ts +7 -0
- package/dist/checks/evidence.d.ts.map +1 -0
- package/dist/checks/evidence.js +133 -0
- package/dist/checks/evidence.js.map +1 -0
- package/dist/checks/hygiene.d.ts +5 -0
- package/dist/checks/hygiene.d.ts.map +1 -0
- package/dist/checks/hygiene.js +37 -0
- package/dist/checks/hygiene.js.map +1 -0
- package/dist/checks/index.d.ts +21 -0
- package/dist/checks/index.d.ts.map +1 -0
- package/dist/checks/index.js +98 -0
- package/dist/checks/index.js.map +1 -0
- package/dist/checks/language.d.ts +14 -0
- package/dist/checks/language.d.ts.map +1 -0
- package/dist/checks/language.js +73 -0
- package/dist/checks/language.js.map +1 -0
- package/dist/checks/outline.d.ts +25 -0
- package/dist/checks/outline.d.ts.map +1 -0
- package/dist/checks/outline.js +214 -0
- package/dist/checks/outline.js.map +1 -0
- package/dist/checks/policy.d.ts +5 -0
- package/dist/checks/policy.d.ts.map +1 -0
- package/dist/checks/policy.js +129 -0
- package/dist/checks/policy.js.map +1 -0
- package/dist/checks/project.d.ts +65 -0
- package/dist/checks/project.d.ts.map +1 -0
- package/dist/checks/project.js +203 -0
- package/dist/checks/project.js.map +1 -0
- package/dist/checks/styles.d.ts +12 -0
- package/dist/checks/styles.d.ts.map +1 -0
- package/dist/checks/styles.js +67 -0
- package/dist/checks/styles.js.map +1 -0
- package/dist/checks/writing.d.ts +6 -0
- package/dist/checks/writing.d.ts.map +1 -0
- package/dist/checks/writing.js +115 -0
- package/dist/checks/writing.js.map +1 -0
- package/dist/chrome/detect.d.ts +19 -0
- package/dist/chrome/detect.d.ts.map +1 -0
- package/dist/chrome/detect.js +116 -0
- package/dist/chrome/detect.js.map +1 -0
- package/dist/claims.d.ts +19 -0
- package/dist/claims.d.ts.map +1 -0
- package/dist/claims.js +99 -0
- package/dist/claims.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +262 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.d.ts +55 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +62 -0
- package/dist/context.js.map +1 -0
- package/dist/coordinator.d.ts +139 -0
- package/dist/coordinator.d.ts.map +1 -0
- package/dist/coordinator.js +710 -0
- package/dist/coordinator.js.map +1 -0
- package/dist/delegate.d.ts +34 -0
- package/dist/delegate.d.ts.map +1 -0
- package/dist/delegate.js +105 -0
- package/dist/delegate.js.map +1 -0
- package/dist/diffguard.d.ts +24 -0
- package/dist/diffguard.d.ts.map +1 -0
- package/dist/diffguard.js +92 -0
- package/dist/diffguard.js.map +1 -0
- package/dist/doctor.d.ts +34 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +155 -0
- package/dist/doctor.js.map +1 -0
- package/dist/draft.d.ts +64 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +801 -0
- package/dist/draft.js.map +1 -0
- package/dist/figure.d.ts +13 -0
- package/dist/figure.d.ts.map +1 -0
- package/dist/figure.js +143 -0
- package/dist/figure.js.map +1 -0
- package/dist/finalize.d.ts +29 -0
- package/dist/finalize.d.ts.map +1 -0
- package/dist/finalize.js +230 -0
- package/dist/finalize.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +206 -0
- package/dist/index.js.map +1 -0
- package/dist/intake.d.ts +57 -0
- package/dist/intake.d.ts.map +1 -0
- package/dist/intake.js +772 -0
- package/dist/intake.js.map +1 -0
- package/dist/labels.d.ts +50 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +98 -0
- package/dist/labels.js.map +1 -0
- package/dist/outline.d.ts +45 -0
- package/dist/outline.d.ts.map +1 -0
- package/dist/outline.js +148 -0
- package/dist/outline.js.map +1 -0
- package/dist/pack-commands.d.ts +18 -0
- package/dist/pack-commands.d.ts.map +1 -0
- package/dist/pack-commands.js +397 -0
- package/dist/pack-commands.js.map +1 -0
- package/dist/package-paths.d.ts +8 -0
- package/dist/package-paths.d.ts.map +1 -0
- package/dist/package-paths.js +13 -0
- package/dist/package-paths.js.map +1 -0
- package/dist/policy/context.d.ts +19 -0
- package/dist/policy/context.d.ts.map +1 -0
- package/dist/policy/context.js +62 -0
- package/dist/policy/context.js.map +1 -0
- package/dist/policy/ethics.d.ts +59 -0
- package/dist/policy/ethics.d.ts.map +1 -0
- package/dist/policy/ethics.js +106 -0
- package/dist/policy/ethics.js.map +1 -0
- package/dist/policy/kinds.d.ts +9 -0
- package/dist/policy/kinds.d.ts.map +1 -0
- package/dist/policy/kinds.js +68 -0
- package/dist/policy/kinds.js.map +1 -0
- package/dist/policy/packs.d.ts +53 -0
- package/dist/policy/packs.d.ts.map +1 -0
- package/dist/policy/packs.js +336 -0
- package/dist/policy/packs.js.map +1 -0
- package/dist/policy/resolver.d.ts +87 -0
- package/dist/policy/resolver.d.ts.map +1 -0
- package/dist/policy/resolver.js +337 -0
- package/dist/policy/resolver.js.map +1 -0
- package/dist/policy/rules.d.ts +65 -0
- package/dist/policy/rules.d.ts.map +1 -0
- package/dist/policy/rules.js +194 -0
- package/dist/policy/rules.js.map +1 -0
- package/dist/protocol.d.ts +46 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +86 -0
- package/dist/protocol.js.map +1 -0
- package/dist/render/adapters/chrome-pdf/cdp.d.ts +36 -0
- package/dist/render/adapters/chrome-pdf/cdp.d.ts.map +1 -0
- package/dist/render/adapters/chrome-pdf/cdp.js +291 -0
- package/dist/render/adapters/chrome-pdf/cdp.js.map +1 -0
- package/dist/render/adapters/chrome-pdf/index.d.ts +10 -0
- package/dist/render/adapters/chrome-pdf/index.d.ts.map +1 -0
- package/dist/render/adapters/chrome-pdf/index.js +139 -0
- package/dist/render/adapters/chrome-pdf/index.js.map +1 -0
- package/dist/render/adapters/chrome-pdf/network.d.ts +7 -0
- package/dist/render/adapters/chrome-pdf/network.d.ts.map +1 -0
- package/dist/render/adapters/chrome-pdf/network.js +33 -0
- package/dist/render/adapters/chrome-pdf/network.js.map +1 -0
- package/dist/render/adapters/html-preview/index.d.ts +8 -0
- package/dist/render/adapters/html-preview/index.d.ts.map +1 -0
- package/dist/render/adapters/html-preview/index.js +62 -0
- package/dist/render/adapters/html-preview/index.js.map +1 -0
- package/dist/render/adapters/test-json/index.d.ts +8 -0
- package/dist/render/adapters/test-json/index.d.ts.map +1 -0
- package/dist/render/adapters/test-json/index.js +62 -0
- package/dist/render/adapters/test-json/index.js.map +1 -0
- package/dist/render/adapters/typst-pdf/emitter.d.ts +21 -0
- package/dist/render/adapters/typst-pdf/emitter.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/emitter.js +259 -0
- package/dist/render/adapters/typst-pdf/emitter.js.map +1 -0
- package/dist/render/adapters/typst-pdf/escape.d.ts +14 -0
- package/dist/render/adapters/typst-pdf/escape.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/escape.js +56 -0
- package/dist/render/adapters/typst-pdf/escape.js.map +1 -0
- package/dist/render/adapters/typst-pdf/index.d.ts +9 -0
- package/dist/render/adapters/typst-pdf/index.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/index.js +154 -0
- package/dist/render/adapters/typst-pdf/index.js.map +1 -0
- package/dist/render/adapters/typst-pdf/profile.d.ts +3 -0
- package/dist/render/adapters/typst-pdf/profile.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/profile.js +55 -0
- package/dist/render/adapters/typst-pdf/profile.js.map +1 -0
- package/dist/render/adapters/typst-pdf/runner.d.ts +52 -0
- package/dist/render/adapters/typst-pdf/runner.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/runner.js +209 -0
- package/dist/render/adapters/typst-pdf/runner.js.map +1 -0
- package/dist/render/adapters/typst-pdf/setup.d.ts +30 -0
- package/dist/render/adapters/typst-pdf/setup.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/setup.js +183 -0
- package/dist/render/adapters/typst-pdf/setup.js.map +1 -0
- package/dist/render/adapters/typst-pdf/version.d.ts +8 -0
- package/dist/render/adapters/typst-pdf/version.d.ts.map +1 -0
- package/dist/render/adapters/typst-pdf/version.js +14 -0
- package/dist/render/adapters/typst-pdf/version.js.map +1 -0
- package/dist/render/assemble.d.ts +28 -0
- package/dist/render/assemble.d.ts.map +1 -0
- package/dist/render/assemble.js +309 -0
- package/dist/render/assemble.js.map +1 -0
- package/dist/render/assets.d.ts +27 -0
- package/dist/render/assets.d.ts.map +1 -0
- package/dist/render/assets.js +232 -0
- package/dist/render/assets.js.map +1 -0
- package/dist/render/build.d.ts +43 -0
- package/dist/render/build.d.ts.map +1 -0
- package/dist/render/build.js +187 -0
- package/dist/render/build.js.map +1 -0
- package/dist/render/charts.d.ts +83 -0
- package/dist/render/charts.d.ts.map +1 -0
- package/dist/render/charts.js +633 -0
- package/dist/render/charts.js.map +1 -0
- package/dist/render/default-registry.d.ts +7 -0
- package/dist/render/default-registry.d.ts.map +1 -0
- package/dist/render/default-registry.js +15 -0
- package/dist/render/default-registry.js.map +1 -0
- package/dist/render/diagram-theme.d.ts +7 -0
- package/dist/render/diagram-theme.d.ts.map +1 -0
- package/dist/render/diagram-theme.js +50 -0
- package/dist/render/diagram-theme.js.map +1 -0
- package/dist/render/dialect.d.ts +23 -0
- package/dist/render/dialect.d.ts.map +1 -0
- package/dist/render/dialect.js +188 -0
- package/dist/render/dialect.js.map +1 -0
- package/dist/render/html/citations.d.ts +70 -0
- package/dist/render/html/citations.d.ts.map +1 -0
- package/dist/render/html/citations.js +371 -0
- package/dist/render/html/citations.js.map +1 -0
- package/dist/render/html/css.d.ts +14 -0
- package/dist/render/html/css.d.ts.map +1 -0
- package/dist/render/html/css.js +113 -0
- package/dist/render/html/css.js.map +1 -0
- package/dist/render/html/emitter.d.ts +20 -0
- package/dist/render/html/emitter.d.ts.map +1 -0
- package/dist/render/html/emitter.js +652 -0
- package/dist/render/html/emitter.js.map +1 -0
- package/dist/render/html/escape.d.ts +11 -0
- package/dist/render/html/escape.d.ts.map +1 -0
- package/dist/render/html/escape.js +32 -0
- package/dist/render/html/escape.js.map +1 -0
- package/dist/render/html/katex.d.ts +9 -0
- package/dist/render/html/katex.d.ts.map +1 -0
- package/dist/render/html/katex.js +39 -0
- package/dist/render/html/katex.js.map +1 -0
- package/dist/render/html/stage.d.ts +12 -0
- package/dist/render/html/stage.d.ts.map +1 -0
- package/dist/render/html/stage.js +30 -0
- package/dist/render/html/stage.js.map +1 -0
- package/dist/render/index.d.ts +5 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +5 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/math.d.ts +9 -0
- package/dist/render/math.d.ts.map +1 -0
- package/dist/render/math.js +60 -0
- package/dist/render/math.js.map +1 -0
- package/dist/render/model.d.ts +233 -0
- package/dist/render/model.d.ts.map +1 -0
- package/dist/render/model.js +2 -0
- package/dist/render/model.js.map +1 -0
- package/dist/render/numbering.d.ts +51 -0
- package/dist/render/numbering.d.ts.map +1 -0
- package/dist/render/numbering.js +155 -0
- package/dist/render/numbering.js.map +1 -0
- package/dist/render/output-name.d.ts +4 -0
- package/dist/render/output-name.d.ts.map +1 -0
- package/dist/render/output-name.js +11 -0
- package/dist/render/output-name.js.map +1 -0
- package/dist/render/palettes.d.ts +22 -0
- package/dist/render/palettes.d.ts.map +1 -0
- package/dist/render/palettes.js +46 -0
- package/dist/render/palettes.js.map +1 -0
- package/dist/render/parse.d.ts +15 -0
- package/dist/render/parse.d.ts.map +1 -0
- package/dist/render/parse.js +637 -0
- package/dist/render/parse.js.map +1 -0
- package/dist/render/port.d.ts +79 -0
- package/dist/render/port.d.ts.map +1 -0
- package/dist/render/port.js +2 -0
- package/dist/render/port.js.map +1 -0
- package/dist/render/registry.d.ts +11 -0
- package/dist/render/registry.d.ts.map +1 -0
- package/dist/render/registry.js +21 -0
- package/dist/render/registry.js.map +1 -0
- package/dist/render/text.d.ts +13 -0
- package/dist/render/text.d.ts.map +1 -0
- package/dist/render/text.js +65 -0
- package/dist/render/text.js.map +1 -0
- package/dist/render/walk.d.ts +13 -0
- package/dist/render/walk.d.ts.map +1 -0
- package/dist/render/walk.js +69 -0
- package/dist/render/walk.js.map +1 -0
- package/dist/research/bibtex.d.ts +12 -0
- package/dist/research/bibtex.d.ts.map +1 -0
- package/dist/research/bibtex.js +99 -0
- package/dist/research/bibtex.js.map +1 -0
- package/dist/research/client.d.ts +112 -0
- package/dist/research/client.d.ts.map +1 -0
- package/dist/research/client.js +661 -0
- package/dist/research/client.js.map +1 -0
- package/dist/research/dossier.d.ts +31 -0
- package/dist/research/dossier.d.ts.map +1 -0
- package/dist/research/dossier.js +54 -0
- package/dist/research/dossier.js.map +1 -0
- package/dist/research/flow.d.ts +31 -0
- package/dist/research/flow.d.ts.map +1 -0
- package/dist/research/flow.js +635 -0
- package/dist/research/flow.js.map +1 -0
- package/dist/research/library.d.ts +79 -0
- package/dist/research/library.d.ts.map +1 -0
- package/dist/research/library.js +319 -0
- package/dist/research/library.js.map +1 -0
- package/dist/research/verify.d.ts +80 -0
- package/dist/research/verify.d.ts.map +1 -0
- package/dist/research/verify.js +307 -0
- package/dist/research/verify.js.map +1 -0
- package/dist/resources.d.ts +15 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +148 -0
- package/dist/resources.js.map +1 -0
- package/dist/review.d.ts +22 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +355 -0
- package/dist/review.js.map +1 -0
- package/dist/schemas.d.ts +252 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +1020 -0
- package/dist/schemas.js.map +1 -0
- package/dist/sections.d.ts +30 -0
- package/dist/sections.d.ts.map +1 -0
- package/dist/sections.js +62 -0
- package/dist/sections.js.map +1 -0
- package/dist/storage.d.ts +21 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +296 -0
- package/dist/storage.js.map +1 -0
- package/dist/style-commands.d.ts +15 -0
- package/dist/style-commands.d.ts.map +1 -0
- package/dist/style-commands.js +54 -0
- package/dist/style-commands.js.map +1 -0
- package/dist/styles/csl.d.ts +58 -0
- package/dist/styles/csl.d.ts.map +1 -0
- package/dist/styles/csl.js +112 -0
- package/dist/styles/csl.js.map +1 -0
- package/dist/styles/discovery.d.ts +45 -0
- package/dist/styles/discovery.d.ts.map +1 -0
- package/dist/styles/discovery.js +99 -0
- package/dist/styles/discovery.js.map +1 -0
- package/dist/styles/golden.d.ts +52 -0
- package/dist/styles/golden.d.ts.map +1 -0
- package/dist/styles/golden.js +216 -0
- package/dist/styles/golden.js.map +1 -0
- package/dist/styles/profile.d.ts +126 -0
- package/dist/styles/profile.d.ts.map +1 -0
- package/dist/styles/profile.js +582 -0
- package/dist/styles/profile.js.map +1 -0
- package/dist/styles/xml.d.ts +22 -0
- package/dist/styles/xml.d.ts.map +1 -0
- package/dist/styles/xml.js +179 -0
- package/dist/styles/xml.js.map +1 -0
- package/dist/types.d.ts +285 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +155 -0
- package/dist/types.js.map +1 -0
- package/dist/typst-pins.d.ts +16 -0
- package/dist/typst-pins.d.ts.map +1 -0
- package/dist/typst-pins.js +39 -0
- package/dist/typst-pins.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/workflow.d.ts +49 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +722 -0
- package/dist/workflow.js.map +1 -0
- package/dist/workspace.d.ts +12 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +71 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +70 -0
- package/policy-packs/countries/CO/academic-standards/ntc-1486-2022.yaml +188 -0
- package/policy-packs/countries/CO/copyright/decision-andina-351.yaml +61 -0
- package/policy-packs/countries/CO/copyright/ley-1915-2018.yaml +25 -0
- package/policy-packs/countries/CO/copyright/ley-23-1982.yaml +64 -0
- package/policy-packs/countries/CO/domains/health/resolucion-8430-1993.yaml +219 -0
- package/policy-packs/countries/CO/higher-education/ley-30-1992.yaml +61 -0
- package/policy-packs/countries/CO/manifest.yaml +42 -0
- package/policy-packs/countries/CO/official-domains.yaml +90 -0
- package/policy-packs/countries/CO/privacy/ley-1581-2012.yaml +197 -0
- package/policy-packs/countries/CO/research-integrity/minciencias-res-0314-2018.yaml +64 -0
- package/policy-packs/global/academic-integrity.yaml +45 -0
- package/policy-packs/global/academic-writing.yaml +70 -0
- package/policy-packs/global/evidence-quality.yaml +81 -0
- package/policy-packs/global/manifest.yaml +54 -0
- package/policy-packs/global/objective-verbs.yaml +245 -0
- package/policy-packs/global/reporting-guidelines.yaml +392 -0
- package/policy-packs/global/work-types.yaml +195 -0
- package/styles/LICENSE-CSL +375 -0
- package/styles/apa.csl +2283 -0
- package/styles/catalog.json +43 -0
- package/styles/fixtures/apa-7.expected.json +25 -0
- package/styles/fixtures/icontec-ntc1486-2022.expected.json +25 -0
- package/styles/fixtures/ieee.expected.json +25 -0
- package/styles/fixtures/references.jsonl +8 -0
- package/styles/icontec-ntc1486-2022.csl +388 -0
- package/styles/ieee.csl +519 -0
- package/templates/html/runtime.js +159 -0
- package/templates/html/thesis.css +98 -0
- package/templates/html/vendor/katex/LICENSE +21 -0
- package/templates/html/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/templates/html/vendor/katex/katex.min.css +1 -0
- package/templates/html/vendor/katex/katex.min.js +1 -0
- package/templates/html/vendor/mermaid/LICENSE +21 -0
- package/templates/html/vendor/mermaid/mermaid.min.js +3587 -0
- package/templates/html/vendor/pagedjs/LICENSE +21 -0
- package/templates/html/vendor/pagedjs/paged.polyfill.min.js +4 -0
- package/templates/palettes.json +57 -0
- package/templates/profiles/apa-7.profile.yaml +15 -0
- package/templates/profiles/generic.profile.yaml +20 -0
- package/templates/profiles/icontec-ntc1486-2022.profile.yaml +36 -0
- package/templates/profiles/ieee.profile.yaml +14 -0
- package/templates/typst/i18n/en.yaml +31 -0
- package/templates/typst/i18n/es.yaml +31 -0
- package/templates/typst/i18n/pt.yaml +31 -0
- package/templates/typst/thesis.typ +276 -0
- package/typst-packages/preview/merman/0.3.0/LICENSE +231 -0
- package/typst-packages/preview/merman/0.3.0/README.md +388 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cose-base-v1/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cose-base-v2/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape/LICENSE +19 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape-cose-bilkent/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape-fcose/LICENSE +19 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/d3-shape/LICENSE +13 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/dagre/LICENSE +19 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/dompurify/LICENSE +202 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/eclipse-elk/LICENSE.md +264 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/elkjs/LICENSE.md +264 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/fmin/LICENSE +27 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/graphlib/LICENSE +19 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/layout-base-v1/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/layout-base-v2/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/rough-rs/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/roughjs/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/sanitize-url/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/venn-js/LICENSE +22 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/wasm-minimal-protocol/LICENSE +24 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
- package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_NOTICES.md +265 -0
- package/typst-packages/preview/merman/0.3.0/lib.typ +1 -0
- package/typst-packages/preview/merman/0.3.0/merman_typst_plugin.wasm +0 -0
- package/typst-packages/preview/merman/0.3.0/src/capabilities.typ +5 -0
- package/typst-packages/preview/merman/0.3.0/src/context.typ +1 -0
- package/typst-packages/preview/merman/0.3.0/src/errors.typ +33 -0
- package/typst-packages/preview/merman/0.3.0/src/exports.typ +5 -0
- package/typst-packages/preview/merman/0.3.0/src/figure.typ +143 -0
- package/typst-packages/preview/merman/0.3.0/src/image.typ +50 -0
- package/typst-packages/preview/merman/0.3.0/src/options.typ +566 -0
- package/typst-packages/preview/merman/0.3.0/src/plugin.typ +1 -0
- package/typst-packages/preview/merman/0.3.0/src/raw.typ +22 -0
- package/typst-packages/preview/merman/0.3.0/src/render.typ +137 -0
- package/typst-packages/preview/merman/0.3.0/src/source.typ +7 -0
- package/typst-packages/preview/merman/0.3.0/src/units.typ +51 -0
- package/typst-packages/preview/merman/0.3.0/typst.toml +12 -0
- package/typst-packages/preview/mitex/0.2.7/CHANGELOG.md +69 -0
- package/typst-packages/preview/mitex/0.2.7/LICENSE +176 -0
- package/typst-packages/preview/mitex/0.2.7/README.md +154 -0
- package/typst-packages/preview/mitex/0.2.7/lib.typ +1 -0
- package/typst-packages/preview/mitex/0.2.7/mitex.typ +45 -0
- package/typst-packages/preview/mitex/0.2.7/mitex.wasm +0 -0
- package/typst-packages/preview/mitex/0.2.7/specs/README.md +250 -0
- package/typst-packages/preview/mitex/0.2.7/specs/latex/standard.typ +1187 -0
- package/typst-packages/preview/mitex/0.2.7/specs/mod.typ +12 -0
- package/typst-packages/preview/mitex/0.2.7/specs/prelude.typ +230 -0
- package/typst-packages/preview/mitex/0.2.7/typst.toml +12 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { stripControl } from "../schemas.js";
|
|
5
|
+
import { atomicWrite } from "../storage.js";
|
|
6
|
+
import { VERSION } from "../version.js";
|
|
7
|
+
/** Fixed scholarly origins (spec 8.2). Nothing else is ever contacted by this client. */
|
|
8
|
+
export const origins = {
|
|
9
|
+
openalex: "https://api.openalex.org",
|
|
10
|
+
crossref: "https://api.crossref.org",
|
|
11
|
+
arxiv: "https://export.arxiv.org",
|
|
12
|
+
};
|
|
13
|
+
export const limits = {
|
|
14
|
+
timeoutMs: 8000,
|
|
15
|
+
responseBytes: 1024 * 1024,
|
|
16
|
+
arxivSpacingMs: 3000,
|
|
17
|
+
};
|
|
18
|
+
export const realClock = {
|
|
19
|
+
now: () => Date.now(),
|
|
20
|
+
sleep: (ms, signal) => new Promise((resolve, reject) => {
|
|
21
|
+
const timer = setTimeout(resolve, ms);
|
|
22
|
+
signal?.addEventListener("abort", () => {
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
reject(new Error("source unavailable"));
|
|
25
|
+
}, { once: true });
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
// ---------------------------------------------------------------------------------------------
|
|
29
|
+
// Sanitizing
|
|
30
|
+
// ---------------------------------------------------------------------------------------------
|
|
31
|
+
/** Remove control characters and markup noise, collapse whitespace and cap the length. */
|
|
32
|
+
export function clean(value, max = 300) {
|
|
33
|
+
if (typeof value !== "string")
|
|
34
|
+
return null;
|
|
35
|
+
const text = stripControl(decodeEntities(value.replace(/<[^>]*>/g, " ")))
|
|
36
|
+
.replace(/\s+/g, " ")
|
|
37
|
+
.trim()
|
|
38
|
+
.slice(0, max);
|
|
39
|
+
return text || null;
|
|
40
|
+
}
|
|
41
|
+
const namedEntities = {
|
|
42
|
+
amp: "&",
|
|
43
|
+
lt: "<",
|
|
44
|
+
gt: ">",
|
|
45
|
+
quot: '"',
|
|
46
|
+
apos: "'",
|
|
47
|
+
nbsp: " ",
|
|
48
|
+
};
|
|
49
|
+
function decodeEntities(value) {
|
|
50
|
+
return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (whole, body) => {
|
|
51
|
+
if (body.startsWith("#")) {
|
|
52
|
+
const code = body[1] === "x" || body[1] === "X"
|
|
53
|
+
? Number.parseInt(body.slice(2), 16)
|
|
54
|
+
: Number(body.slice(1));
|
|
55
|
+
return Number.isInteger(code) && code > 31 && code < 0x110000
|
|
56
|
+
? String.fromCodePoint(code)
|
|
57
|
+
: "";
|
|
58
|
+
}
|
|
59
|
+
return namedEntities[body] ?? whole;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function safeUrl(value) {
|
|
63
|
+
if (typeof value !== "string")
|
|
64
|
+
return null;
|
|
65
|
+
try {
|
|
66
|
+
const url = new URL(value.trim());
|
|
67
|
+
if ((url.protocol !== "https:" && url.protocol !== "http:") || url.username || url.password) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const text = url.toString();
|
|
71
|
+
return text.length <= 500 ? text : null;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
78
|
+
const asArray = (value) => (Array.isArray(value) ? value : []);
|
|
79
|
+
const firstString = (value) => (Array.isArray(value) ? value[0] : value);
|
|
80
|
+
function year(value) {
|
|
81
|
+
const number = typeof value === "number" ? value : Number(value);
|
|
82
|
+
return Number.isInteger(number) && number >= 1000 && number <= 2200 ? number : null;
|
|
83
|
+
}
|
|
84
|
+
function bareOrcid(value) {
|
|
85
|
+
if (typeof value !== "string")
|
|
86
|
+
return null;
|
|
87
|
+
const match = /(\d{4}-\d{4}-\d{4}-\d{3}[\dX])/.exec(value);
|
|
88
|
+
return match ? match[1] : null;
|
|
89
|
+
}
|
|
90
|
+
const maxAuthors = 50;
|
|
91
|
+
function bareDoi(value) {
|
|
92
|
+
if (typeof value !== "string")
|
|
93
|
+
return null;
|
|
94
|
+
const doi = value
|
|
95
|
+
.trim()
|
|
96
|
+
.replace(/^https?:\/\/(?:dx\.)?doi\.org\//i, "")
|
|
97
|
+
.replace(/^doi:\s*/i, "")
|
|
98
|
+
.toLowerCase();
|
|
99
|
+
return /^10\.\d{4,9}\/\S{1,200}$/.test(doi) ? doi : null;
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------------------------
|
|
102
|
+
// Identifiers and input
|
|
103
|
+
// ---------------------------------------------------------------------------------------------
|
|
104
|
+
export function parseIdentifier(raw) {
|
|
105
|
+
if (typeof raw !== "string")
|
|
106
|
+
throw new Error("invalid identifier");
|
|
107
|
+
const text = raw.trim();
|
|
108
|
+
if (text.length < 1 || text.length > 2048)
|
|
109
|
+
throw new Error("invalid identifier");
|
|
110
|
+
let value = text;
|
|
111
|
+
try {
|
|
112
|
+
value = decodeURIComponent(text);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// keep the raw text
|
|
116
|
+
}
|
|
117
|
+
value = value
|
|
118
|
+
.replace(/^doi:\s*/i, "")
|
|
119
|
+
.replace(/^https?:\/\/(?:dx\.)?doi\.org\//i, "")
|
|
120
|
+
.trim();
|
|
121
|
+
if (/^10\.\d{4,9}\/[^\s]{1,200}$/i.test(value))
|
|
122
|
+
return { kind: "doi", value: value.toLowerCase() };
|
|
123
|
+
const arxivUrl = /^https?:\/\/arxiv\.org\/(?:abs|pdf)\/(.+?)(?:\.pdf)?$/i.exec(value);
|
|
124
|
+
const arxiv = /^(?:arxiv:)?(\d{4}\.\d{4,5}|[a-z-]+(?:\.[a-z-]+)?\/\d{7})(v\d+)?$/i.exec(arxivUrl ? arxivUrl[1] : value);
|
|
125
|
+
if (arxiv)
|
|
126
|
+
return { kind: "arxiv", value: arxiv[1].toLowerCase() };
|
|
127
|
+
const openalex = /^(?:https?:\/\/openalex\.org\/)?(W\d{1,12})$/i.exec(value);
|
|
128
|
+
if (openalex)
|
|
129
|
+
return { kind: "openalex", value: openalex[1].toUpperCase() };
|
|
130
|
+
const url = safeUrl(value);
|
|
131
|
+
if (url) {
|
|
132
|
+
const parsed = new URL(url);
|
|
133
|
+
parsed.hash = "";
|
|
134
|
+
return { kind: "url", value: parsed.toString() };
|
|
135
|
+
}
|
|
136
|
+
throw new Error("invalid identifier");
|
|
137
|
+
}
|
|
138
|
+
const yearBounds = { min: 1600, max: new Date().getUTCFullYear() + 1 };
|
|
139
|
+
export function parseSearchInput(input) {
|
|
140
|
+
if (!isRecord(input))
|
|
141
|
+
throw new Error("invalid input");
|
|
142
|
+
const allowed = ["query", "source", "limit", "fromYear", "toYear", "language"];
|
|
143
|
+
if (Object.keys(input).some((key) => !allowed.includes(key)))
|
|
144
|
+
throw new Error("invalid input");
|
|
145
|
+
const query = typeof input.query === "string" ? input.query.trim() : "";
|
|
146
|
+
if (query.length < 1 || query.length > 512)
|
|
147
|
+
throw new Error("invalid input");
|
|
148
|
+
if (input.source !== "openalex" && input.source !== "crossref" && input.source !== "arxiv") {
|
|
149
|
+
throw new Error("invalid input");
|
|
150
|
+
}
|
|
151
|
+
let limit = 10;
|
|
152
|
+
if (input.limit !== undefined) {
|
|
153
|
+
if (!Number.isInteger(input.limit) ||
|
|
154
|
+
input.limit < 1 ||
|
|
155
|
+
input.limit > 25) {
|
|
156
|
+
throw new Error("invalid input");
|
|
157
|
+
}
|
|
158
|
+
limit = input.limit;
|
|
159
|
+
}
|
|
160
|
+
const result = { query: stripControl(query), source: input.source, limit };
|
|
161
|
+
for (const key of ["fromYear", "toYear"]) {
|
|
162
|
+
const value = input[key];
|
|
163
|
+
if (value === undefined)
|
|
164
|
+
continue;
|
|
165
|
+
if (!Number.isInteger(value) ||
|
|
166
|
+
value < yearBounds.min ||
|
|
167
|
+
value > yearBounds.max) {
|
|
168
|
+
throw new Error("invalid input");
|
|
169
|
+
}
|
|
170
|
+
result[key] = value;
|
|
171
|
+
}
|
|
172
|
+
if (result.fromYear && result.toYear && result.fromYear > result.toYear)
|
|
173
|
+
throw new Error("invalid input");
|
|
174
|
+
if (input.language !== undefined) {
|
|
175
|
+
if (typeof input.language !== "string" || !/^[a-z]{2,3}$/i.test(input.language)) {
|
|
176
|
+
throw new Error("invalid input");
|
|
177
|
+
}
|
|
178
|
+
result.language = input.language.toLowerCase();
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
// ---------------------------------------------------------------------------------------------
|
|
183
|
+
// Normalizers (pure; exercised by recorded fixtures)
|
|
184
|
+
// ---------------------------------------------------------------------------------------------
|
|
185
|
+
const crossrefTypes = {
|
|
186
|
+
"journal-article": "journal_article",
|
|
187
|
+
"proceedings-article": "conference_paper",
|
|
188
|
+
book: "book",
|
|
189
|
+
monograph: "book",
|
|
190
|
+
"edited-book": "book",
|
|
191
|
+
"reference-book": "book",
|
|
192
|
+
"book-chapter": "chapter",
|
|
193
|
+
"book-section": "chapter",
|
|
194
|
+
"reference-entry": "chapter",
|
|
195
|
+
dissertation: "thesis",
|
|
196
|
+
report: "report",
|
|
197
|
+
"report-component": "report",
|
|
198
|
+
standard: "standard",
|
|
199
|
+
dataset: "dataset",
|
|
200
|
+
"posted-content": "preprint",
|
|
201
|
+
};
|
|
202
|
+
const openalexTypes = {
|
|
203
|
+
article: "journal_article",
|
|
204
|
+
book: "book",
|
|
205
|
+
"book-chapter": "chapter",
|
|
206
|
+
dissertation: "thesis",
|
|
207
|
+
dataset: "dataset",
|
|
208
|
+
report: "report",
|
|
209
|
+
standard: "standard",
|
|
210
|
+
preprint: "preprint",
|
|
211
|
+
};
|
|
212
|
+
function crossrefRetracted(item) {
|
|
213
|
+
const isRetraction = (entry) => isRecord(entry) && typeof entry.type === "string" && /retract/i.test(entry.type);
|
|
214
|
+
if (asArray(item["update-to"]).some(isRetraction))
|
|
215
|
+
return true;
|
|
216
|
+
if (asArray(item["updated-by"]).some(isRetraction))
|
|
217
|
+
return true;
|
|
218
|
+
const relation = item.relation;
|
|
219
|
+
return isRecord(relation) && Object.keys(relation).some((key) => /retract/i.test(key));
|
|
220
|
+
}
|
|
221
|
+
export function normalizeCrossref(item) {
|
|
222
|
+
if (!isRecord(item))
|
|
223
|
+
return undefined;
|
|
224
|
+
const doi = bareDoi(item.DOI);
|
|
225
|
+
const title = clean(firstString(item.title), 500);
|
|
226
|
+
if (!title)
|
|
227
|
+
return undefined;
|
|
228
|
+
const issued = firstDateYear(item.issued) ??
|
|
229
|
+
firstDateYear(item["published-print"]) ??
|
|
230
|
+
firstDateYear(item["published-online"]);
|
|
231
|
+
const authors = asArray(item.author)
|
|
232
|
+
.filter(isRecord)
|
|
233
|
+
.slice(0, maxAuthors)
|
|
234
|
+
.map((author) => {
|
|
235
|
+
const family = clean(author.family, 120) ?? clean(author.name, 200);
|
|
236
|
+
return family
|
|
237
|
+
? { family, given: clean(author.given, 120), orcid: bareOrcid(author.ORCID) }
|
|
238
|
+
: undefined;
|
|
239
|
+
})
|
|
240
|
+
.filter((author) => author !== undefined);
|
|
241
|
+
const license = asArray(item.license).find(isRecord);
|
|
242
|
+
const type = crossrefTypes[typeof item.type === "string" ? item.type : ""] ?? "other";
|
|
243
|
+
const isbn = asArray(item.ISBN)[0];
|
|
244
|
+
const record = {
|
|
245
|
+
id: doi ?? title,
|
|
246
|
+
doi,
|
|
247
|
+
title,
|
|
248
|
+
authors,
|
|
249
|
+
year: issued,
|
|
250
|
+
containerTitle: clean(firstString(item["container-title"]), 300),
|
|
251
|
+
type,
|
|
252
|
+
publisher: clean(item.publisher, 200),
|
|
253
|
+
...(clean(item["publisher-location"], 120)
|
|
254
|
+
? { placeOfPublication: clean(item["publisher-location"], 120) }
|
|
255
|
+
: {}),
|
|
256
|
+
issn: clean(asArray(item.ISSN)[0], 20),
|
|
257
|
+
isbn: clean(isbn, 20),
|
|
258
|
+
volume: clean(item.volume, 40),
|
|
259
|
+
issue: clean(item.issue, 40),
|
|
260
|
+
pages: clean(item.page, 40),
|
|
261
|
+
language: clean(item.language, 12),
|
|
262
|
+
url: safeUrl(item.URL) ?? (doi ? `https://doi.org/${doi}` : null),
|
|
263
|
+
oaUrl: null,
|
|
264
|
+
license: license ? safeUrl(license.URL) : null,
|
|
265
|
+
abstract: clean(item.abstract, 2000),
|
|
266
|
+
source: "crossref",
|
|
267
|
+
};
|
|
268
|
+
return { record, retracted: crossrefRetracted(item) };
|
|
269
|
+
}
|
|
270
|
+
function firstDateYear(value) {
|
|
271
|
+
if (!isRecord(value))
|
|
272
|
+
return null;
|
|
273
|
+
const parts = asArray(value["date-parts"])[0];
|
|
274
|
+
return year(asArray(parts)[0]);
|
|
275
|
+
}
|
|
276
|
+
function invertedAbstract(value) {
|
|
277
|
+
if (!isRecord(value))
|
|
278
|
+
return null;
|
|
279
|
+
const words = [];
|
|
280
|
+
for (const [word, positions] of Object.entries(value)) {
|
|
281
|
+
for (const position of asArray(positions)) {
|
|
282
|
+
if (Number.isInteger(position) && position >= 0 && position < 20000) {
|
|
283
|
+
words.push([position, word]);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
words.sort((a, b) => a[0] - b[0]);
|
|
288
|
+
return clean(words.map(([, word]) => word).join(" "), 2000);
|
|
289
|
+
}
|
|
290
|
+
export function normalizeOpenAlex(item) {
|
|
291
|
+
if (!isRecord(item))
|
|
292
|
+
return undefined;
|
|
293
|
+
const title = clean(item.display_name ?? item.title, 500);
|
|
294
|
+
if (!title)
|
|
295
|
+
return undefined;
|
|
296
|
+
const id = typeof item.id === "string" ? /(W\d{1,12})$/.exec(item.id)?.[1] : undefined;
|
|
297
|
+
const doi = bareDoi(item.doi);
|
|
298
|
+
const location = isRecord(item.primary_location) ? item.primary_location : {};
|
|
299
|
+
const source = isRecord(location.source) ? location.source : {};
|
|
300
|
+
const access = isRecord(item.open_access) ? item.open_access : {};
|
|
301
|
+
const biblio = isRecord(item.biblio) ? item.biblio : {};
|
|
302
|
+
const authors = asArray(item.authorships)
|
|
303
|
+
.filter(isRecord)
|
|
304
|
+
.slice(0, maxAuthors)
|
|
305
|
+
.map((entry) => {
|
|
306
|
+
const author = isRecord(entry.author) ? entry.author : {};
|
|
307
|
+
const name = clean(author.display_name, 200);
|
|
308
|
+
if (!name)
|
|
309
|
+
return undefined;
|
|
310
|
+
const parts = name.split(" ");
|
|
311
|
+
const family = parts.length > 1 ? parts.pop() : name;
|
|
312
|
+
return {
|
|
313
|
+
family,
|
|
314
|
+
given: parts.length > 0 ? parts.join(" ") : null,
|
|
315
|
+
orcid: bareOrcid(author.orcid),
|
|
316
|
+
};
|
|
317
|
+
})
|
|
318
|
+
.filter((author) => author !== undefined);
|
|
319
|
+
let type = openalexTypes[typeof item.type === "string" ? item.type : ""] ?? "other";
|
|
320
|
+
if (type === "journal_article" && source.type === "conference")
|
|
321
|
+
type = "conference_paper";
|
|
322
|
+
if (type === "journal_article" && source.type === "repository")
|
|
323
|
+
type = "preprint";
|
|
324
|
+
const first = clean(biblio.first_page, 20);
|
|
325
|
+
const last = clean(biblio.last_page, 20);
|
|
326
|
+
const record = {
|
|
327
|
+
id: id ?? doi ?? title,
|
|
328
|
+
doi,
|
|
329
|
+
title,
|
|
330
|
+
authors,
|
|
331
|
+
year: year(item.publication_year),
|
|
332
|
+
containerTitle: clean(source.display_name, 300),
|
|
333
|
+
type,
|
|
334
|
+
publisher: clean(source.host_organization_name, 200),
|
|
335
|
+
issn: clean(source.issn_l, 20),
|
|
336
|
+
isbn: null,
|
|
337
|
+
volume: clean(biblio.volume, 40),
|
|
338
|
+
issue: clean(biblio.issue, 40),
|
|
339
|
+
pages: first && last ? `${first}-${last}` : first,
|
|
340
|
+
language: clean(item.language, 12),
|
|
341
|
+
url: safeUrl(location.landing_page_url) ?? (doi ? `https://doi.org/${doi}` : null),
|
|
342
|
+
oaUrl: safeUrl(access.oa_url),
|
|
343
|
+
license: clean(location.license, 60),
|
|
344
|
+
abstract: invertedAbstract(item.abstract_inverted_index),
|
|
345
|
+
source: "openalex",
|
|
346
|
+
};
|
|
347
|
+
return { record, retracted: item.is_retracted === true };
|
|
348
|
+
}
|
|
349
|
+
function xmlText(block, tag) {
|
|
350
|
+
const match = new RegExp(`<${tag}(?:\\s[^>]*)?>([\\s\\S]*?)</${tag}>`).exec(block);
|
|
351
|
+
return match ? clean(match[1], 2000) : null;
|
|
352
|
+
}
|
|
353
|
+
export function normalizeArxiv(xml) {
|
|
354
|
+
const records = [];
|
|
355
|
+
for (const match of xml.matchAll(/<entry>([\s\S]*?)<\/entry>/g)) {
|
|
356
|
+
const block = match[1];
|
|
357
|
+
const idUrl = xmlText(block, "id");
|
|
358
|
+
const id = idUrl
|
|
359
|
+
? /arxiv\.org\/abs\/(.+?)(?:v\d+)?$/i.exec(idUrl)?.[1]?.toLowerCase()
|
|
360
|
+
: undefined;
|
|
361
|
+
const title = clean(xmlText(block, "title"), 500);
|
|
362
|
+
if (!id || !title)
|
|
363
|
+
continue;
|
|
364
|
+
const authors = [...block.matchAll(/<author>\s*<name>([\s\S]*?)<\/name>/g)]
|
|
365
|
+
.slice(0, maxAuthors)
|
|
366
|
+
.map((author) => clean(author[1], 200))
|
|
367
|
+
.filter((name) => name !== null)
|
|
368
|
+
.map((name) => {
|
|
369
|
+
const parts = name.split(" ");
|
|
370
|
+
const family = parts.length > 1 ? parts.pop() : name;
|
|
371
|
+
return { family, given: parts.length > 0 ? parts.join(" ") : null, orcid: null };
|
|
372
|
+
});
|
|
373
|
+
const published = xmlText(block, "published");
|
|
374
|
+
records.push({
|
|
375
|
+
id,
|
|
376
|
+
doi: bareDoi(xmlText(block, "arxiv:doi")),
|
|
377
|
+
title,
|
|
378
|
+
authors,
|
|
379
|
+
year: published ? year(published.slice(0, 4)) : null,
|
|
380
|
+
containerTitle: clean(xmlText(block, "arxiv:journal_ref"), 300),
|
|
381
|
+
type: "preprint",
|
|
382
|
+
publisher: "arXiv",
|
|
383
|
+
issn: null,
|
|
384
|
+
isbn: null,
|
|
385
|
+
volume: null,
|
|
386
|
+
issue: null,
|
|
387
|
+
pages: null,
|
|
388
|
+
language: "en",
|
|
389
|
+
url: `https://arxiv.org/abs/${id}`,
|
|
390
|
+
oaUrl: `https://arxiv.org/pdf/${id}`,
|
|
391
|
+
license: null,
|
|
392
|
+
abstract: xmlText(block, "summary"),
|
|
393
|
+
source: "arxiv",
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return records;
|
|
397
|
+
}
|
|
398
|
+
// ---------------------------------------------------------------------------------------------
|
|
399
|
+
// Client
|
|
400
|
+
// ---------------------------------------------------------------------------------------------
|
|
401
|
+
const openalexSelect = [
|
|
402
|
+
"id",
|
|
403
|
+
"doi",
|
|
404
|
+
"display_name",
|
|
405
|
+
"publication_year",
|
|
406
|
+
"authorships",
|
|
407
|
+
"primary_location",
|
|
408
|
+
"type",
|
|
409
|
+
"language",
|
|
410
|
+
"open_access",
|
|
411
|
+
"biblio",
|
|
412
|
+
"is_retracted",
|
|
413
|
+
"abstract_inverted_index",
|
|
414
|
+
].join(",");
|
|
415
|
+
const contactPattern = /^[^\s@<>"']{1,64}@[^\s@<>"']{1,190}$/;
|
|
416
|
+
/** Resolved records are cached for 24 hours (spec 15). */
|
|
417
|
+
export const resolveCacheTtlMs = 24 * 60 * 60 * 1000;
|
|
418
|
+
export class ScholarClient {
|
|
419
|
+
cacheDir;
|
|
420
|
+
fetcher;
|
|
421
|
+
clock;
|
|
422
|
+
env;
|
|
423
|
+
timeoutMs;
|
|
424
|
+
crossrefTail = Promise.resolve();
|
|
425
|
+
arxivNext = 0;
|
|
426
|
+
constructor(options = {}) {
|
|
427
|
+
this.fetcher = options.fetch ?? ((input, init) => fetch(input, init));
|
|
428
|
+
this.clock = options.clock ?? realClock;
|
|
429
|
+
this.env = options.env ?? process.env;
|
|
430
|
+
this.timeoutMs = options.timeoutMs ?? limits.timeoutMs;
|
|
431
|
+
}
|
|
432
|
+
/** Cache resolved records under `dir` (for example `<thesis>/build/cache/scholar`). */
|
|
433
|
+
useCache(dir) {
|
|
434
|
+
this.cacheDir = dir;
|
|
435
|
+
}
|
|
436
|
+
cacheFile(identifier) {
|
|
437
|
+
if (!this.cacheDir)
|
|
438
|
+
return undefined;
|
|
439
|
+
const key = createHash("sha256").update(`${identifier.kind}:${identifier.value}`).digest("hex");
|
|
440
|
+
return join(this.cacheDir, `${key}.json`);
|
|
441
|
+
}
|
|
442
|
+
async readCache(identifier) {
|
|
443
|
+
const file = this.cacheFile(identifier);
|
|
444
|
+
if (!file)
|
|
445
|
+
return undefined;
|
|
446
|
+
try {
|
|
447
|
+
const entry = JSON.parse(await readFile(file, "utf8"));
|
|
448
|
+
if (typeof entry.at === "number" &&
|
|
449
|
+
this.clock.now() - entry.at < resolveCacheTtlMs &&
|
|
450
|
+
entry.at <= this.clock.now() &&
|
|
451
|
+
entry.resolved?.record &&
|
|
452
|
+
typeof entry.resolved.retracted === "boolean") {
|
|
453
|
+
return entry.resolved;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
// A missing or damaged cache entry is a miss.
|
|
458
|
+
}
|
|
459
|
+
return undefined;
|
|
460
|
+
}
|
|
461
|
+
async writeCache(identifier, resolved) {
|
|
462
|
+
const file = this.cacheFile(identifier);
|
|
463
|
+
if (!file)
|
|
464
|
+
return;
|
|
465
|
+
try {
|
|
466
|
+
await atomicWrite(file, `${JSON.stringify({ at: this.clock.now(), resolved })}\n`);
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
// The cache is an optimization; a read-only workspace must not fail the lookup.
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/** Optional polite-pool contact; read per call from the environment, never stored or logged. */
|
|
473
|
+
contact() {
|
|
474
|
+
const value = this.env.ALISIO_THESIS_CONTACT_EMAIL?.trim();
|
|
475
|
+
return value && contactPattern.test(value) ? value : undefined;
|
|
476
|
+
}
|
|
477
|
+
async search(input, signal) {
|
|
478
|
+
const records = (await this.searchSource(input, signal)).slice(0, input.limit);
|
|
479
|
+
return records.filter((record) => (input.fromYear === undefined || record.year === null || record.year >= input.fromYear) &&
|
|
480
|
+
(input.toYear === undefined || record.year === null || record.year <= input.toYear));
|
|
481
|
+
}
|
|
482
|
+
async searchSource(input, signal) {
|
|
483
|
+
const query = new URLSearchParams();
|
|
484
|
+
if (input.source === "openalex") {
|
|
485
|
+
query.set("search", input.query);
|
|
486
|
+
query.set("per-page", String(input.limit));
|
|
487
|
+
query.set("select", openalexSelect);
|
|
488
|
+
const filters = [];
|
|
489
|
+
if (input.fromYear)
|
|
490
|
+
filters.push(`from_publication_date:${input.fromYear}-01-01`);
|
|
491
|
+
if (input.toYear)
|
|
492
|
+
filters.push(`to_publication_date:${input.toYear}-12-31`);
|
|
493
|
+
if (input.language)
|
|
494
|
+
filters.push(`language:${input.language}`);
|
|
495
|
+
if (filters.length)
|
|
496
|
+
query.set("filter", filters.join(","));
|
|
497
|
+
const contact = this.contact();
|
|
498
|
+
if (contact)
|
|
499
|
+
query.set("mailto", contact);
|
|
500
|
+
const body = await this.request("openalex", `/works?${query}`, signal);
|
|
501
|
+
return asArray(parseJson(body).results)
|
|
502
|
+
.map(normalizeOpenAlex)
|
|
503
|
+
.filter((entry) => entry !== undefined)
|
|
504
|
+
.map((entry) => entry.record);
|
|
505
|
+
}
|
|
506
|
+
if (input.source === "crossref") {
|
|
507
|
+
query.set("query.bibliographic", input.query);
|
|
508
|
+
query.set("rows", String(input.limit));
|
|
509
|
+
const filters = [];
|
|
510
|
+
if (input.fromYear)
|
|
511
|
+
filters.push(`from-pub-date:${input.fromYear}`);
|
|
512
|
+
if (input.toYear)
|
|
513
|
+
filters.push(`until-pub-date:${input.toYear}`);
|
|
514
|
+
if (filters.length)
|
|
515
|
+
query.set("filter", filters.join(","));
|
|
516
|
+
const message = parseJson(await this.request("crossref", `/works?${query}`, signal)).message;
|
|
517
|
+
return asArray(isRecord(message) ? message.items : undefined)
|
|
518
|
+
.map(normalizeCrossref)
|
|
519
|
+
.filter((entry) => entry !== undefined)
|
|
520
|
+
.map((entry) => entry.record);
|
|
521
|
+
}
|
|
522
|
+
query.set("search_query", `all:${input.query.replace(/["\\]/g, " ")}`);
|
|
523
|
+
query.set("start", "0");
|
|
524
|
+
query.set("max_results", String(input.limit));
|
|
525
|
+
query.set("sortBy", "relevance");
|
|
526
|
+
return normalizeArxiv(await this.request("arxiv", `/api/query?${query}`, signal));
|
|
527
|
+
}
|
|
528
|
+
async resolve(identifier, signal) {
|
|
529
|
+
if (identifier.kind === "url")
|
|
530
|
+
return undefined;
|
|
531
|
+
const cached = await this.readCache(identifier);
|
|
532
|
+
if (cached)
|
|
533
|
+
return cached;
|
|
534
|
+
const resolved = await this.resolveRemote(identifier, signal);
|
|
535
|
+
if (resolved)
|
|
536
|
+
await this.writeCache(identifier, resolved);
|
|
537
|
+
return resolved;
|
|
538
|
+
}
|
|
539
|
+
async resolveRemote(identifier, signal) {
|
|
540
|
+
if (identifier.kind === "arxiv") {
|
|
541
|
+
const query = new URLSearchParams({ id_list: identifier.value });
|
|
542
|
+
const [record] = normalizeArxiv(await this.request("arxiv", `/api/query?${query}`, signal));
|
|
543
|
+
return record ? { record, retracted: false } : undefined;
|
|
544
|
+
}
|
|
545
|
+
if (identifier.kind === "openalex") {
|
|
546
|
+
return this.openalexWork(identifier.value, signal);
|
|
547
|
+
}
|
|
548
|
+
// DOI: Crossref first, OpenAlex when Crossref does not know it.
|
|
549
|
+
const path = identifier.value.split("/").map(encodeURIComponent).join("/");
|
|
550
|
+
const contact = this.contact();
|
|
551
|
+
try {
|
|
552
|
+
const body = parseJson(await this.request("crossref", `/works/${path}${contact ? `?mailto=${encodeURIComponent(contact)}` : ""}`, signal));
|
|
553
|
+
return normalizeCrossref(body.message);
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
if (error.message !== "record not found")
|
|
557
|
+
throw error;
|
|
558
|
+
}
|
|
559
|
+
return this.openalexWork(`doi:https://doi.org/${identifier.value}`, signal);
|
|
560
|
+
}
|
|
561
|
+
async openalexWork(id, signal) {
|
|
562
|
+
const query = new URLSearchParams({ select: openalexSelect });
|
|
563
|
+
const contact = this.contact();
|
|
564
|
+
if (contact)
|
|
565
|
+
query.set("mailto", contact);
|
|
566
|
+
try {
|
|
567
|
+
return normalizeOpenAlex(parseJson(await this.request("openalex", `/works/${encodeURI(id)}?${query}`, signal)));
|
|
568
|
+
}
|
|
569
|
+
catch (error) {
|
|
570
|
+
if (error.message === "record not found")
|
|
571
|
+
return undefined;
|
|
572
|
+
throw error;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
// -------------------------------------------------------------------------------------------
|
|
576
|
+
request(source, path, outer) {
|
|
577
|
+
if (source === "crossref") {
|
|
578
|
+
// Single flight: at most one Crossref request is in progress; callers queue behind it.
|
|
579
|
+
const run = this.crossrefTail.then(() => this.send(source, path, outer), () => this.send(source, path, outer));
|
|
580
|
+
this.crossrefTail = run.catch(() => undefined);
|
|
581
|
+
return run;
|
|
582
|
+
}
|
|
583
|
+
return this.send(source, path, outer);
|
|
584
|
+
}
|
|
585
|
+
async send(source, path, outer) {
|
|
586
|
+
outer?.throwIfAborted();
|
|
587
|
+
if (source === "arxiv") {
|
|
588
|
+
const slot = Math.max(this.clock.now(), this.arxivNext);
|
|
589
|
+
this.arxivNext = slot + limits.arxivSpacingMs;
|
|
590
|
+
const wait = slot - this.clock.now();
|
|
591
|
+
if (wait > 0)
|
|
592
|
+
await this.clock.sleep(wait, outer);
|
|
593
|
+
}
|
|
594
|
+
const signal = outer
|
|
595
|
+
? AbortSignal.any([outer, AbortSignal.timeout(this.timeoutMs)])
|
|
596
|
+
: AbortSignal.timeout(this.timeoutMs);
|
|
597
|
+
const contact = this.contact();
|
|
598
|
+
let response;
|
|
599
|
+
try {
|
|
600
|
+
response = await this.fetcher(`${origins[source]}${path}`, {
|
|
601
|
+
method: "GET",
|
|
602
|
+
redirect: "manual",
|
|
603
|
+
headers: {
|
|
604
|
+
accept: source === "arxiv" ? "application/atom+xml" : "application/json",
|
|
605
|
+
"user-agent": `alisio-plugin-thesis/${VERSION}${source === "crossref" && contact ? ` (mailto:${contact})` : ""}`,
|
|
606
|
+
},
|
|
607
|
+
signal,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
throw new Error("source unavailable");
|
|
612
|
+
}
|
|
613
|
+
if (response.status >= 300 && response.status < 400)
|
|
614
|
+
throw new Error("source returned redirect");
|
|
615
|
+
if (response.status === 404)
|
|
616
|
+
throw new Error("record not found");
|
|
617
|
+
if (response.status === 429)
|
|
618
|
+
throw new Error("source rate limited");
|
|
619
|
+
if (!response.ok)
|
|
620
|
+
throw new Error("source unavailable");
|
|
621
|
+
if (response.redirected)
|
|
622
|
+
throw new Error("source returned redirect");
|
|
623
|
+
return readCapped(response, signal);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
async function readCapped(response, signal) {
|
|
627
|
+
const reader = response.body?.getReader();
|
|
628
|
+
if (!reader)
|
|
629
|
+
return "";
|
|
630
|
+
const chunks = [];
|
|
631
|
+
let bytes = 0;
|
|
632
|
+
try {
|
|
633
|
+
for (;;) {
|
|
634
|
+
signal.throwIfAborted();
|
|
635
|
+
const next = await reader.read();
|
|
636
|
+
if (next.done)
|
|
637
|
+
break;
|
|
638
|
+
bytes += next.value.byteLength;
|
|
639
|
+
if (bytes > limits.responseBytes) {
|
|
640
|
+
await reader.cancel().catch(() => undefined);
|
|
641
|
+
throw new Error("response exceeded limit");
|
|
642
|
+
}
|
|
643
|
+
chunks.push(next.value);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
if (error.message === "response exceeded limit")
|
|
648
|
+
throw error;
|
|
649
|
+
throw new Error("source unavailable");
|
|
650
|
+
}
|
|
651
|
+
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
652
|
+
}
|
|
653
|
+
function parseJson(text) {
|
|
654
|
+
try {
|
|
655
|
+
return JSON.parse(text);
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
throw new Error("source unavailable");
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
//# sourceMappingURL=client.js.map
|