open-agreements 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +6 -1
- package/README.es.md +6 -1
- package/README.md +13 -1
- package/README.pt-br.md +6 -1
- package/README.zh.md +6 -1
- package/content/external/yc-safe-discount/metadata.yaml +1 -1
- package/content/external/yc-safe-mfn/metadata.yaml +1 -1
- package/content/external/yc-safe-pro-rata-side-letter/metadata.yaml +1 -1
- package/content/external/yc-safe-valuation-cap/metadata.yaml +1 -1
- package/content/recipes/QUALITY_TRACKER.md +35 -0
- package/content/recipes/nvca-certificate-of-incorporation/clean.json +14 -2
- package/content/recipes/nvca-certificate-of-incorporation/computed.json +78 -0
- package/content/recipes/nvca-certificate-of-incorporation/metadata.yaml +115 -2
- package/content/recipes/nvca-certificate-of-incorporation/replacements.json +50 -2
- package/content/recipes/nvca-certificate-of-incorporation/selections-roadmap.md +47 -0
- package/content/recipes/nvca-indemnification-agreement/metadata.yaml +5 -1
- package/content/recipes/nvca-indemnification-agreement/replacements.json +30 -5
- package/content/recipes/nvca-investors-rights-agreement/clean.json +9 -1
- package/content/recipes/nvca-investors-rights-agreement/metadata.yaml +1 -1
- package/content/recipes/nvca-investors-rights-agreement/replacements.json +4 -1
- package/content/recipes/nvca-management-rights-letter/metadata.yaml +1 -1
- package/content/recipes/nvca-rofr-co-sale-agreement/clean.json +11 -1
- package/content/recipes/nvca-rofr-co-sale-agreement/metadata.yaml +5 -1
- package/content/recipes/nvca-rofr-co-sale-agreement/replacements.json +62 -3
- package/content/recipes/nvca-stock-purchase-agreement/clean.json +8 -3
- package/content/recipes/nvca-stock-purchase-agreement/metadata.yaml +6 -1
- package/content/recipes/nvca-stock-purchase-agreement/normalize.json +0 -16
- package/content/recipes/nvca-stock-purchase-agreement/replacements.json +15 -12
- package/content/recipes/nvca-stock-purchase-agreement/selections.json +17 -0
- package/content/recipes/nvca-voting-agreement/clean.json +11 -1
- package/content/recipes/nvca-voting-agreement/metadata.yaml +1 -1
- package/content/recipes/nvca-voting-agreement/replacements.json +2 -1
- package/content/templates/bonterms-mutual-nda/metadata.yaml +1 -1
- package/content/templates/bonterms-professional-services-agreement/metadata.yaml +1 -1
- package/content/templates/closing-checklist/metadata.yaml +1 -1
- package/content/templates/closing-checklist/template.docx +0 -0
- package/content/templates/common-paper-ai-addendum/metadata.yaml +1 -1
- package/content/templates/common-paper-ai-addendum-in-app/metadata.yaml +1 -1
- package/content/templates/common-paper-amendment/metadata.yaml +1 -1
- package/content/templates/common-paper-business-associate-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-cloud-service-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-csa-click-through/metadata.yaml +1 -1
- package/content/templates/common-paper-csa-with-ai/metadata.yaml +1 -1
- package/content/templates/common-paper-csa-with-sla/metadata.yaml +1 -1
- package/content/templates/common-paper-csa-without-sla/metadata.yaml +1 -1
- package/content/templates/common-paper-data-processing-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-design-partner-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-independent-contractor-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-letter-of-intent/metadata.yaml +1 -1
- package/content/templates/common-paper-mutual-nda/metadata.yaml +1 -1
- package/content/templates/common-paper-one-way-nda/metadata.yaml +1 -1
- package/content/templates/common-paper-order-form/metadata.yaml +1 -1
- package/content/templates/common-paper-order-form-with-sla/metadata.yaml +1 -1
- package/content/templates/common-paper-partnership-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-pilot-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-professional-services-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-software-license-agreement/metadata.yaml +1 -1
- package/content/templates/common-paper-statement-of-work/metadata.yaml +1 -1
- package/content/templates/common-paper-term-sheet/metadata.yaml +1 -1
- package/content/templates/openagreements-employee-ip-inventions-assignment/metadata.yaml +1 -1
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/metadata.yaml +1 -1
- package/content/templates/openagreements-employment-offer-letter/metadata.yaml +1 -1
- package/content/templates/working-group-list/metadata.yaml +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +8 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/fill.js +3 -3
- package/dist/commands/fill.js.map +1 -1
- package/dist/commands/list.js +19 -15
- package/dist/commands/list.js.map +1 -1
- package/dist/core/checklist/docx-import.d.ts +50 -0
- package/dist/core/checklist/docx-import.d.ts.map +1 -0
- package/dist/core/checklist/docx-import.js +613 -0
- package/dist/core/checklist/docx-import.js.map +1 -0
- package/dist/core/checklist/docx-table-helpers.d.ts +33 -0
- package/dist/core/checklist/docx-table-helpers.d.ts.map +1 -0
- package/dist/core/checklist/docx-table-helpers.js +154 -0
- package/dist/core/checklist/docx-table-helpers.js.map +1 -0
- package/dist/core/checklist/format-checklist-docx.d.ts.map +1 -1
- package/dist/core/checklist/format-checklist-docx.js +37 -88
- package/dist/core/checklist/format-checklist-docx.js.map +1 -1
- package/dist/core/checklist/index.d.ts +15 -12
- package/dist/core/checklist/index.d.ts.map +1 -1
- package/dist/core/checklist/index.js +48 -30
- package/dist/core/checklist/index.js.map +1 -1
- package/dist/core/checklist/status-labels.d.ts +6 -0
- package/dist/core/checklist/status-labels.d.ts.map +1 -1
- package/dist/core/checklist/status-labels.js +8 -0
- package/dist/core/checklist/status-labels.js.map +1 -1
- package/dist/core/command-generation/adapters/claude.js +4 -4
- package/dist/core/employment/memo.js +3 -3
- package/dist/core/engine.js +1 -1
- package/dist/core/external/index.js +1 -1
- package/dist/core/fill-pipeline.d.ts +3 -3
- package/dist/core/fill-pipeline.js +6 -6
- package/dist/core/fill-pipeline.js.map +1 -1
- package/dist/core/metadata.d.ts +13 -3
- package/dist/core/metadata.d.ts.map +1 -1
- package/dist/core/metadata.js +19 -11
- package/dist/core/metadata.js.map +1 -1
- package/dist/core/recipe/bracket-normalizer.d.ts +4 -5
- package/dist/core/recipe/bracket-normalizer.d.ts.map +1 -1
- package/dist/core/recipe/bracket-normalizer.js +67 -149
- package/dist/core/recipe/bracket-normalizer.js.map +1 -1
- package/dist/core/recipe/cleaner.d.ts.map +1 -1
- package/dist/core/recipe/cleaner.js +91 -7
- package/dist/core/recipe/cleaner.js.map +1 -1
- package/dist/core/recipe/downloader.d.ts.map +1 -1
- package/dist/core/recipe/downloader.js +8 -3
- package/dist/core/recipe/downloader.js.map +1 -1
- package/dist/core/recipe/index.d.ts +2 -1
- package/dist/core/recipe/index.d.ts.map +1 -1
- package/dist/core/recipe/index.js +11 -4
- package/dist/core/recipe/index.js.map +1 -1
- package/dist/core/recipe/patcher.d.ts +9 -5
- package/dist/core/recipe/patcher.d.ts.map +1 -1
- package/dist/core/recipe/patcher.js +183 -136
- package/dist/core/recipe/patcher.js.map +1 -1
- package/dist/core/recipe/replacement-keys.d.ts +2 -7
- package/dist/core/recipe/replacement-keys.d.ts.map +1 -1
- package/dist/core/recipe/replacement-keys.js +3 -20
- package/dist/core/recipe/replacement-keys.js.map +1 -1
- package/dist/core/recipe/source-drift.js +1 -1
- package/dist/core/recipe/source-drift.js.map +1 -1
- package/dist/core/recipe/verifier.d.ts +7 -1
- package/dist/core/recipe/verifier.d.ts.map +1 -1
- package/dist/core/recipe/verifier.js +69 -3
- package/dist/core/recipe/verifier.js.map +1 -1
- package/dist/core/selector.d.ts +2 -0
- package/dist/core/selector.d.ts.map +1 -1
- package/dist/core/selector.js +97 -1
- package/dist/core/selector.js.map +1 -1
- package/dist/core/template-listing.d.ts +3 -1
- package/dist/core/template-listing.d.ts.map +1 -1
- package/dist/core/template-listing.js +4 -3
- package/dist/core/template-listing.js.map +1 -1
- package/dist/core/unified-pipeline.d.ts +1 -1
- package/dist/core/unified-pipeline.d.ts.map +1 -1
- package/dist/core/unified-pipeline.js +21 -3
- package/dist/core/unified-pipeline.js.map +1 -1
- package/dist/core/validation/external.d.ts.map +1 -1
- package/dist/core/validation/external.js +0 -2
- package/dist/core/validation/external.js.map +1 -1
- package/dist/core/validation/recipe.d.ts.map +1 -1
- package/dist/core/validation/recipe.js +0 -2
- package/dist/core/validation/recipe.js.map +1 -1
- package/dist/core/validation/scan-metadata.d.ts.map +1 -1
- package/dist/core/validation/scan-metadata.js +17 -1
- package/dist/core/validation/scan-metadata.js.map +1 -1
- package/dist/core/validation/template.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/node_modules/@usejunior/docx-core/dist/atomizer.d.ts +218 -0
- package/node_modules/@usejunior/docx-core/dist/atomizer.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/atomizer.js +869 -0
- package/node_modules/@usejunior/docx-core/dist/atomizer.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.d.ts +96 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.js +347 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/consumerCompatibility.d.ts +2 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/consumerCompatibility.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/consumerCompatibility.js +188 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/consumerCompatibility.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/debug.d.ts +41 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/debug.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/debug.js +85 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/debug.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.d.ts +64 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.js +985 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.d.ts +111 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.js +469 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.d.ts +277 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.js +2279 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/numberingIntegration.d.ts +59 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/numberingIntegration.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/numberingIntegration.js +209 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/numberingIntegration.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.d.ts +69 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.js +910 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/premergeRuns.d.ts +26 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/premergeRuns.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/premergeRuns.js +153 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/premergeRuns.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptor.d.ts +63 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptor.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptor.js +254 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptor.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts +64 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptorAst.js +616 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/trackChangesAcceptorAst.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.d.ts +65 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.js +95 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DocxodusWasm.d.ts +51 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DocxodusWasm.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DocxodusWasm.js +83 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DocxodusWasm.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DotnetCli.d.ts +40 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DotnetCli.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DotnetCli.js +135 -0
- package/node_modules/@usejunior/docx-core/dist/baselines/wmlcomparer/DotnetCli.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/cli/compare-two.d.ts +28 -0
- package/node_modules/@usejunior/docx-core/dist/cli/compare-two.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/cli/compare-two.js +110 -0
- package/node_modules/@usejunior/docx-core/dist/cli/compare-two.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/cli/index.d.ts +3 -0
- package/node_modules/@usejunior/docx-core/dist/cli/index.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/cli/index.js +21 -0
- package/node_modules/@usejunior/docx-core/dist/cli/index.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/core-types.d.ts +296 -0
- package/node_modules/@usejunior/docx-core/dist/core-types.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/core-types.js +122 -0
- package/node_modules/@usejunior/docx-core/dist/core-types.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/footnotes.d.ts +144 -0
- package/node_modules/@usejunior/docx-core/dist/footnotes.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/footnotes.js +291 -0
- package/node_modules/@usejunior/docx-core/dist/footnotes.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/format-detection.d.ts +120 -0
- package/node_modules/@usejunior/docx-core/dist/format-detection.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/format-detection.js +338 -0
- package/node_modules/@usejunior/docx-core/dist/format-detection.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/index.d.ts +177 -0
- package/node_modules/@usejunior/docx-core/dist/index.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/index.js +55 -0
- package/node_modules/@usejunior/docx-core/dist/index.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/integration/output-artifacts.d.ts +6 -0
- package/node_modules/@usejunior/docx-core/dist/integration/output-artifacts.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/integration/output-artifacts.js +30 -0
- package/node_modules/@usejunior/docx-core/dist/integration/output-artifacts.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/move-detection.d.ts +211 -0
- package/node_modules/@usejunior/docx-core/dist/move-detection.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/move-detection.js +391 -0
- package/node_modules/@usejunior/docx-core/dist/move-detection.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/numbering.d.ts +136 -0
- package/node_modules/@usejunior/docx-core/dist/numbering.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/numbering.js +446 -0
- package/node_modules/@usejunior/docx-core/dist/numbering.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/accept_changes.d.ts +30 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/accept_changes.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/accept_changes.js +241 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/accept_changes.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/bookmarks.d.ts +12 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/bookmarks.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/bookmarks.js +248 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/bookmarks.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/comments.d.ts +88 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/comments.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/comments.js +703 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/comments.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document.d.ts +186 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document.js +555 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document_view.d.ts +97 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document_view.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document_view.js +749 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/document_view.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.d.ts +94 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.js +219 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/errors.d.ts +7 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/errors.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/errors.js +10 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/errors.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/extract_revisions.d.ts +50 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/extract_revisions.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/extract_revisions.js +340 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/extract_revisions.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/footnotes.d.ts +37 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/footnotes.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/footnotes.js +552 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/footnotes.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/formatting_tags.d.ts +43 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/formatting_tags.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/formatting_tags.js +291 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/formatting_tags.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/index.d.ts +27 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/index.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/index.js +27 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/index.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/layout.d.ts +53 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/layout.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/layout.js +178 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/layout.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/list_labels.d.ts +19 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/list_labels.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/list_labels.js +57 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/list_labels.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/matching.d.ts +31 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/matching.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/matching.js +223 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/matching.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/merge_runs.d.ts +23 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/merge_runs.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/merge_runs.js +243 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/merge_runs.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/namespaces.d.ts +91 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/namespaces.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/namespaces.js +108 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/namespaces.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/numbering.d.ts +27 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/numbering.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/numbering.js +182 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/numbering.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/prevent_double_elevation.d.ts +18 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/prevent_double_elevation.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/prevent_double_elevation.js +190 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/prevent_double_elevation.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/reject_changes.d.ts +27 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/reject_changes.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/reject_changes.js +371 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/reject_changes.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/relationships.d.ts +7 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/relationships.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/relationships.js +24 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/relationships.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/semantic_tags.d.ts +17 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/semantic_tags.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/semantic_tags.js +58 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/semantic_tags.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/simplify_redlines.d.ts +19 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/simplify_redlines.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/simplify_redlines.js +94 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/simplify_redlines.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/styles.d.ts +36 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/styles.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/styles.js +205 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/styles.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/tables.d.ts +54 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/tables.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/tables.js +205 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/tables.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/text.d.ts +30 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/text.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/text.js +461 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/text.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/validate_document.d.ts +24 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/validate_document.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/validate_document.js +147 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/validate_document.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/xml.d.ts +5 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/xml.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/xml.js +19 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/xml.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/zip.d.ts +25 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/zip.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/zip.js +78 -0
- package/node_modules/@usejunior/docx-core/dist/primitives/zip.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/docx/DocxArchive.d.ts +94 -0
- package/node_modules/@usejunior/docx-core/dist/shared/docx/DocxArchive.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/docx/DocxArchive.js +169 -0
- package/node_modules/@usejunior/docx-core/dist/shared/docx/DocxArchive.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/namespaces.d.ts +149 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/namespaces.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/namespaces.js +224 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/namespaces.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/types.d.ts +136 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/types.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/types.js +7 -0
- package/node_modules/@usejunior/docx-core/dist/shared/ooxml/types.js.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/validators/structural.d.ts +31 -0
- package/node_modules/@usejunior/docx-core/dist/shared/validators/structural.d.ts.map +1 -0
- package/node_modules/@usejunior/docx-core/dist/shared/validators/structural.js +110 -0
- package/node_modules/@usejunior/docx-core/dist/shared/validators/structural.js.map +1 -0
- package/node_modules/@usejunior/docx-core/package.json +26 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/diff-match-patch/LICENSE +202 -0
- package/node_modules/diff-match-patch/README.md +94 -0
- package/node_modules/diff-match-patch/index.js +2218 -0
- package/node_modules/diff-match-patch/package.json +22 -0
- package/node_modules/immediate/LICENSE.txt +20 -0
- package/node_modules/immediate/README.md +93 -0
- package/node_modules/immediate/dist/immediate.js +75 -0
- package/node_modules/immediate/dist/immediate.min.js +1 -0
- package/node_modules/immediate/lib/browser.js +69 -0
- package/node_modules/immediate/lib/index.js +73 -0
- package/node_modules/immediate/package.json +42 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/isarray/.npmignore +1 -0
- package/node_modules/isarray/.travis.yml +4 -0
- package/node_modules/isarray/Makefile +6 -0
- package/node_modules/isarray/README.md +60 -0
- package/node_modules/isarray/component.json +19 -0
- package/node_modules/isarray/index.js +5 -0
- package/node_modules/isarray/package.json +45 -0
- package/node_modules/isarray/test.js +20 -0
- package/node_modules/jszip/.codeclimate.yml +16 -0
- package/node_modules/jszip/.editorconfig +8 -0
- package/node_modules/jszip/.eslintrc.js +43 -0
- package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
- package/node_modules/jszip/.jekyll-metadata +0 -0
- package/node_modules/jszip/.travis.yml +17 -0
- package/node_modules/jszip/CHANGES.md +204 -0
- package/node_modules/jszip/LICENSE.markdown +651 -0
- package/node_modules/jszip/README.markdown +33 -0
- package/node_modules/jszip/deps.js +37 -0
- package/node_modules/jszip/dist/jszip.js +11577 -0
- package/node_modules/jszip/dist/jszip.min.js +13 -0
- package/node_modules/jszip/graph.svg +601 -0
- package/node_modules/jszip/index.d.ts +330 -0
- package/node_modules/jszip/lib/base64.js +106 -0
- package/node_modules/jszip/lib/compressedObject.js +74 -0
- package/node_modules/jszip/lib/compressions.js +14 -0
- package/node_modules/jszip/lib/crc32.js +77 -0
- package/node_modules/jszip/lib/defaults.js +11 -0
- package/node_modules/jszip/lib/external.js +18 -0
- package/node_modules/jszip/lib/flate.js +85 -0
- package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
- package/node_modules/jszip/lib/generate/index.js +57 -0
- package/node_modules/jszip/lib/index.js +55 -0
- package/node_modules/jszip/lib/license_header.js +11 -0
- package/node_modules/jszip/lib/load.js +88 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- package/node_modules/jszip/lib/nodejsUtils.js +57 -0
- package/node_modules/jszip/lib/object.js +384 -0
- package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
- package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- package/node_modules/jszip/lib/reader/DataReader.js +116 -0
- package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- package/node_modules/jszip/lib/reader/StringReader.js +38 -0
- package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- package/node_modules/jszip/lib/reader/readerFor.js +28 -0
- package/node_modules/jszip/lib/signature.js +7 -0
- package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
- package/node_modules/jszip/lib/support.js +38 -0
- package/node_modules/jszip/lib/utf8.js +275 -0
- package/node_modules/jszip/lib/utils.js +501 -0
- package/node_modules/jszip/lib/zipEntries.js +261 -0
- package/node_modules/jszip/lib/zipEntry.js +293 -0
- package/node_modules/jszip/lib/zipObject.js +133 -0
- package/node_modules/jszip/package.json +67 -0
- package/node_modules/jszip/sponsors.md +21 -0
- package/node_modules/jszip/tsconfig.json +101 -0
- package/node_modules/jszip/vendor/FileSaver.js +247 -0
- package/node_modules/lie/README.md +62 -0
- package/node_modules/lie/dist/lie.js +350 -0
- package/node_modules/lie/dist/lie.min.js +1 -0
- package/node_modules/lie/dist/lie.polyfill.js +358 -0
- package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- package/node_modules/lie/lib/browser.js +273 -0
- package/node_modules/lie/lib/index.js +298 -0
- package/node_modules/lie/license.md +7 -0
- package/node_modules/lie/lie.d.ts +244 -0
- package/node_modules/lie/package.json +69 -0
- package/node_modules/lie/polyfill.js +4 -0
- package/node_modules/pako/LICENSE +21 -0
- package/node_modules/pako/README.md +191 -0
- package/node_modules/pako/dist/pako.js +6818 -0
- package/node_modules/pako/dist/pako.min.js +1 -0
- package/node_modules/pako/dist/pako_deflate.js +3997 -0
- package/node_modules/pako/dist/pako_deflate.min.js +1 -0
- package/node_modules/pako/dist/pako_inflate.js +3300 -0
- package/node_modules/pako/dist/pako_inflate.min.js +1 -0
- package/node_modules/pako/index.js +14 -0
- package/node_modules/pako/lib/deflate.js +400 -0
- package/node_modules/pako/lib/inflate.js +423 -0
- package/node_modules/pako/lib/utils/common.js +105 -0
- package/node_modules/pako/lib/utils/strings.js +187 -0
- package/node_modules/pako/lib/zlib/README +59 -0
- package/node_modules/pako/lib/zlib/adler32.js +51 -0
- package/node_modules/pako/lib/zlib/constants.js +68 -0
- package/node_modules/pako/lib/zlib/crc32.js +59 -0
- package/node_modules/pako/lib/zlib/deflate.js +1874 -0
- package/node_modules/pako/lib/zlib/gzheader.js +58 -0
- package/node_modules/pako/lib/zlib/inffast.js +345 -0
- package/node_modules/pako/lib/zlib/inflate.js +1556 -0
- package/node_modules/pako/lib/zlib/inftrees.js +343 -0
- package/node_modules/pako/lib/zlib/messages.js +32 -0
- package/node_modules/pako/lib/zlib/trees.js +1222 -0
- package/node_modules/pako/lib/zlib/zstream.js +47 -0
- package/node_modules/pako/package.json +44 -0
- package/node_modules/process-nextick-args/index.js +45 -0
- package/node_modules/process-nextick-args/license.md +19 -0
- package/node_modules/process-nextick-args/package.json +25 -0
- package/node_modules/process-nextick-args/readme.md +18 -0
- package/node_modules/readable-stream/.travis.yml +34 -0
- package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +58 -0
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- package/node_modules/readable-stream/duplex-browser.js +1 -0
- package/node_modules/readable-stream/duplex.js +1 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/readable-stream/package.json +52 -0
- package/node_modules/readable-stream/passthrough.js +1 -0
- package/node_modules/readable-stream/readable-browser.js +7 -0
- package/node_modules/readable-stream/readable.js +19 -0
- package/node_modules/readable-stream/transform.js +1 -0
- package/node_modules/readable-stream/writable-browser.js +1 -0
- package/node_modules/readable-stream/writable.js +8 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/setimmediate/LICENSE.txt +20 -0
- package/node_modules/setimmediate/package.json +30 -0
- package/node_modules/setimmediate/setImmediate.js +186 -0
- package/node_modules/string_decoder/.travis.yml +50 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +31 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/package.json +11 -5
- package/packages/docx-core/node_modules/@xmldom/xmldom/CHANGELOG.md +468 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/LICENSE +8 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/SECURITY.md +50 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/index.d.ts +43 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +2 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/conventions.js +203 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/dom-parser.js +322 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/dom.js +1879 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/entities.js +2166 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/index.js +4 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/lib/sax.js +662 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/package.json +71 -0
- package/packages/docx-core/node_modules/@xmldom/xmldom/readme.md +356 -0
- package/server.json +31 -0
- package/skills/client-email/SKILL.md +143 -0
- package/skills/cloud-service-agreement/SKILL.md +8 -99
- package/skills/data-privacy-agreement/SKILL.md +10 -97
- package/skills/delaware-franchise-tax/SKILL.md +7 -1
- package/skills/edit-docx-agreement/SKILL.md +10 -3
- package/skills/employment-contract/SKILL.md +10 -95
- package/skills/iso-27001-evidence-collection/SKILL.md +7 -1
- package/skills/iso-27001-internal-audit/SKILL.md +6 -0
- package/skills/nda/SKILL.md +7 -99
- package/skills/open-agreements/CONNECTORS.md +1 -1
- package/skills/open-agreements/SKILL.md +17 -104
- package/skills/recipe-quality-audit/SKILL.md +116 -0
- package/skills/safe/SKILL.md +12 -97
- package/skills/services-agreement/SKILL.md +8 -99
- package/skills/shared/template-filling-execution.md +92 -0
- package/skills/soc2-readiness/SKILL.md +7 -1
- package/skills/unit-test-philosophy/SKILL.md +12 -1
- package/skills/venture-financing/SKILL.md +11 -96
|
@@ -2,9 +2,14 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
|
-
|
|
5
|
+
// Lazy — must be a function so ESM import hoisting doesn't evaluate before
|
|
6
|
+
// api/_shared.ts sets OPEN_AGREEMENTS_CACHE_ROOT for Vercel.
|
|
7
|
+
function getCacheRoot() {
|
|
8
|
+
return process.env['OPEN_AGREEMENTS_CACHE_ROOT']
|
|
9
|
+
?? join(homedir(), '.open-agreements', 'cache');
|
|
10
|
+
}
|
|
6
11
|
function getCachePath(recipeId) {
|
|
7
|
-
return join(
|
|
12
|
+
return join(getCacheRoot(), recipeId, 'source.docx');
|
|
8
13
|
}
|
|
9
14
|
function verifyHash(buf, expected) {
|
|
10
15
|
const actual = createHash('sha256').update(buf).digest('hex');
|
|
@@ -49,7 +54,7 @@ export async function ensureSourceDocx(recipeId, metadata) {
|
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
// Write to cache
|
|
52
|
-
const cacheDir = join(
|
|
57
|
+
const cacheDir = join(getCacheRoot(), recipeId);
|
|
53
58
|
mkdirSync(cacheDir, { recursive: true });
|
|
54
59
|
writeFileSync(cachePath, buf);
|
|
55
60
|
console.log(`Cached: ${cachePath}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloader.js","sourceRoot":"","sources":["../../../src/core/recipe/downloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,
|
|
1
|
+
{"version":3,"file":"downloader.js","sourceRoot":"","sources":["../../../src/core/recipe/downloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,2EAA2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AAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,sBAAsB,QAAQ,UAAU,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,IAAI;YAClF,UAAU,QAAQ,CAAC,UAAU,EAAE,CAChC,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAEtD,2BAA2B;IAC3B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9D,MAAM,IAAI,KAAK,CACb,8BAA8B,QAAQ,0CAA0C;gBAChF,uBAAuB,QAAQ,CAAC,aAAa,IAAI;gBACjD,uBAAuB,MAAM,IAAI;gBACjC,UAAU,QAAQ,CAAC,UAAU,EAAE,CAChC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChD,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,EAAE,CAAC,CAAC;IAEpC,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -7,7 +7,8 @@ export declare function runRecipe(options: RecipeRunOptions): Promise<RecipeRunR
|
|
|
7
7
|
export { cleanDocument } from './cleaner.js';
|
|
8
8
|
export type { CleanResult, CleanOptions } from './cleaner.js';
|
|
9
9
|
export { patchDocument } from './patcher.js';
|
|
10
|
-
export {
|
|
10
|
+
export type { PatchResult } from './patcher.js';
|
|
11
|
+
export { verifyOutput, normalizeText, extractAllText, countFormattingAnomalies } from './verifier.js';
|
|
11
12
|
export { ensureSourceDocx } from './downloader.js';
|
|
12
13
|
export { checkRecipeSourceDrift, computeSourceStructureSignature } from './source-drift.js';
|
|
13
14
|
export { enumerateTextParts, getGeneralTextPartNames } from './ooxml-parts.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/recipe/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/recipe/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAqFnF;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/F,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { loadRecipeMetadata, loadCleanConfig, loadNormalizeConfig } from '../metadata.js';
|
|
4
|
+
import { loadSelectionsConfig } from '../selector.js';
|
|
4
5
|
import { resolveRecipeDir } from '../../utils/paths.js';
|
|
5
6
|
import { verifyOutput } from './verifier.js';
|
|
6
7
|
import { ensureSourceDocx } from './downloader.js';
|
|
@@ -17,6 +18,11 @@ export async function runRecipe(options) {
|
|
|
17
18
|
const metadata = loadRecipeMetadata(recipeDir);
|
|
18
19
|
const cleanConfig = loadCleanConfig(recipeDir);
|
|
19
20
|
const normalizeConfig = loadNormalizeConfig(recipeDir);
|
|
21
|
+
// Load selectionsConfig if selections.json exists (mirrors engine.ts template path)
|
|
22
|
+
const selectionsPath = join(recipeDir, 'selections.json');
|
|
23
|
+
const selectionsConfig = existsSync(selectionsPath)
|
|
24
|
+
? loadSelectionsConfig(selectionsPath)
|
|
25
|
+
: undefined;
|
|
20
26
|
// Resolve input: explicit path or auto-download
|
|
21
27
|
const inputPath = options.inputPath ?? await ensureSourceDocx(recipeId, metadata);
|
|
22
28
|
// Load replacements.json
|
|
@@ -53,14 +59,15 @@ export async function runRecipe(options) {
|
|
|
53
59
|
if (computedOutPath && computedArtifact) {
|
|
54
60
|
writeComputedArtifact(computedOutPath, computedArtifact);
|
|
55
61
|
}
|
|
56
|
-
const shouldNormalizeBracketArtifacts = options.normalizeBracketArtifacts ??
|
|
62
|
+
const shouldNormalizeBracketArtifacts = options.normalizeBracketArtifacts ?? normalizeConfig.paragraph_rules.length > 0;
|
|
57
63
|
const result = await runFillPipeline({
|
|
58
64
|
inputPath,
|
|
59
65
|
outputPath,
|
|
60
66
|
values: effectiveValues,
|
|
61
67
|
fields: metadata.fields,
|
|
62
|
-
|
|
68
|
+
priorityFieldNames: metadata.priority_fields,
|
|
63
69
|
cleanPatch: { cleanConfig, replacements },
|
|
70
|
+
selectionsConfig,
|
|
64
71
|
postProcess: shouldNormalizeBracketArtifacts
|
|
65
72
|
? async (outputDocPath) => {
|
|
66
73
|
await normalizeBracketArtifacts(outputDocPath, outputDocPath, {
|
|
@@ -83,7 +90,7 @@ export async function runRecipe(options) {
|
|
|
83
90
|
}
|
|
84
91
|
export { cleanDocument } from './cleaner.js';
|
|
85
92
|
export { patchDocument } from './patcher.js';
|
|
86
|
-
export { verifyOutput, normalizeText, extractAllText } from './verifier.js';
|
|
93
|
+
export { verifyOutput, normalizeText, extractAllText, countFormattingAnomalies } from './verifier.js';
|
|
87
94
|
export { ensureSourceDocx } from './downloader.js';
|
|
88
95
|
export { checkRecipeSourceDrift, computeSourceStructureSignature } from './source-drift.js';
|
|
89
96
|
export { enumerateTextParts, getGeneralTextPartNames } from './ooxml-parts.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/recipe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/recipe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EA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,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import type { Element } from '@xmldom/xmldom';
|
|
2
|
+
export interface PatchResult {
|
|
3
|
+
outputPath: string;
|
|
4
|
+
zeroMatchKeys: string[];
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Patch a DOCX document by replacing bracketed placeholders with template tags.
|
|
4
8
|
* Uses a char_map algorithm to handle cross-run replacements where Word splits
|
|
5
9
|
* placeholder text across multiple XML run elements.
|
|
6
10
|
*
|
|
7
|
-
* Supports
|
|
11
|
+
* Supports two key syntax types:
|
|
8
12
|
* - Simple: "search text" → replaces all occurrences
|
|
9
|
-
* - Context: "
|
|
10
|
-
*
|
|
13
|
+
* - Context: "context > placeholder" → in tables, replaces placeholder in rows
|
|
14
|
+
* where label matches; in paragraphs, replaces first placeholder after context
|
|
11
15
|
*
|
|
12
|
-
* Processing order: context keys first,
|
|
16
|
+
* Processing order: context keys first, simple keys last.
|
|
13
17
|
* This ensures qualified rules claim their targets before simple rules sweep up the rest.
|
|
14
18
|
*/
|
|
15
19
|
export interface PatchOptions {
|
|
@@ -18,7 +22,7 @@ export interface PatchOptions {
|
|
|
18
22
|
* overriding any inherited placeholder styling (e.g. gray). */
|
|
19
23
|
replacementColor?: string;
|
|
20
24
|
}
|
|
21
|
-
export declare function patchDocument(inputPath: string, outputPath: string, replacements: Record<string, string>, options?: PatchOptions): Promise<
|
|
25
|
+
export declare function patchDocument(inputPath: string, outputPath: string, replacements: Record<string, string>, options?: PatchOptions): Promise<PatchResult>;
|
|
22
26
|
/**
|
|
23
27
|
* Get the text content of the first table cell (label cell) in the same row
|
|
24
28
|
* as the paragraph. Returns null if the paragraph is not inside a table cell.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patcher.d.ts","sourceRoot":"","sources":["../../../src/core/recipe/patcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAY,OAAO,EAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"patcher.d.ts","sourceRoot":"","sources":["../../../src/core/recipe/patcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAY,OAAO,EAAQ,MAAM,gBAAgB,CAAC;AA4B9D,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAcD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;IAC3B;;oEAEgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,WAAW,CAAC,CAsItB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAwB/D;AA0BD,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAO/C;AAuFD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAcvD"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import AdmZip from 'adm-zip';
|
|
2
2
|
import { writeFileSync } from 'node:fs';
|
|
3
3
|
import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
|
|
4
|
+
import { replaceParagraphTextRange, getParagraphText, SafeDocxError, } from '@usejunior/docx-core';
|
|
4
5
|
import { enumerateTextParts, getGeneralTextPartNames } from './ooxml-parts.js';
|
|
5
6
|
import { parseReplacementKey } from './replacement-keys.js';
|
|
6
7
|
const W_NS = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
8
|
+
/**
|
|
9
|
+
* Normalize smart/typographic quotes to ASCII equivalents for matching.
|
|
10
|
+
* Uses the same canonical quote set as verifier's normalizeText().
|
|
11
|
+
* This is a 1-to-1 character mapping so charMap positions remain valid.
|
|
12
|
+
*/
|
|
13
|
+
function normalizeQuotes(text) {
|
|
14
|
+
return text
|
|
15
|
+
.replace(/[\u2018\u2019\u2039\u203A]/g, "'")
|
|
16
|
+
.replace(/[\u201C\u201D\u201A\u201E\u00AB\u00BB]/g, '"');
|
|
17
|
+
}
|
|
7
18
|
/** Maximum replacement iterations per key per paragraph to prevent infinite loops. */
|
|
8
19
|
const MAX_REPLACEMENTS_PER_KEY = 200;
|
|
9
20
|
/**
|
|
@@ -23,30 +34,48 @@ export async function patchDocument(inputPath, outputPath, replacements, options
|
|
|
23
34
|
if (partNames.length === 0) {
|
|
24
35
|
throw new Error('No OOXML text parts found in DOCX');
|
|
25
36
|
}
|
|
26
|
-
// Parse and classify all keys
|
|
37
|
+
// Parse and classify all keys, normalizing smart quotes
|
|
27
38
|
const parsedKeys = [];
|
|
28
39
|
for (const [key, value] of Object.entries(replacements)) {
|
|
29
|
-
|
|
40
|
+
const parsed = parseReplacementKey(key, value);
|
|
41
|
+
// Normalize smart quotes in search text and context for matching
|
|
42
|
+
if (parsed.type === 'context') {
|
|
43
|
+
parsed.searchText = normalizeQuotes(parsed.searchText);
|
|
44
|
+
parsed.context = normalizeQuotes(parsed.context);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
parsed.searchText = normalizeQuotes(parsed.searchText);
|
|
48
|
+
}
|
|
49
|
+
parsedKeys.push(parsed);
|
|
50
|
+
}
|
|
51
|
+
// Deduplicate keys that collide after quote normalization
|
|
52
|
+
const seenSearchKeys = new Map();
|
|
53
|
+
const deduplicatedKeys = [];
|
|
54
|
+
for (const pk of parsedKeys) {
|
|
55
|
+
const dedupKey = pk.type === 'context' ? `${pk.context} > ${pk.searchText}` : pk.searchText;
|
|
56
|
+
const existing = seenSearchKeys.get(dedupKey);
|
|
57
|
+
if (existing) {
|
|
58
|
+
if (existing.value !== pk.value) {
|
|
59
|
+
console.warn(`Patcher: quote-normalized key collision for "${dedupKey}" with different values`);
|
|
60
|
+
}
|
|
61
|
+
// Skip duplicate
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
seenSearchKeys.set(dedupKey, pk);
|
|
65
|
+
deduplicatedKeys.push(pk);
|
|
66
|
+
}
|
|
30
67
|
}
|
|
31
68
|
// Separate by type and sort
|
|
32
|
-
const contextKeys =
|
|
69
|
+
const contextKeys = deduplicatedKeys
|
|
33
70
|
.filter((k) => k.type === 'context')
|
|
34
71
|
.sort((a, b) => b.searchText.length - a.searchText.length);
|
|
35
|
-
const
|
|
36
|
-
.filter((k) => k.type === 'nth')
|
|
37
|
-
.sort((a, b) => {
|
|
38
|
-
// Group by searchText, then by N ascending
|
|
39
|
-
if (a.searchText !== b.searchText)
|
|
40
|
-
return b.searchText.length - a.searchText.length;
|
|
41
|
-
return a.n - b.n;
|
|
42
|
-
});
|
|
43
|
-
const simpleKeys = parsedKeys
|
|
72
|
+
const simpleKeys = deduplicatedKeys
|
|
44
73
|
.filter((k) => k.type === 'simple')
|
|
45
74
|
.sort((a, b) => b.searchText.length - a.searchText.length);
|
|
46
75
|
// Track which parts we modify so we can rebuild the zip cleanly
|
|
47
76
|
const modifiedParts = new Map();
|
|
48
|
-
//
|
|
49
|
-
const
|
|
77
|
+
// Collect all pre-patch paragraph text for zero-match detection
|
|
78
|
+
const preMatchTexts = [];
|
|
50
79
|
for (const partName of partNames) {
|
|
51
80
|
const entry = zip.getEntry(partName);
|
|
52
81
|
if (!entry)
|
|
@@ -54,53 +83,38 @@ export async function patchDocument(inputPath, outputPath, replacements, options
|
|
|
54
83
|
const xml = entry.getData().toString('utf-8');
|
|
55
84
|
const doc = parser.parseFromString(xml, 'text/xml');
|
|
56
85
|
const allParagraphs = doc.getElementsByTagNameNS(W_NS, 'p');
|
|
86
|
+
// Collect paragraph text before any replacements for zero-match detection
|
|
87
|
+
for (let i = 0; i < allParagraphs.length; i++) {
|
|
88
|
+
const text = getParagraphText(allParagraphs[i]);
|
|
89
|
+
if (!text)
|
|
90
|
+
continue;
|
|
91
|
+
preMatchTexts.push(normalizeQuotes(text));
|
|
92
|
+
}
|
|
57
93
|
// Phase 1: Context keys
|
|
58
94
|
for (const ck of contextKeys) {
|
|
59
95
|
for (let i = 0; i < allParagraphs.length; i++) {
|
|
60
96
|
const para = allParagraphs[i];
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
97
|
+
const paraText = getParagraphText(para);
|
|
98
|
+
if (!paraText)
|
|
63
99
|
continue;
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
100
|
+
const normalizedText = normalizeQuotes(paraText);
|
|
101
|
+
if (!normalizedText.includes(ck.searchText))
|
|
66
102
|
continue;
|
|
67
103
|
const rowContext = getTableRowContext(para);
|
|
68
|
-
if (rowContext
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
nthGroups.set(nk.searchText, group);
|
|
79
|
-
}
|
|
80
|
-
for (const [searchText, group] of nthGroups) {
|
|
81
|
-
// Build a map from occurrence number → value for this group
|
|
82
|
-
const nthMap = new Map();
|
|
83
|
-
for (const nk of group) {
|
|
84
|
-
nthMap.set(nk.n, nk.value);
|
|
85
|
-
}
|
|
86
|
-
let counter = nthCounters.get(searchText) ?? 0;
|
|
87
|
-
for (let i = 0; i < allParagraphs.length; i++) {
|
|
88
|
-
const para = allParagraphs[i];
|
|
89
|
-
const runs = getRunElements(para);
|
|
90
|
-
if (runs.length === 0)
|
|
91
|
-
continue;
|
|
92
|
-
const { fullText } = buildCharMap(runs);
|
|
93
|
-
if (!fullText.includes(searchText))
|
|
94
|
-
continue;
|
|
95
|
-
counter++;
|
|
96
|
-
const value = nthMap.get(counter);
|
|
97
|
-
if (value !== undefined) {
|
|
98
|
-
replaceInParagraphOnce(para, searchText, value, options?.replacementColor);
|
|
104
|
+
if (rowContext !== null) {
|
|
105
|
+
const normalizedRowContext = normalizeQuotes(rowContext);
|
|
106
|
+
if (!normalizedRowContext.includes(ck.context))
|
|
107
|
+
continue;
|
|
108
|
+
replaceInParagraph(para, { [ck.searchText]: ck.value }, [ck.searchText], options?.replacementColor);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (!normalizedText.includes(ck.context))
|
|
112
|
+
continue;
|
|
113
|
+
replaceFirstAfterContext(para, ck.searchText, ck.context, ck.value, options?.replacementColor);
|
|
99
114
|
}
|
|
100
115
|
}
|
|
101
|
-
nthCounters.set(searchText, counter);
|
|
102
116
|
}
|
|
103
|
-
// Phase
|
|
117
|
+
// Phase 2: Simple keys
|
|
104
118
|
if (simpleKeys.length > 0) {
|
|
105
119
|
const simpleReplacements = {};
|
|
106
120
|
const simpleSortedKeys = [];
|
|
@@ -114,6 +128,15 @@ export async function patchDocument(inputPath, outputPath, replacements, options
|
|
|
114
128
|
}
|
|
115
129
|
modifiedParts.set(partName, Buffer.from(serializer.serializeToString(doc), 'utf-8'));
|
|
116
130
|
}
|
|
131
|
+
// Compute zero-match keys by checking pre-patch paragraph text
|
|
132
|
+
const preMatchFullText = preMatchTexts.join('\n');
|
|
133
|
+
const zeroMatchKeys = [];
|
|
134
|
+
for (const pk of deduplicatedKeys) {
|
|
135
|
+
const keyLabel = pk.type === 'context' ? `${pk.context} > ${pk.searchText}` : pk.searchText;
|
|
136
|
+
if (!preMatchFullText.includes(pk.searchText)) {
|
|
137
|
+
zeroMatchKeys.push(keyLabel);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
117
140
|
// Rebuild the zip from scratch using addFile() to avoid adm-zip data
|
|
118
141
|
// descriptor issues. Some DOCX files use streaming (bit 3) flags which
|
|
119
142
|
// adm-zip's updateFile/writeZip/toBuffer handle incorrectly.
|
|
@@ -123,7 +146,7 @@ export async function patchDocument(inputPath, outputPath, replacements, options
|
|
|
123
146
|
outZip.addFile(entry.entryName, data);
|
|
124
147
|
}
|
|
125
148
|
writeFileSync(outputPath, outZip.toBuffer());
|
|
126
|
-
return outputPath;
|
|
149
|
+
return { outputPath, zeroMatchKeys };
|
|
127
150
|
}
|
|
128
151
|
/**
|
|
129
152
|
* Get the text content of the first table cell (label cell) in the same row
|
|
@@ -288,44 +311,16 @@ export function isRunSafeToRemove(run) {
|
|
|
288
311
|
return true;
|
|
289
312
|
}
|
|
290
313
|
/**
|
|
291
|
-
*
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
i++;
|
|
297
|
-
return i;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Compute the length of the common suffix between two strings,
|
|
301
|
-
* not overlapping with a known common prefix.
|
|
302
|
-
*/
|
|
303
|
-
function commonSuffixLen(a, b, prefixLen) {
|
|
304
|
-
let i = 0;
|
|
305
|
-
while (i < a.length - prefixLen &&
|
|
306
|
-
i < b.length - prefixLen &&
|
|
307
|
-
a[a.length - 1 - i] === b[b.length - 1 - i])
|
|
308
|
-
i++;
|
|
309
|
-
return i;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Perform a single replacement of searchText with value in the paragraph.
|
|
313
|
-
* Does NOT loop — replaces only the first match found.
|
|
314
|
-
* Used for nth-occurrence keys where the value may contain the searchText.
|
|
314
|
+
* Legacy charMap-based splice: replace `searchTextLength` characters starting at
|
|
315
|
+
* `matchStart` with `value`, cleaning up empty runs afterwards.
|
|
316
|
+
* Used as a fallback when replaceParagraphTextRange throws UNSAFE_CONTAINER_BOUNDARY
|
|
317
|
+
* (e.g. replacements spanning across hyperlinks or SDTs) or UNSUPPORTED_EDIT
|
|
318
|
+
* (e.g. replacement spans field results).
|
|
315
319
|
*/
|
|
316
|
-
function
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const rebuilt = buildCharMap(runs);
|
|
321
|
-
const matchStart = rebuilt.fullText.indexOf(searchText);
|
|
322
|
-
if (matchStart === -1)
|
|
323
|
-
return;
|
|
324
|
-
// Always use full replacement for single-shot mode
|
|
325
|
-
const start = matchStart;
|
|
326
|
-
const end = matchStart + searchText.length;
|
|
327
|
-
const firstEntry = rebuilt.charMap[start];
|
|
328
|
-
const lastEntry = rebuilt.charMap[end - 1];
|
|
320
|
+
function replaceAtPositionLegacy(runs, charMap, matchStart, searchTextLength, value, replacementColor) {
|
|
321
|
+
const end = matchStart + searchTextLength;
|
|
322
|
+
const firstEntry = charMap[matchStart];
|
|
323
|
+
const lastEntry = charMap[end - 1];
|
|
329
324
|
if (firstEntry.runIndex === lastEntry.runIndex) {
|
|
330
325
|
const runText = getRunText(runs[firstEntry.runIndex]);
|
|
331
326
|
setRunText(runs[firstEntry.runIndex], runText.slice(0, firstEntry.charOffset) + value + runText.slice(lastEntry.charOffset + 1));
|
|
@@ -349,74 +344,126 @@ function replaceInParagraphOnce(para, searchText, value, replacementColor) {
|
|
|
349
344
|
}
|
|
350
345
|
}
|
|
351
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Perform a single replacement of searchText with value in the paragraph.
|
|
349
|
+
* Does NOT loop — replaces only the first match found.
|
|
350
|
+
* Uses docx-core's replaceParagraphTextRange for correct formatting preservation,
|
|
351
|
+
* with a legacy charMap fallback for container-boundary cases (hyperlinks, SDTs).
|
|
352
|
+
*/
|
|
353
|
+
function replaceInParagraphOnce(para, searchText, value, replacementColor) {
|
|
354
|
+
const fullText = getParagraphText(para);
|
|
355
|
+
const matchStart = normalizeQuotes(fullText).indexOf(searchText);
|
|
356
|
+
if (matchStart === -1)
|
|
357
|
+
return;
|
|
358
|
+
try {
|
|
359
|
+
replaceParagraphTextRange(para, matchStart, matchStart + searchText.length, replacementColor
|
|
360
|
+
? [{ text: value, addRunProps: { color: replacementColor } }]
|
|
361
|
+
: value);
|
|
362
|
+
}
|
|
363
|
+
catch (e) {
|
|
364
|
+
if (e instanceof SafeDocxError && (e.code === 'UNSAFE_CONTAINER_BOUNDARY' || e.code === 'UNSUPPORTED_EDIT')) {
|
|
365
|
+
const runs = getRunElements(para);
|
|
366
|
+
const { fullText: legacyText, charMap } = buildCharMap(runs);
|
|
367
|
+
const legacyPos = normalizeQuotes(legacyText).indexOf(searchText);
|
|
368
|
+
if (legacyPos === -1)
|
|
369
|
+
return;
|
|
370
|
+
replaceAtPositionLegacy(runs, charMap, legacyPos, searchText.length, value, replacementColor);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
throw e;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Replace the first occurrence of searchText that appears AFTER contextText
|
|
379
|
+
* in the same paragraph. Each call is self-contained — no chaining or order dependency.
|
|
380
|
+
* Uses docx-core's replaceParagraphTextRange with legacy charMap fallback.
|
|
381
|
+
*/
|
|
382
|
+
function replaceFirstAfterContext(para, searchText, contextText, value, replacementColor) {
|
|
383
|
+
const fullText = getParagraphText(para);
|
|
384
|
+
const normalizedFull = normalizeQuotes(fullText);
|
|
385
|
+
const ctxPos = normalizedFull.indexOf(contextText);
|
|
386
|
+
if (ctxPos === -1)
|
|
387
|
+
return;
|
|
388
|
+
const matchStart = normalizedFull.indexOf(searchText, ctxPos + contextText.length);
|
|
389
|
+
if (matchStart === -1)
|
|
390
|
+
return;
|
|
391
|
+
try {
|
|
392
|
+
replaceParagraphTextRange(para, matchStart, matchStart + searchText.length, replacementColor
|
|
393
|
+
? [{ text: value, addRunProps: { color: replacementColor } }]
|
|
394
|
+
: value);
|
|
395
|
+
}
|
|
396
|
+
catch (e) {
|
|
397
|
+
if (e instanceof SafeDocxError && (e.code === 'UNSAFE_CONTAINER_BOUNDARY' || e.code === 'UNSUPPORTED_EDIT')) {
|
|
398
|
+
const runs = getRunElements(para);
|
|
399
|
+
const { fullText: legacyText, charMap } = buildCharMap(runs);
|
|
400
|
+
const normalizedLegacy = normalizeQuotes(legacyText);
|
|
401
|
+
const legacyCtxPos = normalizedLegacy.indexOf(contextText);
|
|
402
|
+
if (legacyCtxPos === -1)
|
|
403
|
+
return;
|
|
404
|
+
const legacyPos = normalizedLegacy.indexOf(searchText, legacyCtxPos + contextText.length);
|
|
405
|
+
if (legacyPos === -1)
|
|
406
|
+
return;
|
|
407
|
+
replaceAtPositionLegacy(runs, charMap, legacyPos, searchText.length, value, replacementColor);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
throw e;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
352
414
|
function replaceInParagraph(para, replacements, sortedKeys, replacementColor) {
|
|
353
|
-
|
|
354
|
-
|
|
415
|
+
// Quick check: skip if no keys match
|
|
416
|
+
const initialText = getParagraphText(para);
|
|
417
|
+
if (!initialText)
|
|
355
418
|
return;
|
|
356
|
-
const
|
|
357
|
-
if (!sortedKeys.some((key) =>
|
|
419
|
+
const normalizedInitial = normalizeQuotes(initialText);
|
|
420
|
+
if (!sortedKeys.some((key) => normalizedInitial.includes(key)))
|
|
358
421
|
return;
|
|
359
422
|
for (const key of sortedKeys) {
|
|
360
|
-
let rebuilt = buildCharMap(runs);
|
|
361
423
|
let iterations = 0;
|
|
362
|
-
|
|
424
|
+
let paraText = getParagraphText(para);
|
|
425
|
+
while (normalizeQuotes(paraText).includes(key)) {
|
|
363
426
|
iterations++;
|
|
364
427
|
if (iterations > MAX_REPLACEMENTS_PER_KEY) {
|
|
365
428
|
throw new Error(`Patcher: exceeded ${MAX_REPLACEMENTS_PER_KEY} replacements for key "${key}" ` +
|
|
366
429
|
`in a single paragraph. This usually means the replacement value contains ` +
|
|
367
430
|
`the search key, creating an infinite loop.`);
|
|
368
431
|
}
|
|
369
|
-
const prevText =
|
|
370
|
-
const matchStart =
|
|
432
|
+
const prevText = paraText;
|
|
433
|
+
const matchStart = normalizeQuotes(paraText).indexOf(key);
|
|
371
434
|
const replacement = replacements[key];
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
let start;
|
|
377
|
-
let end;
|
|
378
|
-
let replText;
|
|
379
|
-
if (cpLen + csLen >= key.length || cpLen + csLen >= replacement.length) {
|
|
380
|
-
// No useful common prefix/suffix — full replacement (current behavior)
|
|
381
|
-
start = matchStart;
|
|
382
|
-
end = matchStart + key.length;
|
|
383
|
-
replText = replacement;
|
|
435
|
+
try {
|
|
436
|
+
replaceParagraphTextRange(para, matchStart, matchStart + key.length, replacementColor
|
|
437
|
+
? [{ text: replacement, addRunProps: { color: replacementColor } }]
|
|
438
|
+
: replacement);
|
|
384
439
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
else {
|
|
398
|
-
const firstRunText = getRunText(runs[firstEntry.runIndex]);
|
|
399
|
-
setRunText(runs[firstEntry.runIndex], firstRunText.slice(0, firstEntry.charOffset) + replText);
|
|
400
|
-
const lastRunText = getRunText(runs[lastEntry.runIndex]);
|
|
401
|
-
setRunText(runs[lastEntry.runIndex], lastRunText.slice(lastEntry.charOffset + 1));
|
|
402
|
-
for (let mid = firstEntry.runIndex + 1; mid < lastEntry.runIndex; mid++) {
|
|
403
|
-
setRunText(runs[mid], '');
|
|
440
|
+
catch (e) {
|
|
441
|
+
if (e instanceof SafeDocxError && (e.code === 'UNSAFE_CONTAINER_BOUNDARY' || e.code === 'UNSUPPORTED_EDIT')) {
|
|
442
|
+
// Fallback: use legacy charMap splice for this specific match
|
|
443
|
+
const runs = getRunElements(para);
|
|
444
|
+
const { fullText: legacyText, charMap } = buildCharMap(runs);
|
|
445
|
+
const legacyPos = normalizeQuotes(legacyText).indexOf(key);
|
|
446
|
+
if (legacyPos === -1)
|
|
447
|
+
break;
|
|
448
|
+
replaceAtPositionLegacy(runs, charMap, legacyPos, key.length, replacement, replacementColor);
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
throw e;
|
|
404
452
|
}
|
|
405
453
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
rebuilt = buildCharMap(runs);
|
|
454
|
+
// Re-read paragraph text after DOM modification
|
|
455
|
+
paraText = getParagraphText(para);
|
|
410
456
|
// Progress guard: if text didn't change, we're stuck
|
|
411
|
-
if (
|
|
457
|
+
if (paraText === prevText) {
|
|
412
458
|
throw new Error(`Patcher: no progress replacing key "${key}" — replacement value may contain the search key.`);
|
|
413
459
|
}
|
|
414
460
|
}
|
|
415
461
|
}
|
|
416
462
|
// Sweep: remove empty runs that are safe to remove (no drawings, fields, etc.)
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
463
|
+
const finalRuns = getRunElements(para);
|
|
464
|
+
for (let i = finalRuns.length - 1; i >= 0; i--) {
|
|
465
|
+
if (getRunText(finalRuns[i]) === '' && isRunSafeToRemove(finalRuns[i])) {
|
|
466
|
+
finalRuns[i].parentNode?.removeChild(finalRuns[i]);
|
|
420
467
|
}
|
|
421
468
|
}
|
|
422
469
|
}
|