wiki-graph-core 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/data/editor/clue_reviewer.jinja +410 -0
- package/data/editor/clue_reviewer_generator.jinja +428 -0
- package/data/editor/revision_feedback.jinja +5 -0
- package/data/editor/text_compressor.jinja +127 -0
- package/data/guaranteed/response_intent_classifier.jinja +8 -0
- package/data/help/commands/archive/next.jinja +29 -0
- package/data/help/commands/gc.jinja +38 -0
- package/data/help/commands/legacy/migrate.jinja +20 -0
- package/data/help/commands/legacy.jinja +19 -0
- package/data/help/commands/maintenance/chapter/add.jinja +41 -0
- package/data/help/commands/maintenance/chapter/list.jinja +33 -0
- package/data/help/commands/maintenance/chapter/move.jinja +36 -0
- package/data/help/commands/maintenance/chapter/remove.jinja +26 -0
- package/data/help/commands/maintenance/chapter/reset.jinja +29 -0
- package/data/help/commands/maintenance/chapter/set-source.jinja +34 -0
- package/data/help/commands/maintenance/chapter/set-summary.jinja +31 -0
- package/data/help/commands/maintenance/chapter/set-title.jinja +29 -0
- package/data/help/commands/maintenance/chapter/tree.jinja +58 -0
- package/data/help/commands/maintenance/chapter.jinja +59 -0
- package/data/help/commands/maintenance/cover.jinja +28 -0
- package/data/help/commands/maintenance/meta.jinja +55 -0
- package/data/help/commands/predicate.jinja +460 -0
- package/data/help/commands/root.jinja +83 -0
- package/data/help/commands/transform.jinja +34 -0
- package/data/help/commands/uri.jinja +274 -0
- package/data/help/topics/config.jinja +88 -0
- package/data/help/topics/format.jinja +72 -0
- package/data/help/topics/readiness.jinja +99 -0
- package/data/help/topics/recipe.jinja +151 -0
- package/data/help/topics/runtime.jinja +62 -0
- package/data/help/topics/uri.jinja +178 -0
- package/data/output/epub/cover.xhtml.jinja +13 -0
- package/data/output/epub/nav.xhtml.jinja +12 -0
- package/data/output/epub/package.opf.xml.jinja +39 -0
- package/data/output/epub/section.xhtml.jinja +12 -0
- package/data/topologization/book_coherence_extraction.jinja +223 -0
- package/data/topologization/chunk_extraction.jinja +233 -0
- package/data/topologization/evidence_choice.jinja +38 -0
- package/data/topologization/translate_chunks.jinja +138 -0
- package/data/topologization/user_focused_extraction.jinja +378 -0
- package/dist/archive/query/archive-view.d.ts +26 -0
- package/dist/archive/query/archive-view.js +4540 -0
- package/dist/archive/query/archive-view.js.map +1 -0
- package/dist/archive/query/continuation-cursor.d.ts +61 -0
- package/dist/archive/query/continuation-cursor.js +363 -0
- package/dist/archive/query/continuation-cursor.js.map +1 -0
- package/dist/archive/query/index.d.ts +29 -0
- package/dist/archive/query/index.js +63 -0
- package/dist/archive/query/index.js.map +1 -0
- package/dist/archive/query/lexical-search.d.ts +22 -0
- package/dist/archive/query/lexical-search.js +137 -0
- package/dist/archive/query/lexical-search.js.map +1 -0
- package/dist/archive/query/search-cache.d.ts +192 -0
- package/dist/archive/query/search-cache.js +1248 -0
- package/dist/archive/query/search-cache.js.map +1 -0
- package/dist/archive/search-index/index.d.ts +26 -0
- package/dist/archive/search-index/index.js +29 -0
- package/dist/archive/search-index/index.js.map +1 -0
- package/dist/archive/search-index/search-index.d.ts +26 -0
- package/dist/archive/search-index/search-index.js +555 -0
- package/dist/archive/search-index/search-index.js.map +1 -0
- package/dist/archive/search-index/search-tokenizer.d.ts +16 -0
- package/dist/archive/search-index/search-tokenizer.js +225 -0
- package/dist/archive/search-index/search-tokenizer.js.map +1 -0
- package/dist/common/cli-command.d.ts +4 -0
- package/dist/common/cli-command.js +7 -0
- package/dist/common/cli-command.js.map +1 -0
- package/dist/common/data-dir.d.ts +3 -0
- package/dist/common/data-dir.js +48 -0
- package/dist/common/data-dir.js.map +1 -0
- package/dist/common/language.d.ts +55 -0
- package/dist/common/language.js +208 -0
- package/dist/common/language.js.map +1 -0
- package/dist/common/llm-scope.d.ts +19 -0
- package/dist/common/llm-scope.js +31 -0
- package/dist/common/llm-scope.js.map +1 -0
- package/dist/common/logging.d.ts +22 -0
- package/dist/common/logging.js +141 -0
- package/dist/common/logging.js.map +1 -0
- package/dist/common/template.d.ts +8 -0
- package/dist/common/template.js +54 -0
- package/dist/common/template.js.map +1 -0
- package/dist/common/tinyld-language.d.ts +6 -0
- package/dist/common/tinyld-language.js +34 -0
- package/dist/common/tinyld-language.js.map +1 -0
- package/dist/common/wiki-graph-dir.d.ts +10 -0
- package/dist/common/wiki-graph-dir.js +41 -0
- package/dist/common/wiki-graph-dir.js.map +1 -0
- package/dist/common/wiki-graph-temp.d.ts +6 -0
- package/dist/common/wiki-graph-temp.js +21 -0
- package/dist/common/wiki-graph-temp.js.map +1 -0
- package/dist/common/wiki-graph-uri.d.ts +28 -0
- package/dist/common/wiki-graph-uri.js +171 -0
- package/dist/common/wiki-graph-uri.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.js +13 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/task-context.d.ts +41 -0
- package/dist/context/task-context.js +111 -0
- package/dist/context/task-context.js.map +1 -0
- package/dist/document/database.d.ts +30 -0
- package/dist/document/database.js +273 -0
- package/dist/document/database.js.map +1 -0
- package/dist/document/document.d.ts +153 -0
- package/dist/document/document.js +615 -0
- package/dist/document/document.js.map +1 -0
- package/dist/document/fragments.d.ts +63 -0
- package/dist/document/fragments.js +371 -0
- package/dist/document/fragments.js.map +1 -0
- package/dist/document/index.d.ts +13 -0
- package/dist/document/index.js +62 -0
- package/dist/document/index.js.map +1 -0
- package/dist/document/schema.d.ts +8 -0
- package/dist/document/schema.js +472 -0
- package/dist/document/schema.js.map +1 -0
- package/dist/document/shared-state-database.d.ts +9 -0
- package/dist/document/shared-state-database.js +193 -0
- package/dist/document/shared-state-database.js.map +1 -0
- package/dist/document/stores.d.ts +203 -0
- package/dist/document/stores.js +1678 -0
- package/dist/document/stores.js.map +1 -0
- package/dist/document/text-streams.d.ts +86 -0
- package/dist/document/text-streams.js +515 -0
- package/dist/document/text-streams.js.map +1 -0
- package/dist/document/types.d.ts +148 -0
- package/dist/document/types.js +69 -0
- package/dist/document/types.js.map +1 -0
- package/dist/editor/clue.d.ts +27 -0
- package/dist/editor/clue.js +158 -0
- package/dist/editor/clue.js.map +1 -0
- package/dist/editor/compressor.d.ts +18 -0
- package/dist/editor/compressor.js +68 -0
- package/dist/editor/compressor.js.map +1 -0
- package/dist/editor/editor.d.ts +39 -0
- package/dist/editor/editor.js +253 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/feedback.d.ts +16 -0
- package/dist/editor/feedback.js +104 -0
- package/dist/editor/feedback.js.map +1 -0
- package/dist/editor/index.d.ts +17 -0
- package/dist/editor/index.js +5 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/language-review.d.ts +14 -0
- package/dist/editor/language-review.js +35 -0
- package/dist/editor/language-review.js.map +1 -0
- package/dist/editor/log.d.ts +37 -0
- package/dist/editor/log.js +202 -0
- package/dist/editor/log.js.map +1 -0
- package/dist/editor/markup.d.ts +20 -0
- package/dist/editor/markup.js +294 -0
- package/dist/editor/markup.js.map +1 -0
- package/dist/editor/prompt-templates.d.ts +6 -0
- package/dist/editor/prompt-templates.js +11 -0
- package/dist/editor/prompt-templates.js.map +1 -0
- package/dist/editor/response.d.ts +5 -0
- package/dist/editor/response.js +31 -0
- package/dist/editor/response.js.map +1 -0
- package/dist/editor/review.d.ts +34 -0
- package/dist/editor/review.js +189 -0
- package/dist/editor/review.js.map +1 -0
- package/dist/editor/types.d.ts +31 -0
- package/dist/editor/types.js +21 -0
- package/dist/editor/types.js.map +1 -0
- package/dist/evidence-selection/anchor-resolver.d.ts +43 -0
- package/dist/evidence-selection/anchor-resolver.js +783 -0
- package/dist/evidence-selection/anchor-resolver.js.map +1 -0
- package/dist/evidence-selection/anchor-types.d.ts +27 -0
- package/dist/evidence-selection/anchor-types.js +1 -0
- package/dist/evidence-selection/anchor-types.js.map +1 -0
- package/dist/evidence-selection/index.d.ts +8 -0
- package/dist/evidence-selection/index.js +32 -0
- package/dist/evidence-selection/index.js.map +1 -0
- package/dist/evidence-selection/prompt.d.ts +18 -0
- package/dist/evidence-selection/prompt.js +54 -0
- package/dist/evidence-selection/prompt.js.map +1 -0
- package/dist/evidence-selection/quote-score.d.ts +29 -0
- package/dist/evidence-selection/quote-score.js +331 -0
- package/dist/evidence-selection/quote-score.js.map +1 -0
- package/dist/evidence-selection/selection-resolver.d.ts +19 -0
- package/dist/evidence-selection/selection-resolver.js +303 -0
- package/dist/evidence-selection/selection-resolver.js.map +1 -0
- package/dist/evidence-selection/text.d.ts +4 -0
- package/dist/evidence-selection/text.js +66 -0
- package/dist/evidence-selection/text.js.map +1 -0
- package/dist/evidence-selection/types.d.ts +36 -0
- package/dist/evidence-selection/types.js +1 -0
- package/dist/evidence-selection/types.js.map +1 -0
- package/dist/facade/app.d.ts +75 -0
- package/dist/facade/app.js +141 -0
- package/dist/facade/app.js.map +1 -0
- package/dist/facade/build-queue.d.ts +181 -0
- package/dist/facade/build-queue.js +1442 -0
- package/dist/facade/build-queue.js.map +1 -0
- package/dist/facade/chapter-build.d.ts +60 -0
- package/dist/facade/chapter-build.js +1020 -0
- package/dist/facade/chapter-build.js.map +1 -0
- package/dist/facade/chapter.d.ts +168 -0
- package/dist/facade/chapter.js +944 -0
- package/dist/facade/chapter.js.map +1 -0
- package/dist/facade/digest.d.ts +55 -0
- package/dist/facade/digest.js +168 -0
- package/dist/facade/digest.js.map +1 -0
- package/dist/facade/graph.d.ts +60 -0
- package/dist/facade/graph.js +203 -0
- package/dist/facade/graph.js.map +1 -0
- package/dist/facade/import.d.ts +49 -0
- package/dist/facade/import.js +262 -0
- package/dist/facade/import.js.map +1 -0
- package/dist/facade/index.d.ts +39 -0
- package/dist/facade/index.js +171 -0
- package/dist/facade/index.js.map +1 -0
- package/dist/facade/knowledge-graph-build.d.ts +75 -0
- package/dist/facade/knowledge-graph-build.js +897 -0
- package/dist/facade/knowledge-graph-build.js.map +1 -0
- package/dist/facade/llm-sampling.d.ts +11 -0
- package/dist/facade/llm-sampling.js +58 -0
- package/dist/facade/llm-sampling.js.map +1 -0
- package/dist/facade/types.d.ts +8 -0
- package/dist/facade/types.js +1 -0
- package/dist/facade/types.js.map +1 -0
- package/dist/facade/wiki-graph-archive.d.ts +41 -0
- package/dist/facade/wiki-graph-archive.js +130 -0
- package/dist/facade/wiki-graph-archive.js.map +1 -0
- package/dist/gc/files.d.ts +15 -0
- package/dist/gc/files.js +141 -0
- package/dist/gc/files.js.map +1 -0
- package/dist/gc/index.d.ts +2 -0
- package/dist/gc/index.js +5 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/gc/lock.d.ts +3 -0
- package/dist/gc/lock.js +137 -0
- package/dist/gc/lock.js.map +1 -0
- package/dist/gc/runner.d.ts +9 -0
- package/dist/gc/runner.js +129 -0
- package/dist/gc/runner.js.map +1 -0
- package/dist/gc/tmp-gc.d.ts +5 -0
- package/dist/gc/tmp-gc.js +57 -0
- package/dist/gc/tmp-gc.js.map +1 -0
- package/dist/gc/types.d.ts +24 -0
- package/dist/gc/types.js +1 -0
- package/dist/gc/types.js.map +1 -0
- package/dist/gc.cjs +10041 -0
- package/dist/gc.cjs.map +1 -0
- package/dist/gc.d.cts +10 -0
- package/dist/gc.d.ts +2 -0
- package/dist/gc.js +5 -0
- package/dist/gc.js.map +1 -0
- package/dist/guaranteed/classifier.d.ts +10 -0
- package/dist/guaranteed/classifier.js +88 -0
- package/dist/guaranteed/classifier.js.map +1 -0
- package/dist/guaranteed/errors.d.ts +38 -0
- package/dist/guaranteed/errors.js +73 -0
- package/dist/guaranteed/errors.js.map +1 -0
- package/dist/guaranteed/index.d.ts +7 -0
- package/dist/guaranteed/index.js +21 -0
- package/dist/guaranteed/index.js.map +1 -0
- package/dist/guaranteed/request.d.ts +8 -0
- package/dist/guaranteed/request.js +206 -0
- package/dist/guaranteed/request.js.map +1 -0
- package/dist/guaranteed/response.d.ts +12 -0
- package/dist/guaranteed/response.js +98 -0
- package/dist/guaranteed/response.js.map +1 -0
- package/dist/guaranteed/types.d.ts +20 -0
- package/dist/guaranteed/types.js +1 -0
- package/dist/guaranteed/types.js.map +1 -0
- package/dist/index-B8NNnQ8P.d.ts +424 -0
- package/dist/index.cjs +34774 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2462 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-sdpub/upgrade.d.ts +7 -0
- package/dist/legacy-sdpub/upgrade.js +795 -0
- package/dist/legacy-sdpub/upgrade.js.map +1 -0
- package/dist/llm/cache.d.ts +13 -0
- package/dist/llm/cache.js +35 -0
- package/dist/llm/cache.js.map +1 -0
- package/dist/llm/client.d.ts +26 -0
- package/dist/llm/client.js +572 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/context.d.ts +22 -0
- package/dist/llm/context.js +78 -0
- package/dist/llm/context.js.map +1 -0
- package/dist/llm/errors.d.ts +7 -0
- package/dist/llm/errors.js +12 -0
- package/dist/llm/errors.js.map +1 -0
- package/dist/llm/index.d.ts +7 -0
- package/dist/llm/index.js +17 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/request-log.d.ts +9 -0
- package/dist/llm/request-log.js +35 -0
- package/dist/llm/request-log.js.map +1 -0
- package/dist/llm/sampling.d.ts +11 -0
- package/dist/llm/sampling.js +67 -0
- package/dist/llm/sampling.js.map +1 -0
- package/dist/llm/types.d.ts +50 -0
- package/dist/llm/types.js +1 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/output/epub/archive.d.ts +9 -0
- package/dist/output/epub/archive.js +81 -0
- package/dist/output/epub/archive.js.map +1 -0
- package/dist/output/epub/book.d.ts +15 -0
- package/dist/output/epub/book.js +76 -0
- package/dist/output/epub/book.js.map +1 -0
- package/dist/output/epub/content.d.ts +9 -0
- package/dist/output/epub/content.js +35 -0
- package/dist/output/epub/content.js.map +1 -0
- package/dist/output/epub/index.d.ts +20 -0
- package/dist/output/epub/index.js +14 -0
- package/dist/output/epub/index.js.map +1 -0
- package/dist/output/epub/model.d.ts +24 -0
- package/dist/output/epub/model.js +1 -0
- package/dist/output/epub/model.js.map +1 -0
- package/dist/output/epub/navigation.d.ts +10 -0
- package/dist/output/epub/navigation.js +39 -0
- package/dist/output/epub/navigation.js.map +1 -0
- package/dist/output/epub/package.d.ts +17 -0
- package/dist/output/epub/package.js +29 -0
- package/dist/output/epub/package.js.map +1 -0
- package/dist/output/epub/shared.d.ts +4 -0
- package/dist/output/epub/shared.js +12 -0
- package/dist/output/epub/shared.js.map +1 -0
- package/dist/output/epub/templates.d.ts +35 -0
- package/dist/output/epub/templates.js +26 -0
- package/dist/output/epub/templates.js.map +1 -0
- package/dist/output/index.d.ts +14 -0
- package/dist/output/index.js +11 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/plain-text.d.ts +18 -0
- package/dist/output/plain-text.js +56 -0
- package/dist/output/plain-text.js.map +1 -0
- package/dist/progress/index.d.ts +3 -0
- package/dist/progress/index.js +14 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/reporter.d.ts +10 -0
- package/dist/progress/reporter.js +79 -0
- package/dist/progress/reporter.js.map +1 -0
- package/dist/progress/tracker.d.ts +37 -0
- package/dist/progress/tracker.js +119 -0
- package/dist/progress/tracker.js.map +1 -0
- package/dist/progress/types.d.ts +28 -0
- package/dist/progress/types.js +1 -0
- package/dist/progress/types.js.map +1 -0
- package/dist/reader/attention/attention.d.ts +39 -0
- package/dist/reader/attention/attention.js +123 -0
- package/dist/reader/attention/attention.js.map +1 -0
- package/dist/reader/attention/index.d.ts +9 -0
- package/dist/reader/attention/index.js +5 -0
- package/dist/reader/attention/index.js.map +1 -0
- package/dist/reader/attention/wave-reflection.d.ts +21 -0
- package/dist/reader/attention/wave-reflection.js +153 -0
- package/dist/reader/attention/wave-reflection.js.map +1 -0
- package/dist/reader/attention/working-memory.d.ts +28 -0
- package/dist/reader/attention/working-memory.js +62 -0
- package/dist/reader/attention/working-memory.js.map +1 -0
- package/dist/reader/chunk-batch/extract.d.ts +13 -0
- package/dist/reader/chunk-batch/extract.js +14 -0
- package/dist/reader/chunk-batch/extract.js.map +1 -0
- package/dist/reader/chunk-batch/extractor.d.ts +17 -0
- package/dist/reader/chunk-batch/extractor.js +337 -0
- package/dist/reader/chunk-batch/extractor.js.map +1 -0
- package/dist/reader/chunk-batch/fragment-projection.d.ts +34 -0
- package/dist/reader/chunk-batch/fragment-projection.js +94 -0
- package/dist/reader/chunk-batch/fragment-projection.js.map +1 -0
- package/dist/reader/chunk-batch/index.d.ts +12 -0
- package/dist/reader/chunk-batch/index.js +13 -0
- package/dist/reader/chunk-batch/index.js.map +1 -0
- package/dist/reader/chunk-batch/language.d.ts +9 -0
- package/dist/reader/chunk-batch/language.js +23 -0
- package/dist/reader/chunk-batch/language.js.map +1 -0
- package/dist/reader/chunk-batch/parser.d.ts +94 -0
- package/dist/reader/chunk-batch/parser.js +640 -0
- package/dist/reader/chunk-batch/parser.js.map +1 -0
- package/dist/reader/chunk-batch/prompt-templates.d.ts +6 -0
- package/dist/reader/chunk-batch/prompt-templates.js +11 -0
- package/dist/reader/chunk-batch/prompt-templates.js.map +1 -0
- package/dist/reader/chunk-batch/types.d.ts +85 -0
- package/dist/reader/chunk-batch/types.js +1 -0
- package/dist/reader/chunk-batch/types.js.map +1 -0
- package/dist/reader/index.d.ts +13 -0
- package/dist/reader/index.js +7 -0
- package/dist/reader/index.js.map +1 -0
- package/dist/reader/reader.d.ts +37 -0
- package/dist/reader/reader.js +82 -0
- package/dist/reader/reader.js.map +1 -0
- package/dist/reader/segment/index.d.ts +2 -0
- package/dist/reader/segment/index.js +5 -0
- package/dist/reader/segment/index.js.map +1 -0
- package/dist/reader/segment/intl-segmenter.d.ts +5 -0
- package/dist/reader/segment/intl-segmenter.js +102 -0
- package/dist/reader/segment/intl-segmenter.js.map +1 -0
- package/dist/reader/segment/segment.d.ts +5 -0
- package/dist/reader/segment/segment.js +9 -0
- package/dist/reader/segment/segment.js.map +1 -0
- package/dist/reader/segment/types.d.ts +14 -0
- package/dist/reader/segment/types.js +1 -0
- package/dist/reader/segment/types.js.map +1 -0
- package/dist/reader/types.d.ts +29 -0
- package/dist/reader/types.js +1 -0
- package/dist/reader/types.js.map +1 -0
- package/dist/serial.d.ts +89 -0
- package/dist/serial.js +476 -0
- package/dist/serial.js.map +1 -0
- package/dist/source/adapter.d.ts +15 -0
- package/dist/source/adapter.js +1 -0
- package/dist/source/adapter.js.map +1 -0
- package/dist/source/epub/archive.d.ts +27 -0
- package/dist/source/epub/archive.js +189 -0
- package/dist/source/epub/archive.js.map +1 -0
- package/dist/source/epub/content.d.ts +22 -0
- package/dist/source/epub/content.js +183 -0
- package/dist/source/epub/content.js.map +1 -0
- package/dist/source/epub/document.d.ts +55 -0
- package/dist/source/epub/document.js +179 -0
- package/dist/source/epub/document.js.map +1 -0
- package/dist/source/epub/index.d.ts +10 -0
- package/dist/source/epub/index.js +6 -0
- package/dist/source/epub/index.js.map +1 -0
- package/dist/source/epub/navigation.d.ts +16 -0
- package/dist/source/epub/navigation.js +215 -0
- package/dist/source/epub/navigation.js.map +1 -0
- package/dist/source/epub/package.d.ts +33 -0
- package/dist/source/epub/package.js +237 -0
- package/dist/source/epub/package.js.map +1 -0
- package/dist/source/epub/xml.d.ts +16 -0
- package/dist/source/epub/xml.js +111 -0
- package/dist/source/epub/xml.js.map +1 -0
- package/dist/source/index.d.ts +12 -0
- package/dist/source/index.js +32 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/meta.d.ts +30 -0
- package/dist/source/meta.js +22 -0
- package/dist/source/meta.js.map +1 -0
- package/dist/source/plain-text.d.ts +16 -0
- package/dist/source/plain-text.js +86 -0
- package/dist/source/plain-text.js.map +1 -0
- package/dist/source/toc.d.ts +16 -0
- package/dist/source/toc.js +17 -0
- package/dist/source/toc.js.map +1 -0
- package/dist/source/types.d.ts +16 -0
- package/dist/source/types.js +1 -0
- package/dist/source/types.js.map +1 -0
- package/dist/topology/grouping.d.ts +15 -0
- package/dist/topology/grouping.js +18 -0
- package/dist/topology/grouping.js.map +1 -0
- package/dist/topology/index.d.ts +21 -0
- package/dist/topology/index.js +5 -0
- package/dist/topology/index.js.map +1 -0
- package/dist/topology/resource-segmentation.d.ts +13 -0
- package/dist/topology/resource-segmentation.js +111 -0
- package/dist/topology/resource-segmentation.js.map +1 -0
- package/dist/topology/segment-incision.d.ts +18 -0
- package/dist/topology/segment-incision.js +197 -0
- package/dist/topology/segment-incision.js.map +1 -0
- package/dist/topology/snake-detector.d.ts +13 -0
- package/dist/topology/snake-detector.js +520 -0
- package/dist/topology/snake-detector.js.map +1 -0
- package/dist/topology/snake-graph-builder.d.ts +14 -0
- package/dist/topology/snake-graph-builder.js +76 -0
- package/dist/topology/snake-graph-builder.js.map +1 -0
- package/dist/topology/topology.d.ts +29 -0
- package/dist/topology/topology.js +348 -0
- package/dist/topology/topology.js.map +1 -0
- package/dist/topology/weights.d.ts +10 -0
- package/dist/topology/weights.js +84 -0
- package/dist/topology/weights.js.map +1 -0
- package/dist/types-FVIqiLC9.d.cts +24 -0
- package/dist/utils/async-semaphore.d.ts +7 -0
- package/dist/utils/async-semaphore.js +40 -0
- package/dist/utils/async-semaphore.js.map +1 -0
- package/dist/utils/enum.d.ts +5 -0
- package/dist/utils/enum.js +18 -0
- package/dist/utils/enum.js.map +1 -0
- package/dist/utils/hash.d.ts +3 -0
- package/dist/utils/hash.js +132 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/node-error.d.ts +4 -0
- package/dist/utils/node-error.js +59 -0
- package/dist/utils/node-error.js.map +1 -0
- package/dist/wikg/archive-uri.d.ts +1 -0
- package/dist/wikg/archive-uri.js +37 -0
- package/dist/wikg/archive-uri.js.map +1 -0
- package/dist/wikg/archive.d.ts +28 -0
- package/dist/wikg/archive.js +496 -0
- package/dist/wikg/archive.js.map +1 -0
- package/dist/wikg/index.d.ts +31 -0
- package/dist/wikg/index.js +60 -0
- package/dist/wikg/index.js.map +1 -0
- package/dist/wikg/wikg-coordinator.d.ts +45 -0
- package/dist/wikg/wikg-coordinator.js +1687 -0
- package/dist/wikg/wikg-coordinator.js.map +1 -0
- package/dist/wikg/wiki-graph-archive-file.d.ts +42 -0
- package/dist/wikg/wiki-graph-archive-file.js +78 -0
- package/dist/wikg/wiki-graph-archive-file.js.map +1 -0
- package/dist/wikilink/index.d.ts +10 -0
- package/dist/wikilink/index.js +7 -0
- package/dist/wikilink/index.js.map +1 -0
- package/dist/wikilink/relation-discovery.d.ts +31 -0
- package/dist/wikilink/relation-discovery.js +477 -0
- package/dist/wikilink/relation-discovery.js.map +1 -0
- package/dist/wikilink/types.d.ts +23 -0
- package/dist/wikilink/types.js +1 -0
- package/dist/wikilink/types.js.map +1 -0
- package/dist/wikilink/window.d.ts +7 -0
- package/dist/wikilink/window.js +53 -0
- package/dist/wikilink/window.js.map +1 -0
- package/dist/wikimatch/enrichment.d.ts +10 -0
- package/dist/wikimatch/enrichment.js +55 -0
- package/dist/wikimatch/enrichment.js.map +1 -0
- package/dist/wikimatch/index.d.ts +16 -0
- package/dist/wikimatch/index.js +66 -0
- package/dist/wikimatch/index.js.map +1 -0
- package/dist/wikimatch/option-narrowing.d.ts +17 -0
- package/dist/wikimatch/option-narrowing.js +208 -0
- package/dist/wikimatch/option-narrowing.js.map +1 -0
- package/dist/wikimatch/options.d.ts +14 -0
- package/dist/wikimatch/options.js +155 -0
- package/dist/wikimatch/options.js.map +1 -0
- package/dist/wikimatch/policy-judge.d.ts +17 -0
- package/dist/wikimatch/policy-judge.js +430 -0
- package/dist/wikimatch/policy-judge.js.map +1 -0
- package/dist/wikimatch/range-suppression.d.ts +9 -0
- package/dist/wikimatch/range-suppression.js +27 -0
- package/dist/wikimatch/range-suppression.js.map +1 -0
- package/dist/wikimatch/surface-screening.d.ts +16 -0
- package/dist/wikimatch/surface-screening.js +168 -0
- package/dist/wikimatch/surface-screening.js.map +1 -0
- package/dist/wikimatch/surface-window.d.ts +6 -0
- package/dist/wikimatch/surface-window.js +44 -0
- package/dist/wikimatch/surface-window.js.map +1 -0
- package/dist/wikimatch/types.d.ts +151 -0
- package/dist/wikimatch/types.js +1 -0
- package/dist/wikimatch/types.js.map +1 -0
- package/dist/wikimatch/wikispine.d.ts +43 -0
- package/dist/wikimatch/wikispine.js +399 -0
- package/dist/wikimatch/wikispine.js.map +1 -0
- package/dist/wikimatch/window.d.ts +6 -0
- package/dist/wikimatch/window.js +83 -0
- package/dist/wikimatch/window.js.map +1 -0
- package/dist/wikimatch/words.d.ts +16 -0
- package/dist/wikimatch/words.js +66 -0
- package/dist/wikimatch/words.js.map +1 -0
- package/dist/wikipage/cache.d.ts +18 -0
- package/dist/wikipage/cache.js +404 -0
- package/dist/wikipage/cache.js.map +1 -0
- package/dist/wikipage/fetch-log.d.ts +17 -0
- package/dist/wikipage/fetch-log.js +143 -0
- package/dist/wikipage/fetch-log.js.map +1 -0
- package/dist/wikipage/index.d.ts +14 -0
- package/dist/wikipage/index.js +17 -0
- package/dist/wikipage/index.js.map +1 -0
- package/dist/wikipage/normalizer.d.ts +14 -0
- package/dist/wikipage/normalizer.js +147 -0
- package/dist/wikipage/normalizer.js.map +1 -0
- package/dist/wikipage/rate-limiter.d.ts +13 -0
- package/dist/wikipage/rate-limiter.js +84 -0
- package/dist/wikipage/rate-limiter.js.map +1 -0
- package/dist/wikipage/resolver.d.ts +26 -0
- package/dist/wikipage/resolver.js +325 -0
- package/dist/wikipage/resolver.js.map +1 -0
- package/dist/wikipage/types.d.ts +96 -0
- package/dist/wikipage/types.js +1 -0
- package/dist/wikipage/types.js.map +1 -0
- package/dist/wikipage/wikimedia-client.d.ts +48 -0
- package/dist/wikipage/wikimedia-client.js +397 -0
- package/dist/wikipage/wikimedia-client.js.map +1 -0
- package/dist/worker-BgQ0Xl8T.d.cts +181 -0
- package/dist/worker.cjs +5259 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +2 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +5 -0
- package/dist/worker.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
import { createWriteStream } from "fs";
|
|
2
|
+
import { mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
|
|
3
|
+
import { dirname, join, posix, resolve, sep } from "path";
|
|
4
|
+
import { pipeline } from "stream/promises";
|
|
5
|
+
import { createWikiGraphTempDirectory } from "../common/wiki-graph-temp.js";
|
|
6
|
+
import {
|
|
7
|
+
open as openZip
|
|
8
|
+
} from "yauzl";
|
|
9
|
+
import { Database } from "../document/database.js";
|
|
10
|
+
import { DirectoryDocument } from "../document/document.js";
|
|
11
|
+
import { writeWikgArchive } from "../wikg/index.js";
|
|
12
|
+
import { isNodeError } from "../utils/node-error.js";
|
|
13
|
+
const LEGACY_SDPUB_PATTERNS = [
|
|
14
|
+
/^manifest\.json$/u,
|
|
15
|
+
/^database\.db$/u,
|
|
16
|
+
/^toc\.json$/u,
|
|
17
|
+
/^cover\/(?:data\.bin|info\.json)$/u,
|
|
18
|
+
/^summaries\/serial-\d+\.txt$/u,
|
|
19
|
+
/^fragments\/serial-\d+\/fragment_\d+\.json$/u
|
|
20
|
+
];
|
|
21
|
+
const LEGACY_FORMAT_VERSION = 1;
|
|
22
|
+
async function migrateLegacySdpubToWikg(inputPath, outputPath = defaultWikgOutputPath(inputPath)) {
|
|
23
|
+
if (resolve(inputPath) === resolve(outputPath)) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Legacy migration output path must differ from input path."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const workspacePath = await createWikiGraphTempDirectory("sdpub-upgrade");
|
|
29
|
+
try {
|
|
30
|
+
await extractLegacySdpubArchive(inputPath, workspacePath);
|
|
31
|
+
await migrateLegacyDatabase(join(workspacePath, "database.db"));
|
|
32
|
+
await migrateLegacyTextStorage(workspacePath);
|
|
33
|
+
await writeWikgArchive(workspacePath, outputPath);
|
|
34
|
+
return { inputPath, outputPath };
|
|
35
|
+
} finally {
|
|
36
|
+
await rm(workspacePath, { force: true, recursive: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function defaultWikgOutputPath(inputPath) {
|
|
40
|
+
if (inputPath.toLowerCase().endsWith(".sdpub")) {
|
|
41
|
+
return `${inputPath.slice(0, -".sdpub".length)}.wikg`;
|
|
42
|
+
}
|
|
43
|
+
return `${inputPath}.wikg`;
|
|
44
|
+
}
|
|
45
|
+
async function extractLegacySdpubArchive(inputPath, outputDirectoryPath) {
|
|
46
|
+
const zipFile = await openArchive(inputPath);
|
|
47
|
+
try {
|
|
48
|
+
const entries = await indexArchiveEntries(zipFile);
|
|
49
|
+
await assertLegacySdpubArchive(zipFile, entries);
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const archivePath = normalizeArchivePath(entry.fileName);
|
|
52
|
+
if (archivePath === "" || !isLegacySdpubPath(archivePath)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const targetPath = resolve(outputDirectoryPath, archivePath);
|
|
56
|
+
assertWithinDirectory(outputDirectoryPath, targetPath, archivePath);
|
|
57
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
58
|
+
await pipeline(
|
|
59
|
+
await openArchiveEntryStream(zipFile, entry),
|
|
60
|
+
createWriteStream(targetPath)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
} finally {
|
|
64
|
+
zipFile.close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function assertLegacySdpubArchive(zipFile, entries) {
|
|
68
|
+
const paths = new Set(
|
|
69
|
+
entries.map((entry) => normalizeArchivePath(entry.fileName))
|
|
70
|
+
);
|
|
71
|
+
if (!paths.has("database.db") || !paths.has("toc.json")) {
|
|
72
|
+
throw new Error("Unsupported legacy sdpub archive.");
|
|
73
|
+
}
|
|
74
|
+
if (paths.has("manifest.json")) {
|
|
75
|
+
const manifestEntry = entries.find(
|
|
76
|
+
(entry) => normalizeArchivePath(entry.fileName) === "manifest.json"
|
|
77
|
+
);
|
|
78
|
+
if (manifestEntry === void 0) {
|
|
79
|
+
throw new Error("Unsupported legacy sdpub archive.");
|
|
80
|
+
}
|
|
81
|
+
assertSupportedManifest(await readArchiveEntryText(zipFile, manifestEntry));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function assertSupportedManifest(content) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(content);
|
|
87
|
+
if (parsed.formatVersion === LEGACY_FORMAT_VERSION) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
throw new Error("Unsupported legacy sdpub archive.");
|
|
92
|
+
}
|
|
93
|
+
throw new Error("Unsupported legacy sdpub archive.");
|
|
94
|
+
}
|
|
95
|
+
async function migrateLegacyDatabase(databasePath) {
|
|
96
|
+
const database = await Database.open(databasePath);
|
|
97
|
+
try {
|
|
98
|
+
await migrateKnowledgeEdges(database);
|
|
99
|
+
await migrateSerialDocumentOrder(database);
|
|
100
|
+
} finally {
|
|
101
|
+
await database.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function migrateKnowledgeEdges(database) {
|
|
105
|
+
const tables = await listTableNames(database);
|
|
106
|
+
if (tables.has("reading_edges")) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!tables.has("knowledge_edges")) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
await database.run(`
|
|
113
|
+
ALTER TABLE knowledge_edges
|
|
114
|
+
RENAME TO reading_edges
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
async function migrateSerialDocumentOrder(database) {
|
|
118
|
+
const columns = await listTableColumns(database, "serials");
|
|
119
|
+
if (!columns.has("document_order")) {
|
|
120
|
+
await database.run(`
|
|
121
|
+
ALTER TABLE serials
|
|
122
|
+
ADD COLUMN document_order INTEGER NOT NULL DEFAULT 0
|
|
123
|
+
`);
|
|
124
|
+
}
|
|
125
|
+
await database.run(`
|
|
126
|
+
CREATE INDEX IF NOT EXISTS idx_serials_document_order
|
|
127
|
+
ON serials(document_order, id)
|
|
128
|
+
`);
|
|
129
|
+
}
|
|
130
|
+
async function migrateLegacyTextStorage(workspacePath) {
|
|
131
|
+
const sourceSerials = await listLegacySourceSerials(workspacePath);
|
|
132
|
+
const remaps = /* @__PURE__ */ new Map();
|
|
133
|
+
for (const serialId of sourceSerials) {
|
|
134
|
+
const fragments = await readLegacySourceFragments(workspacePath, serialId);
|
|
135
|
+
const plan = createDuplicateHalfCanonicalizationPlan(fragments);
|
|
136
|
+
const canonicalFragments = plan?.canonicalFragments ?? fragments;
|
|
137
|
+
const fragmentIdMap = plan?.fragmentIdMap ?? /* @__PURE__ */ new Map();
|
|
138
|
+
const canonicalById = new Map(
|
|
139
|
+
canonicalFragments.map((fragment) => [fragment.fragmentId, fragment])
|
|
140
|
+
);
|
|
141
|
+
const sentenceMap = /* @__PURE__ */ new Map();
|
|
142
|
+
const textParts = [];
|
|
143
|
+
let globalSentenceIndex = 0;
|
|
144
|
+
for (const fragment of canonicalFragments) {
|
|
145
|
+
for (let localSentenceIndex = 0; localSentenceIndex < fragment.content.sentences.length; localSentenceIndex += 1) {
|
|
146
|
+
const sentence = fragment.content.sentences[localSentenceIndex];
|
|
147
|
+
if (sentence === void 0) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
sentenceMap.set(
|
|
151
|
+
`${fragment.fragmentId}:${localSentenceIndex}`,
|
|
152
|
+
globalSentenceIndex
|
|
153
|
+
);
|
|
154
|
+
textParts.push(sentence.text);
|
|
155
|
+
globalSentenceIndex += 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const [oldFragmentId, canonicalFragmentId] of fragmentIdMap) {
|
|
159
|
+
const canonicalFragment = canonicalById.get(canonicalFragmentId);
|
|
160
|
+
if (canonicalFragment === void 0) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
for (let localSentenceIndex = 0; localSentenceIndex < canonicalFragment.content.sentences.length; localSentenceIndex += 1) {
|
|
164
|
+
const mapped = sentenceMap.get(
|
|
165
|
+
`${canonicalFragmentId}:${localSentenceIndex}`
|
|
166
|
+
);
|
|
167
|
+
if (mapped !== void 0) {
|
|
168
|
+
sentenceMap.set(`${oldFragmentId}:${localSentenceIndex}`, mapped);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
remaps.set(serialId, {
|
|
173
|
+
get: (fragmentId, sentenceIndex) => sentenceMap.get(`${fragmentId}:${sentenceIndex}`),
|
|
174
|
+
serialId
|
|
175
|
+
});
|
|
176
|
+
const database = await Database.open(join(workspacePath, "database.db"));
|
|
177
|
+
try {
|
|
178
|
+
await writeLegacySourceTextStream(database, workspacePath, {
|
|
179
|
+
fragments: canonicalFragments,
|
|
180
|
+
serialId,
|
|
181
|
+
text: textParts.join("")
|
|
182
|
+
});
|
|
183
|
+
} finally {
|
|
184
|
+
await database.close();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
await migrateLegacySentenceReferences(workspacePath, remaps);
|
|
188
|
+
await migrateLegacySummariesToTextStreams(workspacePath);
|
|
189
|
+
await rm(join(workspacePath, "fragments"), { force: true, recursive: true });
|
|
190
|
+
await rm(join(workspacePath, "summaries"), { force: true, recursive: true });
|
|
191
|
+
}
|
|
192
|
+
async function migrateLegacySentenceReferences(workspacePath, remaps) {
|
|
193
|
+
const database = await Database.open(join(workspacePath, "database.db"));
|
|
194
|
+
try {
|
|
195
|
+
const tableNames = await listTableNames(database);
|
|
196
|
+
await database.transaction(async () => {
|
|
197
|
+
if (tableNames.has("chunks")) {
|
|
198
|
+
await migrateLegacyChunks(database, remaps);
|
|
199
|
+
}
|
|
200
|
+
if (tableNames.has("chunk_sentences")) {
|
|
201
|
+
await migrateLegacyChunkSentences(database, remaps);
|
|
202
|
+
}
|
|
203
|
+
if (tableNames.has("mentions")) {
|
|
204
|
+
await migrateLegacyMentions(database, remaps);
|
|
205
|
+
}
|
|
206
|
+
if (tableNames.has("mention_link_evidence_sentences")) {
|
|
207
|
+
await migrateLegacyMentionLinkEvidenceSentences(database, remaps);
|
|
208
|
+
}
|
|
209
|
+
if (tableNames.has("fragment_groups")) {
|
|
210
|
+
await migrateLegacyFragmentGroups(database, remaps);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
} finally {
|
|
214
|
+
await database.close();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async function writeLegacySourceTextStream(database, workspacePath, input) {
|
|
218
|
+
await database.run(`
|
|
219
|
+
CREATE TABLE IF NOT EXISTS text_sentence_records (
|
|
220
|
+
id INTEGER PRIMARY KEY,
|
|
221
|
+
kind INTEGER NOT NULL,
|
|
222
|
+
chapter_id INTEGER NOT NULL,
|
|
223
|
+
sentence_index INTEGER NOT NULL,
|
|
224
|
+
words_count INTEGER NOT NULL DEFAULT 0,
|
|
225
|
+
byte_offset INTEGER NOT NULL DEFAULT 0,
|
|
226
|
+
byte_length INTEGER NOT NULL DEFAULT 0,
|
|
227
|
+
UNIQUE(kind, chapter_id, sentence_index)
|
|
228
|
+
)
|
|
229
|
+
`);
|
|
230
|
+
await mkdir(join(workspacePath, "texts", "source"), { recursive: true });
|
|
231
|
+
await writeFile(
|
|
232
|
+
join(workspacePath, "texts", "source", `${input.serialId}.txt`),
|
|
233
|
+
input.text,
|
|
234
|
+
"utf8"
|
|
235
|
+
);
|
|
236
|
+
await database.run(
|
|
237
|
+
`
|
|
238
|
+
DELETE FROM text_sentence_records
|
|
239
|
+
WHERE kind = 1 AND chapter_id = ?
|
|
240
|
+
`,
|
|
241
|
+
[input.serialId]
|
|
242
|
+
);
|
|
243
|
+
let byteOffset = 0;
|
|
244
|
+
let sentenceIndex = 0;
|
|
245
|
+
for (const fragment of input.fragments) {
|
|
246
|
+
for (const sentence of fragment.content.sentences) {
|
|
247
|
+
const byteLength = Buffer.byteLength(sentence.text, "utf8");
|
|
248
|
+
await database.run(
|
|
249
|
+
`
|
|
250
|
+
INSERT OR REPLACE INTO text_sentence_records (
|
|
251
|
+
kind,
|
|
252
|
+
chapter_id,
|
|
253
|
+
sentence_index,
|
|
254
|
+
words_count,
|
|
255
|
+
byte_offset,
|
|
256
|
+
byte_length
|
|
257
|
+
)
|
|
258
|
+
VALUES (1, ?, ?, ?, ?, ?)
|
|
259
|
+
`,
|
|
260
|
+
[
|
|
261
|
+
input.serialId,
|
|
262
|
+
sentenceIndex,
|
|
263
|
+
sentence.wordsCount,
|
|
264
|
+
byteOffset,
|
|
265
|
+
byteLength
|
|
266
|
+
]
|
|
267
|
+
);
|
|
268
|
+
byteOffset += byteLength;
|
|
269
|
+
sentenceIndex += 1;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function migrateLegacyChunks(database, remaps) {
|
|
274
|
+
const rows = await database.queryAll(
|
|
275
|
+
`
|
|
276
|
+
SELECT *
|
|
277
|
+
FROM chunks
|
|
278
|
+
ORDER BY id
|
|
279
|
+
`,
|
|
280
|
+
void 0,
|
|
281
|
+
(row) => row
|
|
282
|
+
);
|
|
283
|
+
await database.run("ALTER TABLE chunks RENAME TO legacy_chunks");
|
|
284
|
+
await database.run(`
|
|
285
|
+
CREATE TABLE chunks (
|
|
286
|
+
id INTEGER PRIMARY KEY,
|
|
287
|
+
generation INTEGER NOT NULL,
|
|
288
|
+
serial_id INTEGER NOT NULL,
|
|
289
|
+
sentence_index INTEGER NOT NULL,
|
|
290
|
+
label TEXT NOT NULL,
|
|
291
|
+
content TEXT NOT NULL,
|
|
292
|
+
retention TEXT,
|
|
293
|
+
importance TEXT,
|
|
294
|
+
wordsCount INTEGER NOT NULL DEFAULT 0,
|
|
295
|
+
weight REAL NOT NULL DEFAULT 0.0
|
|
296
|
+
)
|
|
297
|
+
`);
|
|
298
|
+
for (const row of rows) {
|
|
299
|
+
const serialId = Number(row.serial_id);
|
|
300
|
+
const sentenceIndex = remapSentenceIndex(
|
|
301
|
+
remaps,
|
|
302
|
+
serialId,
|
|
303
|
+
Number(row.fragment_id),
|
|
304
|
+
Number(row.sentence_index)
|
|
305
|
+
);
|
|
306
|
+
await database.run(
|
|
307
|
+
`
|
|
308
|
+
INSERT INTO chunks (
|
|
309
|
+
id, generation, serial_id, sentence_index, label, content,
|
|
310
|
+
retention, importance, wordsCount, weight
|
|
311
|
+
)
|
|
312
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
313
|
+
`,
|
|
314
|
+
[
|
|
315
|
+
row.id ?? null,
|
|
316
|
+
row.generation ?? 0,
|
|
317
|
+
serialId,
|
|
318
|
+
sentenceIndex,
|
|
319
|
+
row.label ?? "",
|
|
320
|
+
row.content ?? "",
|
|
321
|
+
row.retention ?? null,
|
|
322
|
+
row.importance ?? null,
|
|
323
|
+
row.wordsCount ?? 0,
|
|
324
|
+
row.weight ?? 0
|
|
325
|
+
]
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
await database.run("DROP TABLE legacy_chunks");
|
|
329
|
+
}
|
|
330
|
+
async function migrateLegacyChunkSentences(database, remaps) {
|
|
331
|
+
const rows = await database.queryAll(
|
|
332
|
+
`
|
|
333
|
+
SELECT chunk_id, serial_id, fragment_id, sentence_index
|
|
334
|
+
FROM chunk_sentences
|
|
335
|
+
`,
|
|
336
|
+
void 0,
|
|
337
|
+
(row) => row
|
|
338
|
+
);
|
|
339
|
+
await database.run("DROP TABLE chunk_sentences");
|
|
340
|
+
await database.run(`
|
|
341
|
+
CREATE TABLE chunk_sentences (
|
|
342
|
+
chunk_id INTEGER NOT NULL,
|
|
343
|
+
serial_id INTEGER NOT NULL,
|
|
344
|
+
sentence_index INTEGER NOT NULL,
|
|
345
|
+
FOREIGN KEY (chunk_id) REFERENCES chunks(id),
|
|
346
|
+
PRIMARY KEY (chunk_id, serial_id, sentence_index)
|
|
347
|
+
)
|
|
348
|
+
`);
|
|
349
|
+
for (const row of rows) {
|
|
350
|
+
const serialId = Number(row.serial_id);
|
|
351
|
+
await database.run(
|
|
352
|
+
`
|
|
353
|
+
INSERT OR IGNORE INTO chunk_sentences (
|
|
354
|
+
chunk_id, serial_id, sentence_index
|
|
355
|
+
)
|
|
356
|
+
VALUES (?, ?, ?)
|
|
357
|
+
`,
|
|
358
|
+
[
|
|
359
|
+
getRequiredSqlBindValue(row.chunk_id),
|
|
360
|
+
serialId,
|
|
361
|
+
remapSentenceIndex(
|
|
362
|
+
remaps,
|
|
363
|
+
serialId,
|
|
364
|
+
Number(row.fragment_id),
|
|
365
|
+
Number(row.sentence_index)
|
|
366
|
+
)
|
|
367
|
+
]
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async function migrateLegacyMentions(database, remaps) {
|
|
372
|
+
const rows = await database.queryAll(
|
|
373
|
+
`
|
|
374
|
+
SELECT *
|
|
375
|
+
FROM mentions
|
|
376
|
+
ORDER BY id
|
|
377
|
+
`,
|
|
378
|
+
void 0,
|
|
379
|
+
(row) => row
|
|
380
|
+
);
|
|
381
|
+
await database.run("ALTER TABLE mentions RENAME TO legacy_mentions");
|
|
382
|
+
await database.run(`
|
|
383
|
+
CREATE TABLE mentions (
|
|
384
|
+
id TEXT PRIMARY KEY,
|
|
385
|
+
chapter_id INTEGER NOT NULL,
|
|
386
|
+
sentence_index INTEGER,
|
|
387
|
+
range_start INTEGER NOT NULL,
|
|
388
|
+
range_end INTEGER NOT NULL,
|
|
389
|
+
surface TEXT NOT NULL,
|
|
390
|
+
qid TEXT NOT NULL,
|
|
391
|
+
confidence REAL,
|
|
392
|
+
note TEXT,
|
|
393
|
+
FOREIGN KEY (chapter_id) REFERENCES serials(id)
|
|
394
|
+
)
|
|
395
|
+
`);
|
|
396
|
+
for (const row of rows) {
|
|
397
|
+
const chapterId = Number(row.chapter_id);
|
|
398
|
+
const sentenceIndex = row.sentence_index === null || row.sentence_index === void 0 ? null : remapSentenceIndex(
|
|
399
|
+
remaps,
|
|
400
|
+
chapterId,
|
|
401
|
+
Number(row.fragment_id),
|
|
402
|
+
Number(row.sentence_index)
|
|
403
|
+
);
|
|
404
|
+
await database.run(
|
|
405
|
+
`
|
|
406
|
+
INSERT OR REPLACE INTO mentions (
|
|
407
|
+
id, chapter_id, sentence_index, range_start, range_end, surface,
|
|
408
|
+
qid, confidence, note
|
|
409
|
+
)
|
|
410
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
411
|
+
`,
|
|
412
|
+
[
|
|
413
|
+
getRequiredSqlBindValue(row.id),
|
|
414
|
+
chapterId,
|
|
415
|
+
sentenceIndex,
|
|
416
|
+
row.range_start ?? 0,
|
|
417
|
+
row.range_end ?? 0,
|
|
418
|
+
row.surface ?? "",
|
|
419
|
+
row.qid ?? "",
|
|
420
|
+
row.confidence ?? null,
|
|
421
|
+
row.note ?? null
|
|
422
|
+
]
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
await database.run("DROP TABLE legacy_mentions");
|
|
426
|
+
}
|
|
427
|
+
async function migrateLegacyMentionLinkEvidenceSentences(database, remaps) {
|
|
428
|
+
const rows = await database.queryAll(
|
|
429
|
+
`
|
|
430
|
+
SELECT link_id, chapter_id, fragment_id, sentence_index
|
|
431
|
+
FROM mention_link_evidence_sentences
|
|
432
|
+
`,
|
|
433
|
+
void 0,
|
|
434
|
+
(row) => row
|
|
435
|
+
);
|
|
436
|
+
await database.run("DROP TABLE mention_link_evidence_sentences");
|
|
437
|
+
await database.run(`
|
|
438
|
+
CREATE TABLE mention_link_evidence_sentences (
|
|
439
|
+
link_id TEXT NOT NULL,
|
|
440
|
+
chapter_id INTEGER NOT NULL,
|
|
441
|
+
sentence_index INTEGER NOT NULL,
|
|
442
|
+
FOREIGN KEY (link_id) REFERENCES mention_links(id),
|
|
443
|
+
PRIMARY KEY (link_id, chapter_id, sentence_index)
|
|
444
|
+
)
|
|
445
|
+
`);
|
|
446
|
+
for (const row of rows) {
|
|
447
|
+
const chapterId = Number(row.chapter_id);
|
|
448
|
+
await database.run(
|
|
449
|
+
`
|
|
450
|
+
INSERT OR IGNORE INTO mention_link_evidence_sentences (
|
|
451
|
+
link_id, chapter_id, sentence_index
|
|
452
|
+
)
|
|
453
|
+
VALUES (?, ?, ?)
|
|
454
|
+
`,
|
|
455
|
+
[
|
|
456
|
+
getRequiredSqlBindValue(row.link_id),
|
|
457
|
+
chapterId,
|
|
458
|
+
remapSentenceIndex(
|
|
459
|
+
remaps,
|
|
460
|
+
chapterId,
|
|
461
|
+
Number(row.fragment_id),
|
|
462
|
+
Number(row.sentence_index)
|
|
463
|
+
)
|
|
464
|
+
]
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function migrateLegacyFragmentGroups(database, remaps) {
|
|
469
|
+
const rows = await database.queryAll(
|
|
470
|
+
`
|
|
471
|
+
SELECT serial_id, group_id, fragment_id
|
|
472
|
+
FROM fragment_groups
|
|
473
|
+
ORDER BY serial_id, group_id, fragment_id
|
|
474
|
+
`,
|
|
475
|
+
void 0,
|
|
476
|
+
(row) => row
|
|
477
|
+
);
|
|
478
|
+
await database.run("DROP TABLE fragment_groups");
|
|
479
|
+
await database.run(`
|
|
480
|
+
CREATE TABLE sentence_groups (
|
|
481
|
+
serial_id INTEGER NOT NULL,
|
|
482
|
+
group_id INTEGER NOT NULL,
|
|
483
|
+
start_sentence_index INTEGER NOT NULL,
|
|
484
|
+
end_sentence_index INTEGER NOT NULL,
|
|
485
|
+
PRIMARY KEY (serial_id, group_id, start_sentence_index, end_sentence_index)
|
|
486
|
+
)
|
|
487
|
+
`);
|
|
488
|
+
for (const row of rows) {
|
|
489
|
+
const serialId = Number(row.serial_id);
|
|
490
|
+
const startSentenceIndex = remapSentenceIndex(
|
|
491
|
+
remaps,
|
|
492
|
+
serialId,
|
|
493
|
+
Number(row.fragment_id),
|
|
494
|
+
0
|
|
495
|
+
);
|
|
496
|
+
const endSentenceIndex = findFragmentEndSentenceIndex(
|
|
497
|
+
remaps,
|
|
498
|
+
serialId,
|
|
499
|
+
Number(row.fragment_id)
|
|
500
|
+
);
|
|
501
|
+
await database.run(
|
|
502
|
+
`
|
|
503
|
+
INSERT OR IGNORE INTO sentence_groups (
|
|
504
|
+
serial_id, group_id, start_sentence_index, end_sentence_index
|
|
505
|
+
)
|
|
506
|
+
VALUES (?, ?, ?, ?)
|
|
507
|
+
`,
|
|
508
|
+
[
|
|
509
|
+
serialId,
|
|
510
|
+
getRequiredSqlBindValue(row.group_id),
|
|
511
|
+
startSentenceIndex,
|
|
512
|
+
endSentenceIndex
|
|
513
|
+
]
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function remapSentenceIndex(remaps, serialId, fragmentId, sentenceIndex) {
|
|
518
|
+
const remap = remaps.get(serialId);
|
|
519
|
+
const mapped = remap?.get(fragmentId, sentenceIndex);
|
|
520
|
+
if (mapped === void 0) {
|
|
521
|
+
throw new Error(
|
|
522
|
+
`Cannot remap legacy sentence ${serialId}:${fragmentId}:${sentenceIndex}.`
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
return mapped;
|
|
526
|
+
}
|
|
527
|
+
function findFragmentEndSentenceIndex(remaps, serialId, fragmentId) {
|
|
528
|
+
let sentenceIndex = 0;
|
|
529
|
+
let last;
|
|
530
|
+
while (true) {
|
|
531
|
+
const mapped = remaps.get(serialId)?.get(fragmentId, sentenceIndex);
|
|
532
|
+
if (mapped === void 0) {
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
last = mapped;
|
|
536
|
+
sentenceIndex += 1;
|
|
537
|
+
}
|
|
538
|
+
return last ?? remapSentenceIndex(remaps, serialId, fragmentId, 0);
|
|
539
|
+
}
|
|
540
|
+
async function migrateLegacySummariesToTextStreams(workspacePath) {
|
|
541
|
+
const summaries = await listLegacySummaries(workspacePath);
|
|
542
|
+
const document = await DirectoryDocument.open(workspacePath);
|
|
543
|
+
try {
|
|
544
|
+
for (const summary of summaries) {
|
|
545
|
+
await document.writeSummary(summary.serialId, summary.text);
|
|
546
|
+
}
|
|
547
|
+
} finally {
|
|
548
|
+
await document.release();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
async function listLegacySourceSerials(workspacePath) {
|
|
552
|
+
const fragmentsDirectory = join(workspacePath, "fragments");
|
|
553
|
+
try {
|
|
554
|
+
const entries = await readdir(fragmentsDirectory, { withFileTypes: true });
|
|
555
|
+
const serialIds = [];
|
|
556
|
+
for (const entry of entries) {
|
|
557
|
+
if (!entry.isDirectory()) {
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
const match = /^serial-(\d+)$/u.exec(entry.name);
|
|
561
|
+
if (match !== null) {
|
|
562
|
+
serialIds.push(Number(match[1]));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return serialIds.sort((left, right) => left - right);
|
|
566
|
+
} catch (error) {
|
|
567
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
568
|
+
return [];
|
|
569
|
+
}
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
async function readLegacySourceFragments(workspacePath, serialId) {
|
|
574
|
+
const serialDirectory = join(
|
|
575
|
+
workspacePath,
|
|
576
|
+
"fragments",
|
|
577
|
+
`serial-${serialId}`
|
|
578
|
+
);
|
|
579
|
+
const entries = await readdir(serialDirectory, { withFileTypes: true });
|
|
580
|
+
const records = [];
|
|
581
|
+
for (const entry of entries) {
|
|
582
|
+
if (!entry.isFile()) {
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
const match = /^fragment_(\d+)\.json$/u.exec(entry.name);
|
|
586
|
+
if (match === null) {
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
const path = join(serialDirectory, entry.name);
|
|
590
|
+
const content = parseLegacyFragmentFile(await readFile(path, "utf8"));
|
|
591
|
+
records.push({
|
|
592
|
+
content,
|
|
593
|
+
fragmentId: Number(match[1]),
|
|
594
|
+
path,
|
|
595
|
+
signature: createLegacyFragmentSignature(content)
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
return records.sort((left, right) => left.fragmentId - right.fragmentId);
|
|
599
|
+
}
|
|
600
|
+
function parseLegacyFragmentFile(content) {
|
|
601
|
+
const parsed = JSON.parse(content);
|
|
602
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
603
|
+
throw new TypeError("Legacy fragment file must contain sentences.");
|
|
604
|
+
}
|
|
605
|
+
const rawFragment = parsed;
|
|
606
|
+
if (!Array.isArray(rawFragment.sentences)) {
|
|
607
|
+
throw new TypeError("Legacy fragment file must contain sentences.");
|
|
608
|
+
}
|
|
609
|
+
const sentences = rawFragment.sentences.map((sentence) => {
|
|
610
|
+
if (typeof sentence !== "object" || sentence === null || !("text" in sentence) || typeof sentence.text !== "string") {
|
|
611
|
+
throw new TypeError("Legacy fragment sentence must contain text.");
|
|
612
|
+
}
|
|
613
|
+
const rawSentence = sentence;
|
|
614
|
+
const text = rawSentence.text;
|
|
615
|
+
const rawWordsCount = rawSentence.wordsCount;
|
|
616
|
+
const wordsCount = typeof rawWordsCount === "number" ? rawWordsCount : countWords(text);
|
|
617
|
+
return {
|
|
618
|
+
text,
|
|
619
|
+
wordsCount
|
|
620
|
+
};
|
|
621
|
+
});
|
|
622
|
+
const summary = typeof rawFragment.summary === "string" ? rawFragment.summary : "";
|
|
623
|
+
return { sentences, summary };
|
|
624
|
+
}
|
|
625
|
+
function countWords(text) {
|
|
626
|
+
const trimmed = text.trim();
|
|
627
|
+
return trimmed === "" ? 0 : trimmed.split(/\s+/u).length;
|
|
628
|
+
}
|
|
629
|
+
function createLegacyFragmentSignature(fragment) {
|
|
630
|
+
return JSON.stringify(fragment.sentences.map((sentence) => sentence.text));
|
|
631
|
+
}
|
|
632
|
+
function createDuplicateHalfCanonicalizationPlan(fragments) {
|
|
633
|
+
if (fragments.length < 2 || fragments.length % 2 !== 0) {
|
|
634
|
+
return void 0;
|
|
635
|
+
}
|
|
636
|
+
const halfLength = fragments.length / 2;
|
|
637
|
+
const leftHalf = fragments.slice(0, halfLength);
|
|
638
|
+
const rightHalf = fragments.slice(halfLength);
|
|
639
|
+
for (let index = 0; index < halfLength; index += 1) {
|
|
640
|
+
if (leftHalf[index]?.signature !== rightHalf[index]?.signature) {
|
|
641
|
+
return void 0;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const preferRightHalf = rightHalf.some(
|
|
645
|
+
(fragment) => fragment.content.summary.trim() !== ""
|
|
646
|
+
);
|
|
647
|
+
const sourceFragments = preferRightHalf ? rightHalf : leftHalf;
|
|
648
|
+
const fragmentIdMap = /* @__PURE__ */ new Map();
|
|
649
|
+
const canonicalFragments = sourceFragments.map((fragment, index) => {
|
|
650
|
+
const leftFragment = leftHalf[index];
|
|
651
|
+
const rightFragment = rightHalf[index];
|
|
652
|
+
if (leftFragment !== void 0) {
|
|
653
|
+
fragmentIdMap.set(leftFragment.fragmentId, index);
|
|
654
|
+
}
|
|
655
|
+
if (rightFragment !== void 0) {
|
|
656
|
+
fragmentIdMap.set(rightFragment.fragmentId, index);
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
...fragment,
|
|
660
|
+
fragmentId: index
|
|
661
|
+
};
|
|
662
|
+
});
|
|
663
|
+
return { canonicalFragments, fragmentIdMap };
|
|
664
|
+
}
|
|
665
|
+
function getRequiredSqlBindValue(value) {
|
|
666
|
+
if (value === void 0) {
|
|
667
|
+
throw new TypeError("Expected a SQLite bind value.");
|
|
668
|
+
}
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
async function listLegacySummaries(workspacePath) {
|
|
672
|
+
const summaryDirectory = join(workspacePath, "summaries");
|
|
673
|
+
try {
|
|
674
|
+
const entries = await readdir(summaryDirectory, { withFileTypes: true });
|
|
675
|
+
const summaries = [];
|
|
676
|
+
for (const entry of entries) {
|
|
677
|
+
if (!entry.isFile()) {
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
const match = /^serial-(\d+)\.txt$/u.exec(entry.name);
|
|
681
|
+
if (match === null) {
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
summaries.push({
|
|
685
|
+
serialId: Number(match[1]),
|
|
686
|
+
text: await readFile(join(summaryDirectory, entry.name), "utf8")
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
return summaries.sort((left, right) => left.serialId - right.serialId);
|
|
690
|
+
} catch (error) {
|
|
691
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
692
|
+
return [];
|
|
693
|
+
}
|
|
694
|
+
throw error;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async function listTableNames(database) {
|
|
698
|
+
const names = await database.queryAll(
|
|
699
|
+
`
|
|
700
|
+
SELECT name
|
|
701
|
+
FROM sqlite_master
|
|
702
|
+
WHERE type = 'table'
|
|
703
|
+
`,
|
|
704
|
+
void 0,
|
|
705
|
+
(row) => String(row.name)
|
|
706
|
+
);
|
|
707
|
+
return new Set(names);
|
|
708
|
+
}
|
|
709
|
+
async function listTableColumns(database, tableName) {
|
|
710
|
+
const columns = await database.queryAll(
|
|
711
|
+
`PRAGMA table_info(${quoteSqlIdentifier(tableName)})`,
|
|
712
|
+
void 0,
|
|
713
|
+
(row) => String(row.name)
|
|
714
|
+
);
|
|
715
|
+
return new Set(columns);
|
|
716
|
+
}
|
|
717
|
+
function quoteSqlIdentifier(identifier) {
|
|
718
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
719
|
+
}
|
|
720
|
+
async function indexArchiveEntries(zipFile) {
|
|
721
|
+
return await new Promise((resolve2, reject) => {
|
|
722
|
+
const entries = [];
|
|
723
|
+
zipFile.on("entry", (entry) => {
|
|
724
|
+
if (entry.fileName.endsWith("/")) {
|
|
725
|
+
zipFile.readEntry();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
entries.push(entry);
|
|
729
|
+
zipFile.readEntry();
|
|
730
|
+
});
|
|
731
|
+
zipFile.once("end", () => {
|
|
732
|
+
resolve2(entries);
|
|
733
|
+
});
|
|
734
|
+
zipFile.once("error", (error) => {
|
|
735
|
+
reject(error);
|
|
736
|
+
});
|
|
737
|
+
zipFile.readEntry();
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
function isLegacySdpubPath(archivePath) {
|
|
741
|
+
return LEGACY_SDPUB_PATTERNS.some((pattern) => pattern.test(archivePath));
|
|
742
|
+
}
|
|
743
|
+
function assertWithinDirectory(rootDirectoryPath, targetPath, archivePath) {
|
|
744
|
+
const resolvedRootDirectoryPath = resolve(rootDirectoryPath);
|
|
745
|
+
const rootPrefix = resolvedRootDirectoryPath.endsWith(sep) ? resolvedRootDirectoryPath : `${resolvedRootDirectoryPath}${sep}`;
|
|
746
|
+
if (targetPath === resolvedRootDirectoryPath || targetPath.startsWith(rootPrefix)) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
throw new Error(`Invalid archive entry path: ${archivePath}`);
|
|
750
|
+
}
|
|
751
|
+
function normalizeArchivePath(path) {
|
|
752
|
+
const normalized = path.replaceAll("\\", "/").trim();
|
|
753
|
+
const withoutLeadingSlash = normalized.startsWith("/") ? normalized.slice(1) : normalized;
|
|
754
|
+
return posix.normalize(withoutLeadingSlash).replace(/^(\.\/)+/u, "").replace(/^\/+/u, "");
|
|
755
|
+
}
|
|
756
|
+
async function openArchive(path) {
|
|
757
|
+
return await new Promise((resolveOpen, rejectOpen) => {
|
|
758
|
+
openZip(path, { autoClose: false, lazyEntries: true }, (error, zipFile) => {
|
|
759
|
+
if (error !== null || zipFile === void 0) {
|
|
760
|
+
rejectOpen(error ?? new Error(`Cannot open archive: ${path}`));
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
resolveOpen(zipFile);
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
async function openArchiveEntryStream(zipFile, entry) {
|
|
768
|
+
return await new Promise((resolveStream, rejectStream) => {
|
|
769
|
+
zipFile.openReadStream(entry, (error, stream) => {
|
|
770
|
+
if (error !== null || stream === void 0) {
|
|
771
|
+
rejectStream(
|
|
772
|
+
error ?? new Error(`Cannot open archive entry: ${entry.fileName}`)
|
|
773
|
+
);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
resolveStream(stream);
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
async function readArchiveEntryText(zipFile, entry) {
|
|
781
|
+
const chunks = [];
|
|
782
|
+
const stream = await openArchiveEntryStream(zipFile, entry);
|
|
783
|
+
await new Promise((resolveRead, rejectRead) => {
|
|
784
|
+
stream.on("data", (chunk) => {
|
|
785
|
+
chunks.push(chunk);
|
|
786
|
+
});
|
|
787
|
+
stream.once("end", resolveRead);
|
|
788
|
+
stream.once("error", rejectRead);
|
|
789
|
+
});
|
|
790
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
791
|
+
}
|
|
792
|
+
export {
|
|
793
|
+
migrateLegacySdpubToWikg
|
|
794
|
+
};
|
|
795
|
+
//# sourceMappingURL=upgrade.js.map
|