open-agreements 0.1.1 → 0.2.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/README.md +148 -34
- package/bin/open-agreements.js +3 -1
- package/{external → content/external}/yc-safe-discount/metadata.yaml +17 -21
- package/{external → content/external}/yc-safe-mfn/metadata.yaml +16 -16
- package/{external → content/external}/yc-safe-pro-rata-side-letter/metadata.yaml +13 -13
- package/{external → content/external}/yc-safe-valuation-cap/metadata.yaml +16 -16
- package/{recipes → content/recipes}/nvca-certificate-of-incorporation/metadata.yaml +13 -13
- package/{recipes → content/recipes}/nvca-indemnification-agreement/metadata.yaml +17 -21
- package/{recipes → content/recipes}/nvca-investors-rights-agreement/metadata.yaml +18 -22
- package/{recipes → content/recipes}/nvca-management-rights-letter/metadata.yaml +13 -16
- package/{recipes → content/recipes}/nvca-rofr-co-sale-agreement/metadata.yaml +20 -24
- package/content/recipes/nvca-stock-purchase-agreement/clean.json +13 -0
- package/content/recipes/nvca-stock-purchase-agreement/computed.json +103 -0
- package/content/recipes/nvca-stock-purchase-agreement/metadata.yaml +138 -0
- package/content/recipes/nvca-stock-purchase-agreement/normalize.json +83 -0
- package/content/recipes/nvca-stock-purchase-agreement/replacements.json +41 -0
- package/{recipes → content/recipes}/nvca-voting-agreement/metadata.yaml +19 -23
- package/{templates → content/templates}/bonterms-mutual-nda/metadata.yaml +14 -14
- package/{templates → content/templates}/bonterms-professional-services-agreement/metadata.yaml +11 -13
- package/content/templates/closing-checklist/metadata.yaml +39 -0
- package/content/templates/closing-checklist/template.docx +0 -0
- package/{templates → content/templates}/common-paper-ai-addendum/metadata.yaml +8 -10
- package/{templates → content/templates}/common-paper-ai-addendum-in-app/metadata.yaml +6 -8
- package/{templates → content/templates}/common-paper-amendment/metadata.yaml +14 -14
- package/{templates → content/templates}/common-paper-business-associate-agreement/metadata.yaml +9 -16
- package/{templates → content/templates}/common-paper-cloud-service-agreement/metadata.yaml +53 -187
- package/{templates → content/templates}/common-paper-cloud-service-agreement/template.docx +0 -0
- package/{templates → content/templates}/common-paper-csa-click-through/metadata.yaml +10 -20
- package/{templates → content/templates}/common-paper-csa-with-ai/metadata.yaml +14 -37
- package/{templates → content/templates}/common-paper-csa-with-sla/metadata.yaml +14 -40
- package/{templates → content/templates}/common-paper-csa-without-sla/metadata.yaml +14 -34
- package/{templates → content/templates}/common-paper-data-processing-agreement/metadata.yaml +15 -34
- package/{templates → content/templates}/common-paper-design-partner-agreement/metadata.yaml +10 -16
- package/{templates → content/templates}/common-paper-independent-contractor-agreement/metadata.yaml +14 -14
- package/{templates → content/templates}/common-paper-letter-of-intent/metadata.yaml +11 -12
- package/{templates → content/templates}/common-paper-mutual-nda/metadata.yaml +13 -13
- package/{templates → content/templates}/common-paper-one-way-nda/metadata.yaml +13 -14
- package/{templates → content/templates}/common-paper-order-form/metadata.yaml +12 -23
- package/{templates → content/templates}/common-paper-order-form-with-sla/metadata.yaml +12 -30
- package/{templates → content/templates}/common-paper-partnership-agreement/metadata.yaml +9 -21
- package/{templates → content/templates}/common-paper-pilot-agreement/metadata.yaml +15 -29
- package/{templates → content/templates}/common-paper-professional-services-agreement/metadata.yaml +15 -32
- package/{templates → content/templates}/common-paper-software-license-agreement/metadata.yaml +6 -6
- package/{templates → content/templates}/common-paper-statement-of-work/metadata.yaml +12 -19
- package/{templates → content/templates}/common-paper-term-sheet/metadata.yaml +9 -9
- package/content/templates/openagreements-employee-ip-inventions-assignment/README.md +31 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/metadata.yaml +71 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/template.docx +0 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/template.md +80 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/README.md +30 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/metadata.yaml +60 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.docx +0 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.md +51 -0
- package/content/templates/openagreements-employment-offer-letter/README.md +33 -0
- package/content/templates/openagreements-employment-offer-letter/metadata.yaml +75 -0
- package/content/templates/openagreements-employment-offer-letter/template.docx +0 -0
- package/content/templates/openagreements-employment-offer-letter/template.md +90 -0
- package/content/templates/working-group-list/metadata.yaml +22 -0
- package/content/templates/working-group-list/template.docx +0 -0
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +185 -89
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/checklist.d.ts +22 -0
- package/dist/commands/checklist.d.ts.map +1 -0
- package/dist/commands/checklist.js +222 -0
- package/dist/commands/checklist.js.map +1 -0
- package/dist/commands/fill.d.ts +11 -0
- package/dist/commands/fill.d.ts.map +1 -1
- package/dist/commands/fill.js +56 -1
- package/dist/commands/fill.js.map +1 -1
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +147 -72
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/recipe.d.ts +2 -0
- package/dist/commands/recipe.d.ts.map +1 -1
- package/dist/commands/recipe.js +5 -0
- package/dist/commands/recipe.js.map +1 -1
- package/dist/commands/scan.d.ts +16 -0
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +36 -20
- package/dist/commands/scan.js.map +1 -1
- package/dist/core/checklist/index.d.ts +38 -0
- package/dist/core/checklist/index.d.ts.map +1 -0
- package/dist/core/checklist/index.js +229 -0
- package/dist/core/checklist/index.js.map +1 -0
- package/dist/core/checklist/patch-apply.d.ts +65 -0
- package/dist/core/checklist/patch-apply.d.ts.map +1 -0
- package/dist/core/checklist/patch-apply.js +274 -0
- package/dist/core/checklist/patch-apply.js.map +1 -0
- package/dist/core/checklist/patch-schemas.d.ts +86 -0
- package/dist/core/checklist/patch-schemas.d.ts.map +1 -0
- package/dist/core/checklist/patch-schemas.js +89 -0
- package/dist/core/checklist/patch-schemas.js.map +1 -0
- package/dist/core/checklist/patch-validator.d.ts +76 -0
- package/dist/core/checklist/patch-validator.d.ts.map +1 -0
- package/dist/core/checklist/patch-validator.js +404 -0
- package/dist/core/checklist/patch-validator.js.map +1 -0
- package/dist/core/checklist/schemas.d.ts +270 -0
- package/dist/core/checklist/schemas.d.ts.map +1 -0
- package/dist/core/checklist/schemas.js +229 -0
- package/dist/core/checklist/schemas.js.map +1 -0
- package/dist/core/checklist/test-utils.d.ts +7 -0
- package/dist/core/checklist/test-utils.d.ts.map +1 -0
- package/dist/core/checklist/test-utils.js +13 -0
- package/dist/core/checklist/test-utils.js.map +1 -0
- package/dist/core/command-generation/adapters/claude.d.ts.map +1 -1
- package/dist/core/command-generation/adapters/claude.js +8 -2
- package/dist/core/command-generation/adapters/claude.js.map +1 -1
- package/dist/core/employment/jurisdiction-rules.d.ts +20 -0
- package/dist/core/employment/jurisdiction-rules.d.ts.map +1 -0
- package/dist/core/employment/jurisdiction-rules.js +57 -0
- package/dist/core/employment/jurisdiction-rules.js.map +1 -0
- package/dist/core/employment/memo.d.ts +57 -0
- package/dist/core/employment/memo.d.ts.map +1 -0
- package/dist/core/employment/memo.js +589 -0
- package/dist/core/employment/memo.js.map +1 -0
- package/dist/core/engine.d.ts +1 -1
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +33 -1
- package/dist/core/engine.js.map +1 -1
- package/dist/core/external/index.d.ts.map +1 -1
- package/dist/core/external/index.js +1 -0
- package/dist/core/external/index.js.map +1 -1
- package/dist/core/external/types.d.ts +1 -1
- package/dist/core/external/types.d.ts.map +1 -1
- package/dist/core/fill-pipeline.d.ts +8 -5
- package/dist/core/fill-pipeline.d.ts.map +1 -1
- package/dist/core/fill-pipeline.js +85 -14
- package/dist/core/fill-pipeline.js.map +1 -1
- package/dist/core/fill-utils.d.ts +1 -1
- package/dist/core/fill-utils.d.ts.map +1 -1
- package/dist/core/fill-utils.js.map +1 -1
- package/dist/core/metadata.d.ts +110 -409
- package/dist/core/metadata.d.ts.map +1 -1
- package/dist/core/metadata.js +56 -4
- package/dist/core/metadata.js.map +1 -1
- package/dist/core/recipe/bracket-normalizer.d.ts +46 -0
- package/dist/core/recipe/bracket-normalizer.d.ts.map +1 -0
- package/dist/core/recipe/bracket-normalizer.js +354 -0
- package/dist/core/recipe/bracket-normalizer.js.map +1 -0
- package/dist/core/recipe/cleaner.d.ts +2 -2
- package/dist/core/recipe/cleaner.d.ts.map +1 -1
- package/dist/core/recipe/cleaner.js +13 -9
- package/dist/core/recipe/cleaner.js.map +1 -1
- package/dist/core/recipe/computed.d.ts +136 -0
- package/dist/core/recipe/computed.d.ts.map +1 -0
- package/dist/core/recipe/computed.js +225 -0
- package/dist/core/recipe/computed.js.map +1 -0
- package/dist/core/recipe/index.d.ts +2 -0
- package/dist/core/recipe/index.d.ts.map +1 -1
- package/dist/core/recipe/index.js +51 -4
- package/dist/core/recipe/index.js.map +1 -1
- package/dist/core/recipe/source-drift.d.ts +33 -0
- package/dist/core/recipe/source-drift.d.ts.map +1 -0
- package/dist/core/recipe/source-drift.js +113 -0
- package/dist/core/recipe/source-drift.js.map +1 -0
- package/dist/core/recipe/types.d.ts +6 -1
- package/dist/core/recipe/types.d.ts.map +1 -1
- package/dist/core/recipe/verifier.d.ts +1 -1
- package/dist/core/recipe/verifier.d.ts.map +1 -1
- package/dist/core/recipe/verifier.js +2 -2
- package/dist/core/recipe/verifier.js.map +1 -1
- package/dist/core/selector.d.ts +12 -87
- package/dist/core/selector.d.ts.map +1 -1
- package/dist/core/selector.js +5 -7
- package/dist/core/selector.js.map +1 -1
- package/dist/core/unified-pipeline.d.ts +4 -2
- package/dist/core/unified-pipeline.d.ts.map +1 -1
- package/dist/core/unified-pipeline.js +6 -1
- package/dist/core/unified-pipeline.js.map +1 -1
- package/dist/core/validation/recipe.d.ts +1 -1
- package/dist/core/validation/recipe.d.ts.map +1 -1
- package/dist/core/validation/recipe.js +43 -40
- package/dist/core/validation/recipe.js.map +1 -1
- package/dist/core/validation/scan-metadata.d.ts +21 -0
- package/dist/core/validation/scan-metadata.d.ts.map +1 -0
- package/dist/core/validation/scan-metadata.js +70 -0
- package/dist/core/validation/scan-metadata.js.map +1 -0
- package/dist/core/validation/template.d.ts.map +1 -1
- package/dist/core/validation/template.js +19 -6
- package/dist/core/validation/template.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +13 -6
- package/dist/utils/paths.js.map +1 -1
- package/package.json +60 -10
- package/skills/cloud-service-agreement/CONNECTORS.md +19 -0
- package/skills/cloud-service-agreement/SKILL.md +172 -0
- package/skills/data-privacy-agreement/CONNECTORS.md +19 -0
- package/skills/data-privacy-agreement/SKILL.md +158 -0
- package/skills/delaware-franchise-tax/CONNECTORS.md +16 -0
- package/skills/delaware-franchise-tax/SKILL.md +206 -0
- package/skills/delaware-franchise-tax/reference/ecorp-portal-playwright-notes.md +136 -0
- package/skills/delaware-franchise-tax/reference/faq.md +101 -0
- package/skills/delaware-franchise-tax/reference/filing-instructions.md +111 -0
- package/skills/delaware-franchise-tax/reference/tax-calculation.md +167 -0
- package/skills/employment-contract/CONNECTORS.md +19 -0
- package/skills/employment-contract/SKILL.md +157 -0
- package/skills/nda/CONNECTORS.md +19 -0
- package/skills/nda/SKILL.md +153 -0
- package/skills/open-agreements/CONNECTORS.md +19 -0
- package/skills/open-agreements/SKILL.md +86 -70
- package/skills/safe/CONNECTORS.md +19 -0
- package/skills/safe/SKILL.md +161 -0
- package/skills/services-agreement/CONNECTORS.md +19 -0
- package/skills/services-agreement/SKILL.md +156 -0
- package/skills/unit-test-philosophy/SKILL.md +113 -0
- package/skills/unit-test-philosophy/references/allure-test-spec-writing-guide.md +164 -0
- package/skills/venture-financing/CONNECTORS.md +19 -0
- package/skills/venture-financing/SKILL.md +169 -0
- package/recipes/nvca-certificate-of-incorporation/schema.json +0 -11
- package/recipes/nvca-indemnification-agreement/schema.json +0 -19
- package/recipes/nvca-investors-rights-agreement/schema.json +0 -18
- package/recipes/nvca-management-rights-letter/schema.json +0 -13
- package/recipes/nvca-rofr-co-sale-agreement/schema.json +0 -19
- package/recipes/nvca-stock-purchase-agreement/clean.json +0 -10
- package/recipes/nvca-stock-purchase-agreement/metadata.yaml +0 -74
- package/recipes/nvca-stock-purchase-agreement/replacements.json +0 -20
- package/recipes/nvca-stock-purchase-agreement/schema.json +0 -19
- package/recipes/nvca-voting-agreement/schema.json +0 -28
- /package/{external → content/external}/LICENSE +0 -0
- /package/{external → content/external}/README.md +0 -0
- /package/{external → content/external}/yc-safe-discount/README.md +0 -0
- /package/{external → content/external}/yc-safe-discount/clean.json +0 -0
- /package/{external → content/external}/yc-safe-discount/replacements.json +0 -0
- /package/{external → content/external}/yc-safe-discount/template.docx +0 -0
- /package/{external → content/external}/yc-safe-mfn/README.md +0 -0
- /package/{external → content/external}/yc-safe-mfn/clean.json +0 -0
- /package/{external → content/external}/yc-safe-mfn/replacements.json +0 -0
- /package/{external → content/external}/yc-safe-mfn/template.docx +0 -0
- /package/{external → content/external}/yc-safe-pro-rata-side-letter/README.md +0 -0
- /package/{external → content/external}/yc-safe-pro-rata-side-letter/clean.json +0 -0
- /package/{external → content/external}/yc-safe-pro-rata-side-letter/replacements.json +0 -0
- /package/{external → content/external}/yc-safe-pro-rata-side-letter/template.docx +0 -0
- /package/{external → content/external}/yc-safe-valuation-cap/README.md +0 -0
- /package/{external → content/external}/yc-safe-valuation-cap/clean.json +0 -0
- /package/{external → content/external}/yc-safe-valuation-cap/replacements.json +0 -0
- /package/{external → content/external}/yc-safe-valuation-cap/template.docx +0 -0
- /package/{recipes → content/recipes}/nvca-certificate-of-incorporation/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-certificate-of-incorporation/replacements.json +0 -0
- /package/{recipes → content/recipes}/nvca-indemnification-agreement/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-indemnification-agreement/replacements.json +0 -0
- /package/{recipes → content/recipes}/nvca-investors-rights-agreement/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-investors-rights-agreement/replacements.json +0 -0
- /package/{recipes → content/recipes}/nvca-management-rights-letter/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-management-rights-letter/replacements.json +0 -0
- /package/{recipes → content/recipes}/nvca-rofr-co-sale-agreement/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-rofr-co-sale-agreement/replacements.json +0 -0
- /package/{recipes → content/recipes}/nvca-voting-agreement/README.md +0 -0
- /package/{recipes → content/recipes}/nvca-voting-agreement/clean.json +0 -0
- /package/{recipes → content/recipes}/nvca-voting-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/bonterms-mutual-nda/README.md +0 -0
- /package/{templates → content/templates}/bonterms-mutual-nda/source.json +0 -0
- /package/{templates → content/templates}/bonterms-mutual-nda/template.docx +0 -0
- /package/{templates → content/templates}/bonterms-professional-services-agreement/README.md +0 -0
- /package/{templates → content/templates}/bonterms-professional-services-agreement/selections.json +0 -0
- /package/{templates → content/templates}/bonterms-professional-services-agreement/source.json +0 -0
- /package/{templates → content/templates}/bonterms-professional-services-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-ai-addendum/README.md +0 -0
- /package/{templates → content/templates}/common-paper-ai-addendum/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-ai-addendum-in-app/README.md +0 -0
- /package/{templates → content/templates}/common-paper-ai-addendum-in-app/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-amendment/README.md +0 -0
- /package/{templates → content/templates}/common-paper-amendment/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-business-associate-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-business-associate-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-business-associate-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-cloud-service-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-csa-click-through/README.md +0 -0
- /package/{templates → content/templates}/common-paper-csa-click-through/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-ai/README.md +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-ai/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-ai/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-sla/README.md +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-sla/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-csa-with-sla/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-csa-without-sla/README.md +0 -0
- /package/{templates → content/templates}/common-paper-csa-without-sla/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-csa-without-sla/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-data-processing-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-data-processing-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-data-processing-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-design-partner-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-design-partner-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-design-partner-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-independent-contractor-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-independent-contractor-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-letter-of-intent/README.md +0 -0
- /package/{templates → content/templates}/common-paper-letter-of-intent/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-mutual-nda/README.md +0 -0
- /package/{templates → content/templates}/common-paper-mutual-nda/selections.json +0 -0
- /package/{templates → content/templates}/common-paper-mutual-nda/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-one-way-nda/README.md +0 -0
- /package/{templates → content/templates}/common-paper-one-way-nda/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-order-form/README.md +0 -0
- /package/{templates → content/templates}/common-paper-order-form/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-order-form/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-order-form-with-sla/README.md +0 -0
- /package/{templates → content/templates}/common-paper-order-form-with-sla/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-order-form-with-sla/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-partnership-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-partnership-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-partnership-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-pilot-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-pilot-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-pilot-agreement/selections.json +0 -0
- /package/{templates → content/templates}/common-paper-pilot-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-professional-services-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-professional-services-agreement/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-professional-services-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-software-license-agreement/README.md +0 -0
- /package/{templates → content/templates}/common-paper-software-license-agreement/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-statement-of-work/README.md +0 -0
- /package/{templates → content/templates}/common-paper-statement-of-work/replacements.json +0 -0
- /package/{templates → content/templates}/common-paper-statement-of-work/template.docx +0 -0
- /package/{templates → content/templates}/common-paper-term-sheet/README.md +0 -0
- /package/{templates → content/templates}/common-paper-term-sheet/template.docx +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"A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, PatchCitationSchema, ChecklistPatchSourceEventSchema, ChecklistPatchOperationSchema, ChecklistPatchEnvelopeSchema, ChecklistPatchApplyRequestSchema, type ChecklistPatchMode, type JsonPointer, type PatchCitation, type ChecklistPatchSourceEvent, type ChecklistPatchOperation, type ChecklistPatchEnvelope, type ChecklistPatchApplyRequest, } from './patch-schemas.js';
|
|
3
|
+
export { CHECKLIST_PATCH_VALIDATION_TTL_MS, DANGEROUS_KEYS, applyChecklistPatchOperations, computeChecklistPatchHash, validateChecklistPatch, getChecklistPatchValidationArtifact, setChecklistPatchValidationStore, getChecklistPatchValidationStore, type ChecklistPatchValidationErrorCode, type ChecklistPatchValidationDiagnostic, type ResolvedChecklistPatchOperation, type ChecklistPatchValidationArtifact, type ChecklistPatchValidationStore, type ValidateChecklistPatchInput, type ChecklistPatchValidationSuccess, type ChecklistPatchValidationFailure, type ChecklistPatchValidationResult, } from './patch-validator.js';
|
|
4
|
+
export { applyChecklistPatch, setChecklistAppliedPatchStore, getChecklistAppliedPatchStore, setChecklistProposedPatchStore, getChecklistProposedPatchStore, type ChecklistAppliedPatchRecord, type ChecklistAppliedPatchStore, type ChecklistProposedPatchRecord, type ChecklistProposedPatchStore, type ChecklistPatchApplyErrorCode, type ChecklistPatchApplyFailure, type ChecklistPatchApplySuccess, type ChecklistPatchApplyResult, type ApplyChecklistPatchInput, } from './patch-apply.js';
|
|
5
|
+
interface LegacyTemplateDocumentRow {
|
|
6
|
+
document_name: string;
|
|
7
|
+
status: string;
|
|
8
|
+
}
|
|
9
|
+
interface LegacyTemplateActionRow {
|
|
10
|
+
item_id: string;
|
|
11
|
+
description: string;
|
|
12
|
+
status: string;
|
|
13
|
+
assigned_to: {
|
|
14
|
+
organization: string;
|
|
15
|
+
};
|
|
16
|
+
due_date: string;
|
|
17
|
+
}
|
|
18
|
+
interface LegacyTemplateIssueRow {
|
|
19
|
+
issue_id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
status: string;
|
|
22
|
+
escalation_tier: string;
|
|
23
|
+
resolution: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ChecklistTemplateContext {
|
|
26
|
+
deal_name: string;
|
|
27
|
+
updated_at: string;
|
|
28
|
+
working_group: Array<Record<string, unknown>>;
|
|
29
|
+
documents: LegacyTemplateDocumentRow[];
|
|
30
|
+
action_items: LegacyTemplateActionRow[];
|
|
31
|
+
open_issues: LegacyTemplateIssueRow[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build template values for the legacy closing-checklist DOCX template from
|
|
35
|
+
* document-first v2 checklist input.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildChecklistTemplateContext(data: unknown): ChecklistTemplateContext;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/checklist/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iCAAiC,EACjC,cAAc,EACd,6BAA6B,EAC7B,yBAAyB,EACzB,sBAAsB,EACtB,mCAAmC,EACnC,gCAAgC,EAChC,gCAAgC,EAChC,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,GACpC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as.js';
|
|
2
|
+
export { ClosingChecklistSchema } from './schemas.js';
|
|
3
|
+
export { ChecklistPatchModeEnum, JsonPointerSchema, PatchCitationSchema, ChecklistPatchSourceEventSchema, ChecklistPatchOperationSchema, ChecklistPatchEnvelopeSchema, ChecklistPatchApplyRequestSchema, } from './patch-schemas.js';
|
|
4
|
+
export { CHECKLIST_PATCH_VALIDATION_TTL_MS, DANGEROUS_KEYS, applyChecklistPatchOperations, computeChecklistPatchHash, validateChecklistPatch, getChecklistPatchValidationArtifact, setChecklistPatchValidationStore, getChecklistPatchValidationStore, } from './patch-validator.js';
|
|
5
|
+
export { applyChecklistPatch, setChecklistAppliedPatchStore, getChecklistAppliedPatchStore, setChecklistProposedPatchStore, getChecklistProposedPatchStore, } from './patch-apply.js';
|
|
6
|
+
const STAGE_ORDER = ['PRE_SIGNING', 'SIGNING', 'CLOSING', 'POST_CLOSING'];
|
|
7
|
+
const STAGE_HEADINGS = {
|
|
8
|
+
PRE_SIGNING: 'PRE-SIGNING',
|
|
9
|
+
SIGNING: 'SIGNING',
|
|
10
|
+
CLOSING: 'CLOSING',
|
|
11
|
+
POST_CLOSING: 'POST-CLOSING',
|
|
12
|
+
};
|
|
13
|
+
const STAGE_ROMANS = ['I', 'II', 'III', 'IV'];
|
|
14
|
+
function compareBySortKey(a, b) {
|
|
15
|
+
const keyCompare = a.sort_key.localeCompare(b.sort_key, undefined, { numeric: true, sensitivity: 'base' });
|
|
16
|
+
if (keyCompare !== 0)
|
|
17
|
+
return keyCompare;
|
|
18
|
+
return a.entry_id.localeCompare(b.entry_id);
|
|
19
|
+
}
|
|
20
|
+
function nonEmpty(values) {
|
|
21
|
+
return values.map((v) => v.trim()).filter((v) => v.length > 0);
|
|
22
|
+
}
|
|
23
|
+
function responsibilityLabel(responsibility) {
|
|
24
|
+
if (!responsibility)
|
|
25
|
+
return '';
|
|
26
|
+
return nonEmpty([
|
|
27
|
+
responsibility.individual_name ?? '',
|
|
28
|
+
responsibility.organization ?? '',
|
|
29
|
+
responsibility.role ?? '',
|
|
30
|
+
]).join(', ');
|
|
31
|
+
}
|
|
32
|
+
function citationLabel(citation) {
|
|
33
|
+
const base = citation.text ?? citation.ref ?? '';
|
|
34
|
+
const sources = nonEmpty([citation.link ?? '', citation.filepath ?? '']);
|
|
35
|
+
if (!base)
|
|
36
|
+
return sources.join(' | ');
|
|
37
|
+
if (sources.length === 0)
|
|
38
|
+
return base;
|
|
39
|
+
return `${base} (${sources.join(' | ')})`;
|
|
40
|
+
}
|
|
41
|
+
function latestCitationLabel(citations) {
|
|
42
|
+
if (citations.length === 0)
|
|
43
|
+
return '';
|
|
44
|
+
return citationLabel(citations[citations.length - 1]);
|
|
45
|
+
}
|
|
46
|
+
function signatoryLabel(signatory) {
|
|
47
|
+
const who = nonEmpty([signatory.party, signatory.name ?? '', signatory.title ?? '']).join(' ');
|
|
48
|
+
const artifacts = signatory.signature_artifacts
|
|
49
|
+
.map((artifact) => artifact.uri ?? artifact.path ?? '')
|
|
50
|
+
.filter((value) => value.length > 0);
|
|
51
|
+
if (artifacts.length === 0) {
|
|
52
|
+
return `${who} [${signatory.status}]`;
|
|
53
|
+
}
|
|
54
|
+
return `${who} [${signatory.status}] (${artifacts.join(', ')})`;
|
|
55
|
+
}
|
|
56
|
+
function toArray(collection) {
|
|
57
|
+
return Array.isArray(collection) ? collection : Object.values(collection);
|
|
58
|
+
}
|
|
59
|
+
function buildRenderModel(data) {
|
|
60
|
+
const checklist = ClosingChecklistSchema.parse(data);
|
|
61
|
+
const documents = toArray(checklist.documents);
|
|
62
|
+
const entries = toArray(checklist.checklist_entries);
|
|
63
|
+
const actions = toArray(checklist.action_items);
|
|
64
|
+
const issues = toArray(checklist.issues);
|
|
65
|
+
const documentsById = new Map(documents.map((document) => [document.document_id, document]));
|
|
66
|
+
const entryDocumentIds = new Set(entries
|
|
67
|
+
.map((entry) => entry.document_id)
|
|
68
|
+
.filter((documentId) => Boolean(documentId)));
|
|
69
|
+
const actionsByDocument = new Map();
|
|
70
|
+
const unlinkedActions = [];
|
|
71
|
+
for (const action of actions) {
|
|
72
|
+
const linkedDocumentIds = action.related_document_ids.filter((documentId) => entryDocumentIds.has(documentId));
|
|
73
|
+
if (linkedDocumentIds.length === 0) {
|
|
74
|
+
unlinkedActions.push(action);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
for (const documentId of linkedDocumentIds) {
|
|
78
|
+
const current = actionsByDocument.get(documentId) ?? [];
|
|
79
|
+
current.push(action);
|
|
80
|
+
actionsByDocument.set(documentId, current);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const issuesByDocument = new Map();
|
|
84
|
+
const unlinkedIssues = [];
|
|
85
|
+
for (const issue of issues) {
|
|
86
|
+
const linkedDocumentIds = issue.related_document_ids.filter((documentId) => entryDocumentIds.has(documentId));
|
|
87
|
+
if (linkedDocumentIds.length === 0) {
|
|
88
|
+
unlinkedIssues.push(issue);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
for (const documentId of linkedDocumentIds) {
|
|
92
|
+
const current = issuesByDocument.get(documentId) ?? [];
|
|
93
|
+
current.push(issue);
|
|
94
|
+
issuesByDocument.set(documentId, current);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const actionGroup of actionsByDocument.values()) {
|
|
98
|
+
actionGroup.sort((a, b) => a.action_id.localeCompare(b.action_id));
|
|
99
|
+
}
|
|
100
|
+
for (const issueGroup of issuesByDocument.values()) {
|
|
101
|
+
issueGroup.sort((a, b) => a.issue_id.localeCompare(b.issue_id));
|
|
102
|
+
}
|
|
103
|
+
unlinkedActions.sort((a, b) => a.action_id.localeCompare(b.action_id));
|
|
104
|
+
unlinkedIssues.sort((a, b) => a.issue_id.localeCompare(b.issue_id));
|
|
105
|
+
const rowsByStage = new Map();
|
|
106
|
+
for (const stage of STAGE_ORDER) {
|
|
107
|
+
const stageEntries = entries
|
|
108
|
+
.filter((entry) => entry.stage === stage)
|
|
109
|
+
.sort(compareBySortKey);
|
|
110
|
+
const stageEntriesById = new Map(stageEntries.map((entry) => [entry.entry_id, entry]));
|
|
111
|
+
const childrenByParent = new Map();
|
|
112
|
+
const roots = [];
|
|
113
|
+
for (const entry of stageEntries) {
|
|
114
|
+
if (entry.parent_entry_id && stageEntriesById.has(entry.parent_entry_id)) {
|
|
115
|
+
const children = childrenByParent.get(entry.parent_entry_id) ?? [];
|
|
116
|
+
children.push(entry);
|
|
117
|
+
childrenByParent.set(entry.parent_entry_id, children);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
roots.push(entry);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
roots.sort(compareBySortKey);
|
|
124
|
+
for (const [parentId, children] of childrenByParent.entries()) {
|
|
125
|
+
children.sort(compareBySortKey);
|
|
126
|
+
childrenByParent.set(parentId, children);
|
|
127
|
+
}
|
|
128
|
+
const stageRows = [];
|
|
129
|
+
const visit = (entry, depth, number) => {
|
|
130
|
+
const document = entry.document_id ? (documentsById.get(entry.document_id) ?? null) : null;
|
|
131
|
+
stageRows.push({
|
|
132
|
+
entry,
|
|
133
|
+
document,
|
|
134
|
+
number,
|
|
135
|
+
depth,
|
|
136
|
+
linkedActions: entry.document_id ? (actionsByDocument.get(entry.document_id) ?? []) : [],
|
|
137
|
+
linkedIssues: entry.document_id ? (issuesByDocument.get(entry.document_id) ?? []) : [],
|
|
138
|
+
});
|
|
139
|
+
const children = childrenByParent.get(entry.entry_id) ?? [];
|
|
140
|
+
children.forEach((child, index) => {
|
|
141
|
+
visit(child, depth + 1, `${number}.${index + 1}`);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
roots.forEach((entry, index) => {
|
|
145
|
+
visit(entry, 0, `${index + 1}`);
|
|
146
|
+
});
|
|
147
|
+
rowsByStage.set(stage, stageRows);
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
checklist,
|
|
151
|
+
rowsByStage,
|
|
152
|
+
unlinkedActions,
|
|
153
|
+
unlinkedIssues,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Build template values for the legacy closing-checklist DOCX template from
|
|
158
|
+
* document-first v2 checklist input.
|
|
159
|
+
*/
|
|
160
|
+
export function buildChecklistTemplateContext(data) {
|
|
161
|
+
const model = buildRenderModel(data);
|
|
162
|
+
const documentRows = [];
|
|
163
|
+
STAGE_ORDER.forEach((stage, index) => {
|
|
164
|
+
const stageRows = model.rowsByStage.get(stage) ?? [];
|
|
165
|
+
if (stageRows.length === 0)
|
|
166
|
+
return;
|
|
167
|
+
documentRows.push({
|
|
168
|
+
document_name: `${STAGE_ROMANS[index]}. ${STAGE_HEADINGS[stage]}`,
|
|
169
|
+
status: '',
|
|
170
|
+
});
|
|
171
|
+
for (const row of stageRows) {
|
|
172
|
+
const indent = '\u00A0\u00A0'.repeat(row.depth);
|
|
173
|
+
const citationText = row.entry.citations.map(citationLabel).join('; ');
|
|
174
|
+
const linkText = row.document?.primary_link ? ` (${row.document.primary_link})` : '';
|
|
175
|
+
const documentName = `${row.number} ${indent}${row.entry.title}${citationText ? ` [${citationText}]` : ''}${linkText}`;
|
|
176
|
+
const statusParts = [row.entry.status];
|
|
177
|
+
if (row.entry.signatories.length > 0) {
|
|
178
|
+
statusParts.push(row.entry.signatories.map(signatoryLabel).join('; '));
|
|
179
|
+
}
|
|
180
|
+
const responsibility = responsibilityLabel(row.entry.responsible_party);
|
|
181
|
+
if (responsibility) {
|
|
182
|
+
statusParts.push(`Resp: ${responsibility}`);
|
|
183
|
+
}
|
|
184
|
+
documentRows.push({
|
|
185
|
+
document_name: documentName,
|
|
186
|
+
status: statusParts.join(' | '),
|
|
187
|
+
});
|
|
188
|
+
for (const action of row.linkedActions) {
|
|
189
|
+
const latestCitation = latestCitationLabel(action.citations);
|
|
190
|
+
documentRows.push({
|
|
191
|
+
document_name: `\u00A0\u00A0${indent}\u21B3 Action ${action.action_id}: ${action.description}`,
|
|
192
|
+
status: latestCitation ? `${action.status} | Evidence: ${latestCitation}` : action.status,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
for (const issue of row.linkedIssues) {
|
|
196
|
+
const latestCitation = latestCitationLabel(issue.citations);
|
|
197
|
+
documentRows.push({
|
|
198
|
+
document_name: `\u00A0\u00A0${indent}\u21B3 Issue ${issue.issue_id}: ${issue.title}`,
|
|
199
|
+
status: latestCitation ? `${issue.status} | Evidence: ${latestCitation}` : issue.status,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const fallbackActions = model.unlinkedActions.map((action) => ({
|
|
205
|
+
item_id: action.action_id,
|
|
206
|
+
description: action.description,
|
|
207
|
+
status: latestCitationLabel(action.citations) ? `${action.status} | ${latestCitationLabel(action.citations)}` : action.status,
|
|
208
|
+
assigned_to: {
|
|
209
|
+
organization: responsibilityLabel(action.assigned_to) || '',
|
|
210
|
+
},
|
|
211
|
+
due_date: action.due_date ?? '',
|
|
212
|
+
}));
|
|
213
|
+
const fallbackIssues = model.unlinkedIssues.map((issue) => ({
|
|
214
|
+
issue_id: issue.issue_id,
|
|
215
|
+
title: issue.title,
|
|
216
|
+
status: issue.status,
|
|
217
|
+
escalation_tier: '',
|
|
218
|
+
resolution: nonEmpty([issue.summary ?? '', latestCitationLabel(issue.citations)]).join(' | '),
|
|
219
|
+
}));
|
|
220
|
+
return {
|
|
221
|
+
deal_name: model.checklist.deal_name,
|
|
222
|
+
updated_at: model.checklist.updated_at,
|
|
223
|
+
working_group: [],
|
|
224
|
+
documents: documentRows,
|
|
225
|
+
action_items: fallbackActions,
|
|
226
|
+
open_issues: fallbackIssues,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/checklist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAUvB,MAAM,cAAc,CAAC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AAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ClosingChecklist } from './schemas.js';
|
|
2
|
+
import { type ChecklistPatchEnvelope } from './patch-schemas.js';
|
|
3
|
+
import { type ChecklistPatchValidationDiagnostic, type ChecklistPatchValidationStore, type ResolvedChecklistPatchOperation } from './patch-validator.js';
|
|
4
|
+
export interface ChecklistAppliedPatchRecord {
|
|
5
|
+
checklist_id: string;
|
|
6
|
+
patch_id: string;
|
|
7
|
+
patch_hash: string;
|
|
8
|
+
applied_at_ms: number;
|
|
9
|
+
revision_before: number;
|
|
10
|
+
revision_after: number;
|
|
11
|
+
patch: ChecklistPatchEnvelope;
|
|
12
|
+
}
|
|
13
|
+
export interface ChecklistAppliedPatchStore {
|
|
14
|
+
get(checklistId: string, patchId: string): Promise<ChecklistAppliedPatchRecord | null>;
|
|
15
|
+
set(record: ChecklistAppliedPatchRecord): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface ChecklistProposedPatchRecord {
|
|
18
|
+
checklist_id: string;
|
|
19
|
+
patch_id: string;
|
|
20
|
+
patch_hash: string;
|
|
21
|
+
proposed_at_ms: number;
|
|
22
|
+
expected_revision: number;
|
|
23
|
+
validation_id: string;
|
|
24
|
+
resolved_operations: ResolvedChecklistPatchOperation[];
|
|
25
|
+
}
|
|
26
|
+
export interface ChecklistProposedPatchStore {
|
|
27
|
+
get(checklistId: string, patchId: string): Promise<ChecklistProposedPatchRecord | null>;
|
|
28
|
+
set(record: ChecklistProposedPatchRecord): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function setChecklistAppliedPatchStore(store: ChecklistAppliedPatchStore | null): void;
|
|
31
|
+
export declare function getChecklistAppliedPatchStore(): ChecklistAppliedPatchStore;
|
|
32
|
+
export declare function setChecklistProposedPatchStore(store: ChecklistProposedPatchStore | null): void;
|
|
33
|
+
export declare function getChecklistProposedPatchStore(): ChecklistProposedPatchStore;
|
|
34
|
+
export type ChecklistPatchApplyErrorCode = 'CHECKLIST_SCHEMA_INVALID' | 'APPLY_REQUEST_SCHEMA_INVALID' | 'VALIDATION_REQUIRED' | 'VALIDATION_MISMATCH' | 'REVISION_CONFLICT' | 'PATCH_ID_CONFLICT' | 'APPLY_OPERATION_FAILED' | 'POST_PATCH_SCHEMA_INVALID';
|
|
35
|
+
export interface ChecklistPatchApplyFailure {
|
|
36
|
+
ok: false;
|
|
37
|
+
error_code: ChecklistPatchApplyErrorCode;
|
|
38
|
+
message: string;
|
|
39
|
+
diagnostics: ChecklistPatchValidationDiagnostic[];
|
|
40
|
+
}
|
|
41
|
+
export interface ChecklistPatchApplySuccess {
|
|
42
|
+
ok: true;
|
|
43
|
+
checklist: ClosingChecklist;
|
|
44
|
+
previous_revision: number;
|
|
45
|
+
new_revision: number;
|
|
46
|
+
patch_id: string;
|
|
47
|
+
patch_hash: string;
|
|
48
|
+
idempotent_replay: boolean;
|
|
49
|
+
mode: 'APPLY' | 'PROPOSED';
|
|
50
|
+
applied: boolean;
|
|
51
|
+
resolved_operations: ResolvedChecklistPatchOperation[];
|
|
52
|
+
}
|
|
53
|
+
export type ChecklistPatchApplyResult = ChecklistPatchApplySuccess | ChecklistPatchApplyFailure;
|
|
54
|
+
export interface ApplyChecklistPatchInput {
|
|
55
|
+
checklist_id: string;
|
|
56
|
+
checklist: unknown;
|
|
57
|
+
current_revision: number;
|
|
58
|
+
request: unknown;
|
|
59
|
+
now_ms?: number;
|
|
60
|
+
validation_store?: ChecklistPatchValidationStore;
|
|
61
|
+
applied_patch_store?: ChecklistAppliedPatchStore;
|
|
62
|
+
proposed_patch_store?: ChecklistProposedPatchStore;
|
|
63
|
+
}
|
|
64
|
+
export declare function applyChecklistPatch(input: ApplyChecklistPatchInput): Promise<ChecklistPatchApplyResult>;
|
|
65
|
+
//# sourceMappingURL=patch-apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-apply.d.ts","sourceRoot":"","sources":["../../../src/core/checklist/pat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EAAE,2BAA2B,CAAC;CACpD;AAkDD,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAoM7G"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { ClosingChecklistSchema } from './schemas.js';
|
|
2
|
+
import { ChecklistPatchApplyRequestSchema } from './patch-schemas.js';
|
|
3
|
+
import { applyChecklistPatchOperations, computeChecklistPatchHash, getChecklistPatchValidationArtifact, getChecklistPatchValidationStore, } from './patch-validator.js';
|
|
4
|
+
class InMemoryChecklistAppliedPatchStore {
|
|
5
|
+
map = new Map();
|
|
6
|
+
key(checklistId, patchId) {
|
|
7
|
+
return `${checklistId}:${patchId}`;
|
|
8
|
+
}
|
|
9
|
+
async get(checklistId, patchId) {
|
|
10
|
+
return this.map.get(this.key(checklistId, patchId)) ?? null;
|
|
11
|
+
}
|
|
12
|
+
async set(record) {
|
|
13
|
+
this.map.set(this.key(record.checklist_id, record.patch_id), record);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class InMemoryChecklistProposedPatchStore {
|
|
17
|
+
map = new Map();
|
|
18
|
+
key(checklistId, patchId) {
|
|
19
|
+
return `${checklistId}:${patchId}`;
|
|
20
|
+
}
|
|
21
|
+
async get(checklistId, patchId) {
|
|
22
|
+
return this.map.get(this.key(checklistId, patchId)) ?? null;
|
|
23
|
+
}
|
|
24
|
+
async set(record) {
|
|
25
|
+
this.map.set(this.key(record.checklist_id, record.patch_id), record);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let appliedPatchStore = null;
|
|
29
|
+
let proposedPatchStore = null;
|
|
30
|
+
export function setChecklistAppliedPatchStore(store) {
|
|
31
|
+
appliedPatchStore = store;
|
|
32
|
+
}
|
|
33
|
+
export function getChecklistAppliedPatchStore() {
|
|
34
|
+
if (!appliedPatchStore) {
|
|
35
|
+
appliedPatchStore = new InMemoryChecklistAppliedPatchStore();
|
|
36
|
+
}
|
|
37
|
+
return appliedPatchStore;
|
|
38
|
+
}
|
|
39
|
+
export function setChecklistProposedPatchStore(store) {
|
|
40
|
+
proposedPatchStore = store;
|
|
41
|
+
}
|
|
42
|
+
export function getChecklistProposedPatchStore() {
|
|
43
|
+
if (!proposedPatchStore) {
|
|
44
|
+
proposedPatchStore = new InMemoryChecklistProposedPatchStore();
|
|
45
|
+
}
|
|
46
|
+
return proposedPatchStore;
|
|
47
|
+
}
|
|
48
|
+
function cloneValue(value) {
|
|
49
|
+
if (typeof structuredClone === 'function') {
|
|
50
|
+
return structuredClone(value);
|
|
51
|
+
}
|
|
52
|
+
return JSON.parse(JSON.stringify(value));
|
|
53
|
+
}
|
|
54
|
+
function issuePath(path) {
|
|
55
|
+
if (path.length === 0)
|
|
56
|
+
return '<root>';
|
|
57
|
+
return path
|
|
58
|
+
.map((segment) => (typeof segment === 'symbol' ? segment.toString() : String(segment)))
|
|
59
|
+
.join('.');
|
|
60
|
+
}
|
|
61
|
+
function parsedChecklistOrFailure(checklist) {
|
|
62
|
+
const parsed = ClosingChecklistSchema.safeParse(checklist);
|
|
63
|
+
if (parsed.success) {
|
|
64
|
+
return { ok: true, checklist: parsed.data };
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
error_code: 'CHECKLIST_SCHEMA_INVALID',
|
|
69
|
+
message: 'Checklist payload failed schema validation.',
|
|
70
|
+
diagnostics: parsed.error.issues.map((issue) => ({
|
|
71
|
+
code: 'CHECKLIST_SCHEMA_INVALID',
|
|
72
|
+
message: issue.message,
|
|
73
|
+
path: issuePath(issue.path),
|
|
74
|
+
})),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function parsedRequestOrFailure(request) {
|
|
78
|
+
const parsed = ChecklistPatchApplyRequestSchema.safeParse(request);
|
|
79
|
+
if (parsed.success) {
|
|
80
|
+
return { ok: true, request: parsed.data };
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
error_code: 'APPLY_REQUEST_SCHEMA_INVALID',
|
|
85
|
+
message: 'Patch apply request failed schema validation.',
|
|
86
|
+
diagnostics: parsed.error.issues.map((issue) => ({
|
|
87
|
+
code: 'PATCH_SCHEMA_INVALID',
|
|
88
|
+
message: issue.message,
|
|
89
|
+
path: issuePath(issue.path),
|
|
90
|
+
})),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export async function applyChecklistPatch(input) {
|
|
94
|
+
const checklistParsed = parsedChecklistOrFailure(input.checklist);
|
|
95
|
+
if (!checklistParsed.ok)
|
|
96
|
+
return checklistParsed;
|
|
97
|
+
const requestParsed = parsedRequestOrFailure(input.request);
|
|
98
|
+
if (!requestParsed.ok)
|
|
99
|
+
return requestParsed;
|
|
100
|
+
const request = requestParsed.request;
|
|
101
|
+
const mode = request.patch.mode;
|
|
102
|
+
const patchHash = computeChecklistPatchHash(request.patch);
|
|
103
|
+
const validationStore = input.validation_store ?? getChecklistPatchValidationStore();
|
|
104
|
+
const validationArtifact = await getChecklistPatchValidationArtifact(request.validation_id, {
|
|
105
|
+
now_ms: input.now_ms,
|
|
106
|
+
store: validationStore,
|
|
107
|
+
});
|
|
108
|
+
if (!validationArtifact) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
error_code: 'VALIDATION_REQUIRED',
|
|
112
|
+
message: 'Missing or expired validation_id. Re-run validate before apply.',
|
|
113
|
+
diagnostics: [],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (validationArtifact.checklist_id !== input.checklist_id) {
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
error_code: 'VALIDATION_MISMATCH',
|
|
120
|
+
message: 'validation_id does not belong to this checklist.',
|
|
121
|
+
diagnostics: [],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (validationArtifact.patch_hash !== patchHash) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
error_code: 'VALIDATION_MISMATCH',
|
|
128
|
+
message: 'Patch payload does not match the validated patch hash.',
|
|
129
|
+
diagnostics: [],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (validationArtifact.patch_id !== request.patch.patch_id) {
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
error_code: 'VALIDATION_MISMATCH',
|
|
136
|
+
message: 'Patch ID does not match the validated patch.',
|
|
137
|
+
diagnostics: [],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const appliedStore = input.applied_patch_store ?? getChecklistAppliedPatchStore();
|
|
141
|
+
const existing = await appliedStore.get(input.checklist_id, request.patch.patch_id);
|
|
142
|
+
if (existing) {
|
|
143
|
+
if (existing.patch_hash === patchHash) {
|
|
144
|
+
return {
|
|
145
|
+
ok: true,
|
|
146
|
+
checklist: checklistParsed.checklist,
|
|
147
|
+
previous_revision: input.current_revision,
|
|
148
|
+
new_revision: input.current_revision,
|
|
149
|
+
patch_id: request.patch.patch_id,
|
|
150
|
+
patch_hash: patchHash,
|
|
151
|
+
idempotent_replay: true,
|
|
152
|
+
mode,
|
|
153
|
+
applied: false,
|
|
154
|
+
resolved_operations: validationArtifact.resolved_operations,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
error_code: 'PATCH_ID_CONFLICT',
|
|
160
|
+
message: `patch_id "${request.patch.patch_id}" already exists with different payload hash.`,
|
|
161
|
+
diagnostics: [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (mode === 'PROPOSED') {
|
|
165
|
+
const proposedStore = input.proposed_patch_store ?? getChecklistProposedPatchStore();
|
|
166
|
+
const existingProposal = await proposedStore.get(input.checklist_id, request.patch.patch_id);
|
|
167
|
+
if (existingProposal) {
|
|
168
|
+
if (existingProposal.patch_hash === patchHash) {
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
checklist: checklistParsed.checklist,
|
|
172
|
+
previous_revision: input.current_revision,
|
|
173
|
+
new_revision: input.current_revision,
|
|
174
|
+
patch_id: request.patch.patch_id,
|
|
175
|
+
patch_hash: patchHash,
|
|
176
|
+
idempotent_replay: true,
|
|
177
|
+
mode,
|
|
178
|
+
applied: false,
|
|
179
|
+
resolved_operations: validationArtifact.resolved_operations,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
ok: false,
|
|
184
|
+
error_code: 'PATCH_ID_CONFLICT',
|
|
185
|
+
message: `patch_id "${request.patch.patch_id}" already exists with different payload hash.`,
|
|
186
|
+
diagnostics: [],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const proposedAt = input.now_ms ?? Date.now();
|
|
190
|
+
await proposedStore.set({
|
|
191
|
+
checklist_id: input.checklist_id,
|
|
192
|
+
patch_id: request.patch.patch_id,
|
|
193
|
+
patch_hash: patchHash,
|
|
194
|
+
proposed_at_ms: proposedAt,
|
|
195
|
+
expected_revision: request.patch.expected_revision,
|
|
196
|
+
validation_id: request.validation_id,
|
|
197
|
+
resolved_operations: validationArtifact.resolved_operations,
|
|
198
|
+
});
|
|
199
|
+
return {
|
|
200
|
+
ok: true,
|
|
201
|
+
checklist: checklistParsed.checklist,
|
|
202
|
+
previous_revision: input.current_revision,
|
|
203
|
+
new_revision: input.current_revision,
|
|
204
|
+
patch_id: request.patch.patch_id,
|
|
205
|
+
patch_hash: patchHash,
|
|
206
|
+
idempotent_replay: false,
|
|
207
|
+
mode,
|
|
208
|
+
applied: false,
|
|
209
|
+
resolved_operations: validationArtifact.resolved_operations,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (request.patch.expected_revision !== input.current_revision) {
|
|
213
|
+
return {
|
|
214
|
+
ok: false,
|
|
215
|
+
error_code: 'REVISION_CONFLICT',
|
|
216
|
+
message: `expected_revision ${request.patch.expected_revision} does not match current revision ${input.current_revision}.`,
|
|
217
|
+
diagnostics: [],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (validationArtifact.expected_revision !== input.current_revision) {
|
|
221
|
+
return {
|
|
222
|
+
ok: false,
|
|
223
|
+
error_code: 'REVISION_CONFLICT',
|
|
224
|
+
message: `Validated revision ${validationArtifact.expected_revision} does not match current revision ${input.current_revision}.`,
|
|
225
|
+
diagnostics: [],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const updatedChecklist = cloneValue(checklistParsed.checklist);
|
|
229
|
+
const applyResult = applyChecklistPatchOperations(updatedChecklist, request.patch.operations);
|
|
230
|
+
if (!applyResult.ok) {
|
|
231
|
+
return {
|
|
232
|
+
ok: false,
|
|
233
|
+
error_code: 'APPLY_OPERATION_FAILED',
|
|
234
|
+
message: 'Patch operation failed during apply.',
|
|
235
|
+
diagnostics: [applyResult.diagnostic],
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const postPatch = ClosingChecklistSchema.safeParse(updatedChecklist);
|
|
239
|
+
if (!postPatch.success) {
|
|
240
|
+
return {
|
|
241
|
+
ok: false,
|
|
242
|
+
error_code: 'POST_PATCH_SCHEMA_INVALID',
|
|
243
|
+
message: 'Patched checklist failed schema validation.',
|
|
244
|
+
diagnostics: postPatch.error.issues.map((issue) => ({
|
|
245
|
+
code: 'POST_PATCH_SCHEMA_INVALID',
|
|
246
|
+
message: issue.message,
|
|
247
|
+
path: issuePath(issue.path),
|
|
248
|
+
})),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const appliedAt = input.now_ms ?? Date.now();
|
|
252
|
+
await appliedStore.set({
|
|
253
|
+
checklist_id: input.checklist_id,
|
|
254
|
+
patch_id: request.patch.patch_id,
|
|
255
|
+
patch_hash: patchHash,
|
|
256
|
+
applied_at_ms: appliedAt,
|
|
257
|
+
revision_before: input.current_revision,
|
|
258
|
+
revision_after: input.current_revision + 1,
|
|
259
|
+
patch: request.patch,
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
ok: true,
|
|
263
|
+
checklist: postPatch.data,
|
|
264
|
+
previous_revision: input.current_revision,
|
|
265
|
+
new_revision: input.current_revision + 1,
|
|
266
|
+
patch_id: request.patch.patch_id,
|
|
267
|
+
patch_hash: patchHash,
|
|
268
|
+
idempotent_replay: false,
|
|
269
|
+
mode,
|
|
270
|
+
applied: true,
|
|
271
|
+
resolved_operations: applyResult.resolved_operations,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=patch-apply.js.map
|