weaver-work-cli 0.1.1 → 0.1.4
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 +187 -76
- package/dist/cmd/setup/index.js +5 -5
- package/dist/cmd/skills/index.js +1 -1
- package/dist/core/hooks.js +7 -0
- package/dist/index.js +0 -0
- package/dist/internal/e10/auth/commands.js +160 -55
- package/dist/internal/e10/auth/crypto.js +7 -22
- package/dist/internal/e10/auth/session.js +1 -1
- package/dist/internal/e10/auth/xiaoe.js +268 -0
- package/dist/internal/e10/context.js +16 -2
- package/dist/internal/e10/index.js +1 -0
- package/dist/internal/e10/request-runtime.js +344 -0
- package/dist/internal/skills/install.js +48 -6
- package/dist/internal/skills/reader.js +27 -0
- package/dist/shortcuts/archive/continuation.js +70 -0
- package/dist/shortcuts/archive/errors.js +53 -0
- package/dist/shortcuts/archive/host.js +197 -0
- package/dist/shortcuts/archive/index.js +363 -0
- package/dist/shortcuts/archive/manifest.js +45 -0
- package/dist/shortcuts/archive/operations/archive-info.js +55 -0
- package/dist/shortcuts/archive/operations/borrow-car.js +146 -0
- package/dist/shortcuts/archive/operations/borrow-list.js +200 -0
- package/dist/shortcuts/archive/operations/confirm.js +46 -0
- package/dist/shortcuts/archive/operations/download.js +238 -0
- package/dist/shortcuts/archive/operations/flow-url.js +240 -0
- package/dist/shortcuts/archive/operations/fonds.js +95 -0
- package/dist/shortcuts/archive/operations/getPageUrl.js +137 -0
- package/dist/shortcuts/archive/operations/registry.js +43 -0
- package/dist/shortcuts/archive/operations/search.js +88 -0
- package/dist/shortcuts/archive/operations/shared.js +120 -0
- package/dist/shortcuts/archive/operations/types.js +23 -0
- package/dist/shortcuts/archive/operations/upload.js +182 -0
- package/dist/shortcuts/archive/operations.js +13 -0
- package/dist/shortcuts/archive/render/search-format.js +276 -0
- package/dist/shortcuts/archive/render/search-view.js +125 -0
- package/dist/shortcuts/asset/continuation.js +70 -0
- package/dist/shortcuts/asset/errors.js +67 -0
- package/dist/shortcuts/asset/host.js +438 -0
- package/dist/shortcuts/asset/index.js +255 -0
- package/dist/shortcuts/asset/manifest.js +471 -0
- package/dist/shortcuts/asset/operations/query.js +249 -0
- package/dist/shortcuts/asset/operations/registry.js +85 -0
- package/dist/shortcuts/asset/operations/shared.js +100 -0
- package/dist/shortcuts/asset/operations/type-cache.js +49 -0
- package/dist/shortcuts/asset/operations/types.js +1 -0
- package/dist/shortcuts/asset/operations/viewlink.js +117 -0
- package/dist/shortcuts/asset/operations/write.js +435 -0
- package/dist/shortcuts/asset/operations.js +9 -0
- package/dist/shortcuts/calendar/continuation.js +70 -0
- package/dist/shortcuts/calendar/errors.js +53 -0
- package/dist/shortcuts/calendar/host.js +148 -0
- package/dist/shortcuts/calendar/index.js +125 -0
- package/dist/shortcuts/calendar/manifest.js +26 -0
- package/dist/shortcuts/calendar/operations/read.js +259 -0
- package/dist/shortcuts/calendar/operations/registry.js +31 -0
- package/dist/shortcuts/calendar/operations/shared.js +132 -0
- package/dist/shortcuts/calendar/operations/types.js +25 -0
- package/dist/shortcuts/calendar/operations/write.js +439 -0
- package/dist/shortcuts/calendar/operations.js +8 -0
- package/dist/shortcuts/ehr/continuation.js +70 -0
- package/dist/shortcuts/ehr/errors.js +53 -0
- package/dist/shortcuts/ehr/host.js +213 -0
- package/dist/shortcuts/ehr/index.js +205 -0
- package/dist/shortcuts/ehr/manifest.js +47 -0
- package/dist/shortcuts/ehr/operations/attend-read.js +373 -0
- package/dist/shortcuts/ehr/operations/attend-write.js +514 -0
- package/dist/shortcuts/ehr/operations/hr-contact.js +363 -0
- package/dist/shortcuts/ehr/operations/hr-ds.js +298 -0
- package/dist/shortcuts/ehr/operations/hr-report.js +386 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +1629 -0
- package/dist/shortcuts/ehr/operations/recruit.js +803 -0
- package/dist/shortcuts/ehr/operations/registry.js +43 -0
- package/dist/shortcuts/ehr/operations/salary.js +319 -0
- package/dist/shortcuts/ehr/operations/shared.js +246 -0
- package/dist/shortcuts/ehr/operations/types.js +25 -0
- package/dist/shortcuts/ehr/operations.js +25 -0
- package/dist/shortcuts/esb/continuation.js +70 -0
- package/dist/shortcuts/esb/errors.js +65 -0
- package/dist/shortcuts/esb/host.js +187 -0
- package/dist/shortcuts/esb/index.js +112 -0
- package/dist/shortcuts/esb/manifest.js +91 -0
- package/dist/shortcuts/esb/operations/input-format.js +31 -0
- package/dist/shortcuts/esb/operations/registry.js +48 -0
- package/dist/shortcuts/esb/operations/shared.js +152 -0
- package/dist/shortcuts/esb/operations/trigger.js +76 -0
- package/dist/shortcuts/esb/operations/types.js +21 -0
- package/dist/shortcuts/esb/operations.js +15 -0
- package/dist/shortcuts/fna/continuation.js +70 -0
- package/dist/shortcuts/fna/errors.js +59 -0
- package/dist/shortcuts/fna/host.js +146 -0
- package/dist/shortcuts/fna/index.js +111 -0
- package/dist/shortcuts/fna/manifest.js +41 -0
- package/dist/shortcuts/fna/operations/budget.js +124 -0
- package/dist/shortcuts/fna/operations/expense-center.js +148 -0
- package/dist/shortcuts/fna/operations/invoice-writeoff.js +212 -0
- package/dist/shortcuts/fna/operations/loan.js +195 -0
- package/dist/shortcuts/fna/operations/registry.js +35 -0
- package/dist/shortcuts/fna/operations/shared.js +210 -0
- package/dist/shortcuts/fna/operations/types.js +25 -0
- package/dist/shortcuts/fna/operations.js +19 -0
- package/dist/shortcuts/hrm/errors.js +38 -0
- package/dist/shortcuts/hrm/host.js +156 -0
- package/dist/shortcuts/hrm/index.js +111 -0
- package/dist/shortcuts/hrm/manifest.js +32 -0
- package/dist/shortcuts/hrm/operations/employee.js +338 -0
- package/dist/shortcuts/hrm/operations/org.js +110 -0
- package/dist/shortcuts/hrm/operations/position.js +176 -0
- package/dist/shortcuts/hrm/operations/registry.js +33 -0
- package/dist/shortcuts/hrm/operations/shared.js +143 -0
- package/dist/shortcuts/hrm/operations/types.js +23 -0
- package/dist/shortcuts/hrm/operations.js +19 -0
- package/dist/shortcuts/index.js +20 -0
- package/dist/shortcuts/invoice/host.js +99 -94
- package/dist/shortcuts/invoice/index.js +65 -61
- package/dist/shortcuts/invoice/manifest.js +222 -14
- package/dist/shortcuts/invoice/operations/browse-field.js +17 -0
- package/dist/shortcuts/invoice/operations/issuing.js +198 -0
- package/dist/shortcuts/invoice/operations/ocr-preview.js +6 -3
- package/dist/shortcuts/invoice/operations/registry.js +17 -0
- package/dist/shortcuts/invoice/operations/reim.js +401 -0
- package/dist/shortcuts/invoice/operations/shared.js +271 -6
- package/dist/shortcuts/invoice/operations/validate-preview.js +1 -1
- package/dist/shortcuts/jiuchuanhui/cache.js +441 -0
- package/dist/shortcuts/jiuchuanhui/continuation.js +70 -0
- package/dist/shortcuts/jiuchuanhui/errors.js +59 -0
- package/dist/shortcuts/jiuchuanhui/host.js +159 -0
- package/dist/shortcuts/jiuchuanhui/index.js +109 -0
- package/dist/shortcuts/jiuchuanhui/manifest.js +469 -0
- package/dist/shortcuts/jiuchuanhui/operations/datajson.js +214 -0
- package/dist/shortcuts/jiuchuanhui/operations/esb.js +157 -0
- package/dist/shortcuts/jiuchuanhui/operations/generic.js +146 -0
- package/dist/shortcuts/jiuchuanhui/operations/registry.js +133 -0
- package/dist/shortcuts/jiuchuanhui/operations/shared.js +158 -0
- package/dist/shortcuts/jiuchuanhui/operations/types.js +1 -0
- package/dist/shortcuts/jiuchuanhui/operations.js +8 -0
- package/dist/shortcuts/mail/continuation.js +70 -0
- package/dist/shortcuts/mail/errors.js +53 -0
- package/dist/shortcuts/mail/host.js +182 -0
- package/dist/shortcuts/mail/index.js +519 -0
- package/dist/shortcuts/mail/manifest.js +38 -0
- package/dist/shortcuts/mail/operations/mail-blacklist.js +79 -0
- package/dist/shortcuts/mail/operations/mail-contacts.js +195 -0
- package/dist/shortcuts/mail/operations/mail-manage.js +335 -0
- package/dist/shortcuts/mail/operations/mail-read.js +508 -0
- package/dist/shortcuts/mail/operations/mail-send.js +474 -0
- package/dist/shortcuts/mail/operations/mail-sign.js +203 -0
- package/dist/shortcuts/mail/operations/mail-template.js +170 -0
- package/dist/shortcuts/mail/operations/registry.js +41 -0
- package/dist/shortcuts/mail/operations/shared.js +64 -0
- package/dist/shortcuts/mail/operations/types.js +27 -0
- package/dist/shortcuts/mail/operations.js +19 -0
- package/dist/shortcuts/plan/continuation.js +70 -0
- package/dist/shortcuts/plan/errors.js +70 -0
- package/dist/shortcuts/plan/host.js +180 -0
- package/dist/shortcuts/plan/index.js +150 -0
- package/dist/shortcuts/plan/manifest.js +53 -0
- package/dist/shortcuts/plan/operations/link.js +256 -0
- package/dist/shortcuts/plan/operations/read.js +259 -0
- package/dist/shortcuts/plan/operations/registry.js +33 -0
- package/dist/shortcuts/plan/operations/shared.js +246 -0
- package/dist/shortcuts/plan/operations/types.js +49 -0
- package/dist/shortcuts/plan/operations/version.js +49 -0
- package/dist/shortcuts/plan/operations/write.js +710 -0
- package/dist/shortcuts/plan/operations.js +8 -0
- package/docs/SKILL.md +11 -7
- package/docs/_catalog.md +23 -5
- package/docs/agent-invoice.md +31 -10
- package/docs/agent-skill-install.md +211 -0
- package/docs/calendar.md +87 -0
- package/docs/e10-auth.md +28 -9
- package/docs/ehr.md +186 -0
- package/docs/esb.md +64 -0
- package/docs/fna.md +72 -0
- package/docs/hrm.md +89 -0
- package/docs/invoice.md +66 -20
- package/docs/jiuchuanhui.md +131 -0
- package/docs/operation-manual.md +443 -0
- package/docs/plan.md +82 -0
- package/docs/wenshuding.md +129 -0
- package/docs/ziguanjia.md +89 -0
- package/package.json +4 -4
- package/scripts/package-skill.mjs +127 -34
- package/scripts/postbuild.mjs +13 -0
- package/skill-template/business-info.json +13 -2
- package/skill-template/domains/calendar.md +15 -0
- package/skill-template/domains/esb.md +13 -0
- package/skill-template/domains/hrm.md +16 -0
- package/skill-template/domains/jiuchuanhui.md +23 -0
- package/skill-template/domains/jucailin.md +22 -0
- package/skill-template/domains/mail.md +21 -0
- package/skill-template/domains/plan.md +17 -0
- package/skill-template/domains/qiyecheng.md +17 -0
- package/skill-template/domains/shared.md +9 -3
- package/skill-template/domains/skill-maker.md +10 -0
- package/skill-template/domains/wenshuding.md +22 -0
- package/skill-template/domains/{invoice.md → yepiaotong.md} +4 -0
- package/skill-template/domains/ziguanjia.md +21 -0
- package/skill-template/master-skill-template.md +12 -6
- package/skill-template/skill-template.md +40 -9
- package/skills/weaver-e10-calendar/SKILL.md +101 -0
- package/skills/weaver-e10-calendar/product.json +8 -0
- package/skills/weaver-e10-calendar/references/calendar-app-check.md +65 -0
- package/skills/weaver-e10-calendar/references/calendar-dict.md +55 -0
- package/skills/weaver-e10-calendar/references/calendar-query.md +70 -0
- package/skills/weaver-e10-calendar/references/calendar-write.md +97 -0
- package/skills/weaver-e10-calendar/references/source-manifest.json +54 -0
- package/skills/weaver-e10-esb/SKILL.md +102 -0
- package/skills/weaver-e10-esb/product.json +8 -0
- package/skills/weaver-e10-esb/references/input-format.md +52 -0
- package/skills/weaver-e10-esb/references/source-manifest.json +242 -0
- package/skills/weaver-e10-esb/references/trigger.md +99 -0
- package/skills/weaver-e10-hrm/SKILL.md +87 -0
- package/skills/weaver-e10-hrm/product.json +8 -0
- package/skills/weaver-e10-hrm/references/employee.md +109 -0
- package/skills/weaver-e10-hrm/references/org.md +95 -0
- package/skills/weaver-e10-hrm/references/position.md +95 -0
- package/skills/weaver-e10-hrm/references/source-manifest.json +121 -0
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +174 -0
- package/skills/weaver-e10-jiuchuanhui/product.json +8 -0
- package/skills/weaver-e10-jiuchuanhui/references/cache.md +110 -0
- package/skills/weaver-e10-jiuchuanhui/references/clue.md +61 -0
- package/skills/weaver-e10-jiuchuanhui/references/contact-plan.md +56 -0
- package/skills/weaver-e10-jiuchuanhui/references/contact-records.md +48 -0
- package/skills/weaver-e10-jiuchuanhui/references/contact.md +56 -0
- package/skills/weaver-e10-jiuchuanhui/references/customer.md +69 -0
- package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +24 -0
- package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +60 -0
- package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +59 -0
- package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +60 -0
- package/skills/weaver-e10-jiuchuanhui/references/sale.md +72 -0
- package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +2632 -0
- package/skills/weaver-e10-jucailin/SKILL.md +101 -0
- package/skills/weaver-e10-jucailin/product.json +8 -0
- package/skills/weaver-e10-jucailin/references/attend-read.md +73 -0
- package/skills/weaver-e10-jucailin/references/attend-write.md +82 -0
- package/skills/weaver-e10-jucailin/references/hr-contact.md +92 -0
- package/skills/weaver-e10-jucailin/references/hr-datasource.md +104 -0
- package/skills/weaver-e10-jucailin/references/hr-report.md +76 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +76 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +70 -0
- package/skills/weaver-e10-jucailin/references/safety-boundaries.md +35 -0
- package/skills/weaver-e10-jucailin/references/salary.md +110 -0
- package/skills/weaver-e10-jucailin/references/source-manifest.json +152 -0
- package/skills/weaver-e10-mail/SKILL.md +151 -0
- package/skills/weaver-e10-mail/product.json +8 -0
- package/skills/weaver-e10-mail/references/mail-agent-entry.md +47 -0
- package/skills/weaver-e10-mail/references/mail-attachment.md +30 -0
- package/skills/weaver-e10-mail/references/mail-blacklist.md +27 -0
- package/skills/weaver-e10-mail/references/mail-contacts.md +33 -0
- package/skills/weaver-e10-mail/references/mail-manage.md +44 -0
- package/skills/weaver-e10-mail/references/mail-read.md +76 -0
- package/skills/weaver-e10-mail/references/mail-send.md +43 -0
- package/skills/weaver-e10-mail/references/mail-sign.md +33 -0
- package/skills/weaver-e10-mail/references/mail-template.md +31 -0
- package/skills/weaver-e10-mail/references/safety-boundaries.md +32 -0
- package/skills/weaver-e10-plan/SKILL.md +139 -0
- package/skills/weaver-e10-plan/product.json +8 -0
- package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +123 -0
- package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +138 -0
- package/skills/weaver-e10-plan/references/plan-report-query.md +154 -0
- package/skills/weaver-e10-plan/references/plan-report-remind.md +104 -0
- package/skills/weaver-e10-plan/references/plan-report-write.md +162 -0
- package/skills/weaver-e10-plan/references/source-manifest.json +858 -0
- package/skills/weaver-e10-qiyecheng/SKILL.md +118 -0
- package/skills/weaver-e10-qiyecheng/product.json +8 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +65 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +56 -0
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +51 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +57 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +59 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +698 -0
- package/skills/weaver-e10-shared/SKILL.md +86 -0
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +127 -0
- package/skills/weaver-e10-shared/references/json-output-contract.md +120 -0
- package/skills/weaver-e10-shared/references/weaver-e10-installation.md +110 -0
- package/skills/weaver-e10-skill-maker/SKILL.md +77 -0
- package/skills/weaver-e10-skill-maker/product.json +8 -0
- package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +124 -0
- package/skills/weaver-e10-skill-maker/references/detector-validation.md +101 -0
- package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +230 -0
- package/skills/weaver-e10-skill-maker/references/post-generation-install.md +105 -0
- package/skills/weaver-e10-skill-maker/references/source-update-detection.md +261 -0
- package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +141 -0
- package/skills/weaver-e10-wenshuding/SKILL.md +157 -0
- package/skills/weaver-e10-wenshuding/product.json +8 -0
- package/skills/weaver-e10-wenshuding/references/archive-agent-entry.md +63 -0
- package/skills/weaver-e10-wenshuding/references/archive-borrow-car.md +52 -0
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +52 -0
- package/skills/weaver-e10-wenshuding/references/archive-disabled-capabilities.md +22 -0
- package/skills/weaver-e10-wenshuding/references/archive-download.md +48 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +46 -0
- package/skills/weaver-e10-wenshuding/references/archive-fonds.md +34 -0
- package/skills/weaver-e10-wenshuding/references/archive-info.md +33 -0
- package/skills/weaver-e10-wenshuding/references/archive-search.md +52 -0
- package/skills/weaver-e10-wenshuding/references/archive-upload.md +41 -0
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +517 -0
- package/skills/weaver-e10-yepiaotong/SKILL.md +184 -0
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-add.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +47 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +204 -0
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-delete.md +1 -1
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-detail.md +13 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +28 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-download.md +31 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +45 -0
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-file-upload.md +15 -4
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +45 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +120 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-field-rules.md +161 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +99 -0
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-ocr-preview.md +14 -4
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +58 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-red.md +261 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +97 -0
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-update.md +1 -1
- package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-validation-preview.md +10 -3
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +1340 -0
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +845 -0
- package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +94 -0
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +449 -0
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +266 -0
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +494 -0
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1103 -0
- package/skills/weaver-e10-ziguanjia/SKILL.md +162 -0
- package/skills/weaver-e10-ziguanjia/product.json +8 -0
- package/skills/weaver-e10-ziguanjia/references/source-manifest.json +147 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +65 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-create.md +45 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-depre.md +48 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-disabled-capabilities.md +22 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-purch.md +57 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-query.md +62 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-repair.md +83 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-resolve.md +49 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-return.md +70 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-update.md +45 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-use.md +60 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-viewlink.md +81 -0
- package/skills/weaver-work-cli-invoice/SKILL.md +0 -103
- package/skills/weaver-work-cli-invoice/references/invoice-agent-entry.md +0 -38
- package/skills/weaver-work-cli-invoice/references/invoice-disabled-capabilities.md +0 -26
- package/skills/weaver-work-cli-invoice/references/invoice-download.md +0 -22
- package/skills/weaver-work-cli-invoice/references/invoice-enterprise-list.md +0 -35
- package/skills/weaver-work-cli-invoice/references/invoice-import.md +0 -28
- package/skills/weaver-work-cli-invoice/references/invoice-personal-list.md +0 -47
- package/skills/weaver-work-cli-shared/SKILL.md +0 -53
- package/skills/weaver-work-cli-shared/references/e10-auth-and-session.md +0 -83
- package/skills/weaver-work-cli-shared/references/json-output-contract.md +0 -61
- package/skills/weaver-work-cli-shared/references/weaver-work-cli-installation.md +0 -61
- /package/skills/{weaver-work-cli-shared → weaver-e10-shared}/references/high-risk-write.md +0 -0
- /package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/product.json +0 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { assertNoForbiddenKeys } from '../host.js';
|
|
2
|
+
import { ziguanjiaFixed } from '../manifest.js';
|
|
3
|
+
import { ziguanjiaValidationError } from '../errors.js';
|
|
4
|
+
import { asObject, actionFlowResult, ensureVersionGate, getDatas, mainTableOf, ok } from './shared.js';
|
|
5
|
+
const EB = ziguanjiaFixed.EB_INTERFACE_PK;
|
|
6
|
+
const ES = ziguanjiaFixed.ES_UNIQUE_INDENT;
|
|
7
|
+
function todayStr() {
|
|
8
|
+
const d = new Date();
|
|
9
|
+
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
10
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
11
|
+
return `${d.getFullYear()}-${m}-${day}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 写操作统一采用 prepare / apply 两阶段:
|
|
15
|
+
* - 第一阶段(无 confirm / 无 continuation):执行版本门禁与只读校验,返回带签名的 continuation 与操作预览,不落地任何写操作。
|
|
16
|
+
* - 第二阶段(confirm:true 且携带合法 continuation):校验签名后执行真实写操作。
|
|
17
|
+
*/
|
|
18
|
+
export class ZiguanjiaPreparedWriteOperation {
|
|
19
|
+
name;
|
|
20
|
+
constructor(name) {
|
|
21
|
+
this.name = name;
|
|
22
|
+
}
|
|
23
|
+
async execute(input, context) {
|
|
24
|
+
const body = asObject(input, this.name);
|
|
25
|
+
await ensureVersionGate(context.host, this.name);
|
|
26
|
+
if (body.confirm !== true || typeof body.continuation !== 'string' || body.continuation === '') {
|
|
27
|
+
const prepared = await this.prepare(body, context);
|
|
28
|
+
const token = await context.continuation.issue({ operation: this.name, ...prepared.commit });
|
|
29
|
+
return ok('NEED_CONFIRM', {
|
|
30
|
+
operation: this.name,
|
|
31
|
+
confirmation: prepared.confirmationText
|
|
32
|
+
|| `即将执行 ${this.name},请确认预览无误后,携带本 continuation 并设置 confirm:true 重新执行。`,
|
|
33
|
+
continuation: token,
|
|
34
|
+
preview: prepared.preview,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const verified = await context.continuation.verify(String(body.continuation), this.name);
|
|
38
|
+
const result = await this.apply(verified, context);
|
|
39
|
+
return ok('COMPLETE', result);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function resolveAssetId(host, interfacePk, filters, operation) {
|
|
43
|
+
const result = await host.ebuilderRequest({
|
|
44
|
+
endpoint: 'getFormDataList',
|
|
45
|
+
interfacePk,
|
|
46
|
+
operation,
|
|
47
|
+
body: { mainTable: filters, pageInfo: { pageNo: '1', pageSize: '10' } },
|
|
48
|
+
});
|
|
49
|
+
const datas = getDatas(result).map(mainTableOf);
|
|
50
|
+
if (datas.length === 0) {
|
|
51
|
+
throw ziguanjiaValidationError('resolve_not_found', `未找到匹配的资产(${JSON.stringify(filters)})`);
|
|
52
|
+
}
|
|
53
|
+
if (datas.length > 1) {
|
|
54
|
+
throw ziguanjiaValidationError('resolve_ambiguous', '匹配到多条资产,请改用 id 明确指定', {
|
|
55
|
+
candidates: datas.slice(0, 10).map((d) => d.id ?? d.mainTable?.id),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const id = datas[0].id ?? datas[0].mainTable?.id;
|
|
59
|
+
if (id === undefined || id === null || String(id).trim() === '') {
|
|
60
|
+
throw ziguanjiaValidationError('resolve_missing_id', '匹配到资产但缺少可引用 ID');
|
|
61
|
+
}
|
|
62
|
+
return String(id);
|
|
63
|
+
}
|
|
64
|
+
const OPERATIONINFO = { printCost: false, asyncPostProcess: false, asyncMark: false };
|
|
65
|
+
export class ZiguanjiaCreateOperation extends ZiguanjiaPreparedWriteOperation {
|
|
66
|
+
constructor() {
|
|
67
|
+
super('asset.create');
|
|
68
|
+
}
|
|
69
|
+
async prepare(body, context) {
|
|
70
|
+
const assetName = typeof body.asset_name === 'string' ? body.asset_name : '';
|
|
71
|
+
const assetType = typeof body.asset_type_browse === 'string' ? body.asset_type_browse : '';
|
|
72
|
+
if (assetName.trim() === '')
|
|
73
|
+
throw ziguanjiaValidationError('input_required', 'asset_name 必填');
|
|
74
|
+
if (assetType.trim() === '')
|
|
75
|
+
throw ziguanjiaValidationError('input_required', 'asset_type_browse 必填(资产类型 ID,经 asset.resolve.type 解析)');
|
|
76
|
+
const session = await context.host.getSession();
|
|
77
|
+
const mainTable = {
|
|
78
|
+
asset_name: assetName,
|
|
79
|
+
asset_type_browse: assetType,
|
|
80
|
+
asset_data_attr: typeof body.asset_data_attr === 'string' ? body.asset_data_attr : '0',
|
|
81
|
+
admin_istrator: typeof body.admin_istrator === 'string' && body.admin_istrator !== '' ? body.admin_istrator : session.userId,
|
|
82
|
+
};
|
|
83
|
+
if (typeof body.asset_spec === 'string' && body.asset_spec !== '')
|
|
84
|
+
mainTable.asset_spec = body.asset_spec;
|
|
85
|
+
mainTable.stockindate = typeof body.stockindate === 'string' && body.stockindate !== '' ? body.stockindate : todayStr();
|
|
86
|
+
if (typeof body.startprice === 'string' && body.startprice !== '')
|
|
87
|
+
mainTable.startprice = body.startprice;
|
|
88
|
+
if (typeof body.original_value === 'string' && body.original_value !== '')
|
|
89
|
+
mainTable.original_value = body.original_value;
|
|
90
|
+
if (typeof body.image_id === 'string' && body.image_id !== '')
|
|
91
|
+
mainTable.image_id = body.image_id;
|
|
92
|
+
if (typeof body.blongdepartment === 'string' && body.blongdepartment !== '')
|
|
93
|
+
mainTable.blongdepartment = body.blongdepartment;
|
|
94
|
+
if (typeof body.resourceid === 'string' && body.resourceid !== '')
|
|
95
|
+
mainTable.resourceid = body.resourceid;
|
|
96
|
+
if (typeof body.stateid === 'string' && body.stateid !== '')
|
|
97
|
+
mainTable.stateid = body.stateid;
|
|
98
|
+
return {
|
|
99
|
+
preview: { operation: 'create', interfacePk: EB.create, mainTable },
|
|
100
|
+
confirmationText: `即将在 E10 资产库新增资产「${assetName}」(类型 ${assetType})。确认后执行。`,
|
|
101
|
+
commit: { endpoint: 'saveFormData', interfacePk: EB.create, mainTable },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async apply(commit, context) {
|
|
105
|
+
const result = await context.host.ebuilderRequest({
|
|
106
|
+
endpoint: 'saveFormData',
|
|
107
|
+
interfacePk: String(commit.interfacePk),
|
|
108
|
+
operation: this.name,
|
|
109
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable: commit.mainTable }] },
|
|
110
|
+
});
|
|
111
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
112
|
+
return { dataIds, count: Array.isArray(dataIds) ? dataIds.length : 0, mainTable: commit.mainTable };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class ZiguanjiaUpdateOperation extends ZiguanjiaPreparedWriteOperation {
|
|
116
|
+
constructor() {
|
|
117
|
+
super('asset.update');
|
|
118
|
+
}
|
|
119
|
+
async prepare(body, context) {
|
|
120
|
+
const changes = body.changes;
|
|
121
|
+
if (!changes || typeof changes !== 'object' || Array.isArray(changes) || Object.keys(changes).length === 0) {
|
|
122
|
+
throw ziguanjiaValidationError('input_required', 'changes 必填且至少包含一个字段');
|
|
123
|
+
}
|
|
124
|
+
let id = typeof body.id === 'string' && body.id !== '' ? body.id : undefined;
|
|
125
|
+
if (!id) {
|
|
126
|
+
const filters = {};
|
|
127
|
+
if (typeof body.asset_number === 'string' && body.asset_number !== '')
|
|
128
|
+
filters.asset_number = body.asset_number;
|
|
129
|
+
if (typeof body.asset_name === 'string' && body.asset_name !== '')
|
|
130
|
+
filters.asset_name = body.asset_name;
|
|
131
|
+
if (Object.keys(filters).length === 0) {
|
|
132
|
+
throw ziguanjiaValidationError('input_required', '需提供 id,或 asset_number / asset_name 用于定位资产');
|
|
133
|
+
}
|
|
134
|
+
id = await resolveAssetId(context.host, EB.baseDetail, filters, this.name);
|
|
135
|
+
}
|
|
136
|
+
const mainTable = { id, ...changes };
|
|
137
|
+
return {
|
|
138
|
+
preview: { operation: 'update', id, changes, interfacePk: EB.update },
|
|
139
|
+
confirmationText: `即将修改资产 ${id} 的字段:${Object.keys(changes).join(', ')}。确认后执行。`,
|
|
140
|
+
commit: { endpoint: 'updateFormData', interfacePk: EB.update, mainTable },
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async apply(commit, context) {
|
|
144
|
+
const result = await context.host.ebuilderRequest({
|
|
145
|
+
endpoint: 'updateFormData',
|
|
146
|
+
interfacePk: String(commit.interfacePk),
|
|
147
|
+
operation: this.name,
|
|
148
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable: commit.mainTable }] },
|
|
149
|
+
});
|
|
150
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
151
|
+
return { dataIds, count: Array.isArray(dataIds) ? dataIds.length : 0, id: commit.mainTable.id };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export class ZiguanjiaUseOperation extends ZiguanjiaPreparedWriteOperation {
|
|
155
|
+
constructor() {
|
|
156
|
+
super('asset.use');
|
|
157
|
+
}
|
|
158
|
+
async prepare(body, _context) {
|
|
159
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
160
|
+
if (detail1.length === 0)
|
|
161
|
+
throw ziguanjiaValidationError('input_required', 'detail1 至少一条领用明细');
|
|
162
|
+
const mainTable = { detail1 };
|
|
163
|
+
if (typeof body.use_location === 'string' && body.use_location !== '')
|
|
164
|
+
mainTable.use_location = body.use_location;
|
|
165
|
+
if (typeof body.purpose === 'string' && body.purpose !== '')
|
|
166
|
+
mainTable.purpose = body.purpose;
|
|
167
|
+
return {
|
|
168
|
+
preview: { operation: 'use', uniqueIndent: ES.use, mainTable },
|
|
169
|
+
confirmationText: `即将提交资产领用(${detail1.length} 条明细)。确认后执行。`,
|
|
170
|
+
commit: { uniqueIndent: ES.use, mainTable },
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async apply(commit, context) {
|
|
174
|
+
const result = await context.host.actionFlow({
|
|
175
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
176
|
+
mainTable: commit.mainTable,
|
|
177
|
+
operation: this.name,
|
|
178
|
+
});
|
|
179
|
+
return actionFlowResult(result);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export class ZiguanjiaReturnQueryOperation {
|
|
183
|
+
name = 'asset.return.query';
|
|
184
|
+
async execute(input, context) {
|
|
185
|
+
const body = asObject(input, this.name);
|
|
186
|
+
assertNoForbiddenKeys(body);
|
|
187
|
+
const mainTable = {
|
|
188
|
+
return_type: typeof body.return_type === 'string' ? body.return_type : '',
|
|
189
|
+
detail1: Array.isArray(body.detail1) ? body.detail1 : [],
|
|
190
|
+
};
|
|
191
|
+
const result = await context.host.actionFlow({
|
|
192
|
+
uniqueIndent: ES.returnQuery,
|
|
193
|
+
mainTable,
|
|
194
|
+
operation: this.name,
|
|
195
|
+
});
|
|
196
|
+
return ok('COMPLETE', actionFlowResult(result));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export class ZiguanjiaReturnCreateOperation extends ZiguanjiaPreparedWriteOperation {
|
|
200
|
+
constructor() {
|
|
201
|
+
super('asset.return.create');
|
|
202
|
+
}
|
|
203
|
+
async prepare(body, _context) {
|
|
204
|
+
const dataIds = typeof body.data_ids === 'string' && body.data_ids.trim() !== '' ? body.data_ids : undefined;
|
|
205
|
+
if (!dataIds)
|
|
206
|
+
throw ziguanjiaValidationError('input_required', 'data_ids 必填(半角逗号拼接的确认资产数据 ID,来自 asset.return.query)');
|
|
207
|
+
const mainTable = { data_ids: dataIds };
|
|
208
|
+
return {
|
|
209
|
+
preview: { operation: 'return.create', uniqueIndent: ES.returnCreate, mainTable },
|
|
210
|
+
confirmationText: `即将归还资产数据 ID:${dataIds}。确认后执行。`,
|
|
211
|
+
commit: { uniqueIndent: ES.returnCreate, mainTable },
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async apply(commit, context) {
|
|
215
|
+
const result = await context.host.actionFlow({
|
|
216
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
217
|
+
mainTable: commit.mainTable,
|
|
218
|
+
operation: this.name,
|
|
219
|
+
});
|
|
220
|
+
// 必须透传 mainTable:其中 lcID 是归还单「查看详情」链接(scene=asset_return)的 dataID,ghbh 是归还编号。
|
|
221
|
+
return actionFlowResult(result);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export class ZiguanjiaRepairQueryOperation {
|
|
225
|
+
name = 'asset.repair.query';
|
|
226
|
+
async execute(input, context) {
|
|
227
|
+
const body = asObject(input, this.name);
|
|
228
|
+
assertNoForbiddenKeys(body);
|
|
229
|
+
const mainTable = { detail1: Array.isArray(body.detail1) ? body.detail1 : [] };
|
|
230
|
+
const result = await context.host.actionFlow({
|
|
231
|
+
uniqueIndent: ES.repairQuery,
|
|
232
|
+
mainTable,
|
|
233
|
+
operation: this.name,
|
|
234
|
+
});
|
|
235
|
+
return ok('COMPLETE', actionFlowResult(result));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
export class ZiguanjiaRepairCreateOperation extends ZiguanjiaPreparedWriteOperation {
|
|
239
|
+
constructor() {
|
|
240
|
+
super('asset.repair.create');
|
|
241
|
+
}
|
|
242
|
+
async prepare(body, _context) {
|
|
243
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
244
|
+
if (detail1.length === 0)
|
|
245
|
+
throw ziguanjiaValidationError('input_required', 'detail1 至少一条报修明细');
|
|
246
|
+
const mainTable = { detail1 };
|
|
247
|
+
if (typeof body.repail_name === 'string' && body.repail_name !== '')
|
|
248
|
+
mainTable.repail_name = body.repail_name;
|
|
249
|
+
if (typeof body.repail_remark === 'string' && body.repail_remark !== '')
|
|
250
|
+
mainTable.repail_remark = body.repail_remark;
|
|
251
|
+
return {
|
|
252
|
+
preview: { operation: 'repair.create', uniqueIndent: ES.repairCreate, mainTable },
|
|
253
|
+
confirmationText: `即将提交资产报修(${detail1.length} 条明细)。确认后执行。`,
|
|
254
|
+
commit: { uniqueIndent: ES.repairCreate, mainTable },
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
async apply(commit, context) {
|
|
258
|
+
const result = await context.host.actionFlow({
|
|
259
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
260
|
+
mainTable: commit.mainTable,
|
|
261
|
+
operation: this.name,
|
|
262
|
+
});
|
|
263
|
+
return actionFlowResult(result);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export class ZiguanjiaPurchOperation extends ZiguanjiaPreparedWriteOperation {
|
|
267
|
+
constructor() {
|
|
268
|
+
super('asset.purch');
|
|
269
|
+
}
|
|
270
|
+
async prepare(body, _context) {
|
|
271
|
+
const detail1 = Array.isArray(body.detail1) ? body.detail1 : [];
|
|
272
|
+
if (detail1.length === 0)
|
|
273
|
+
throw ziguanjiaValidationError('input_required', 'detail1 至少一条采购申请明细');
|
|
274
|
+
const mainTable = { detail1 };
|
|
275
|
+
if (typeof body.purchase_name === 'string' && body.purchase_name !== '')
|
|
276
|
+
mainTable.purchase_name = body.purchase_name;
|
|
277
|
+
return {
|
|
278
|
+
preview: { operation: 'purch', uniqueIndent: ES.purch, mainTable },
|
|
279
|
+
confirmationText: `即将提交资产采购申请(${detail1.length} 条明细)。确认后执行。`,
|
|
280
|
+
commit: { uniqueIndent: ES.purch, mainTable },
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
async apply(commit, context) {
|
|
284
|
+
const result = await context.host.actionFlow({
|
|
285
|
+
uniqueIndent: String(commit.uniqueIndent),
|
|
286
|
+
mainTable: commit.mainTable,
|
|
287
|
+
operation: this.name,
|
|
288
|
+
});
|
|
289
|
+
return actionFlowResult(result);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/** 0/1 标记归一化为 '0' / '1'(is_group_calc 可能以数值、字符串或布尔返回)。 */
|
|
293
|
+
function normalizeBinaryFlag(value) {
|
|
294
|
+
if (value === undefined || value === null || value === '')
|
|
295
|
+
return undefined;
|
|
296
|
+
if (value === true)
|
|
297
|
+
return '1';
|
|
298
|
+
if (value === false)
|
|
299
|
+
return '0';
|
|
300
|
+
const text = String(value).trim().toLowerCase();
|
|
301
|
+
if (text === '1' || text === 'true')
|
|
302
|
+
return '1';
|
|
303
|
+
if (text === '0' || text === 'false')
|
|
304
|
+
return '0';
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
/** 安全转为有限数字;空值 / 非数字返回 undefined(避免把缺失字段误判为 0)。 */
|
|
308
|
+
function toFiniteNumber(value) {
|
|
309
|
+
if (value === undefined || value === null || value === '')
|
|
310
|
+
return undefined;
|
|
311
|
+
const num = Number(value);
|
|
312
|
+
return Number.isFinite(num) ? num : undefined;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 计提前置条件「可计提」校验(源资料要求必须严格执行):任一命中即阻止建单。
|
|
316
|
+
* 缺失字段不参与判断,避免因返回结构差异把「未返回」误判为「为 0」。
|
|
317
|
+
*/
|
|
318
|
+
function assertDeprePrecheckAllowed(table) {
|
|
319
|
+
const normal = toFiniteNumber(table?.normalCount);
|
|
320
|
+
const divide = toFiniteNumber(table?.divideCount);
|
|
321
|
+
const voucher = toFiniteNumber(table?.voucherCount);
|
|
322
|
+
const afterResult = toFiniteNumber(table?.afterResultCount);
|
|
323
|
+
const afterMonth = toFiniteNumber(table?.afterMonthRecordCount);
|
|
324
|
+
if (normal === 0) {
|
|
325
|
+
throw ziguanjiaValidationError('depre_not_allowed', '当前周期无符合条件的资产,无法发起计提操作');
|
|
326
|
+
}
|
|
327
|
+
if ((divide ?? 0) > 0 || (voucher ?? 0) > 0) {
|
|
328
|
+
throw ziguanjiaValidationError('depre_not_allowed', '目标周期已存在关联业务记录,无法重复计提');
|
|
329
|
+
}
|
|
330
|
+
if ((afterResult ?? 0) > 0 || (afterMonth ?? 0) > 0) {
|
|
331
|
+
throw ziguanjiaValidationError('depre_not_allowed', '后续周期已执行结账或计提操作,无法补录');
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export class ZiguanjiaDepreOperation extends ZiguanjiaPreparedWriteOperation {
|
|
335
|
+
constructor() {
|
|
336
|
+
super('asset.depre');
|
|
337
|
+
}
|
|
338
|
+
async prepare(body, context) {
|
|
339
|
+
const calcMonth = typeof body.calc_month === 'string' ? body.calc_month.trim() : '';
|
|
340
|
+
if (!/^\d{4}-\d{2}$/u.test(calcMonth)) {
|
|
341
|
+
throw ziguanjiaValidationError('input_invalid', 'calc_month 必填,格式 YYYY-MM,且须早于当前月份');
|
|
342
|
+
}
|
|
343
|
+
const now = new Date();
|
|
344
|
+
const currentMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`;
|
|
345
|
+
if (calcMonth >= currentMonth) {
|
|
346
|
+
throw ziguanjiaValidationError('input_invalid', `计提年月必须早于当前月份(当前 ${currentMonth}),${calcMonth} 不合法,已停止`);
|
|
347
|
+
}
|
|
348
|
+
// 第 2 步:读折旧设置,取 is_group_calc(1=分组计提 / 0=全量计提),据此推导 task_mode。
|
|
349
|
+
const setting = await context.host.ebuilderRequest({
|
|
350
|
+
endpoint: 'getFormDataList',
|
|
351
|
+
interfacePk: EB.depreSetting,
|
|
352
|
+
operation: this.name,
|
|
353
|
+
body: { mainTable: {}, pageInfo: { pageNo: '1', pageSize: '10' } },
|
|
354
|
+
});
|
|
355
|
+
const settingItems = getDatas(setting).map(mainTableOf);
|
|
356
|
+
const isGroupCalc = normalizeBinaryFlag(settingItems[0]?.is_group_calc) ?? '0';
|
|
357
|
+
const taskMode = isGroupCalc === '1' ? '1' : '0';
|
|
358
|
+
// 分组计提开启时,需「当前登录人所属分部 ID」:显式 company_ids 优先,否则按登录会话的分部名称解析。
|
|
359
|
+
let companyIds;
|
|
360
|
+
let companyName;
|
|
361
|
+
if (isGroupCalc === '1') {
|
|
362
|
+
const explicit = typeof body.company_ids === 'string' ? body.company_ids.trim() : '';
|
|
363
|
+
const session = await context.host.getSession();
|
|
364
|
+
companyName = session.subcompany || undefined;
|
|
365
|
+
companyIds = explicit !== '' ? explicit : await context.host.resolveSubcompanyIdByName(session.subcompany);
|
|
366
|
+
}
|
|
367
|
+
// 第 3 步:前置条件动作流(可计提校验)。
|
|
368
|
+
// 注意:动作流入参用 camelCase(calcMonth / companyIds),与第 4 步表单字段(calc_month / company_ids)不同。
|
|
369
|
+
const precheckMainTable = { calcMonth };
|
|
370
|
+
if (companyIds)
|
|
371
|
+
precheckMainTable.companyIds = companyIds;
|
|
372
|
+
const precheck = await context.host.actionFlow({
|
|
373
|
+
uniqueIndent: ES.deprePrecheck,
|
|
374
|
+
mainTable: precheckMainTable,
|
|
375
|
+
operation: this.name,
|
|
376
|
+
});
|
|
377
|
+
const precheckTable = actionFlowResult(precheck).mainTable;
|
|
378
|
+
assertDeprePrecheckAllowed(precheckTable);
|
|
379
|
+
const normalCount = toFiniteNumber(precheckTable?.normalCount);
|
|
380
|
+
const modeText = isGroupCalc === '1' ? '分组计提(按分部)' : '非分组计提(全量)';
|
|
381
|
+
const companyText = isGroupCalc === '1' ? `,分部:${companyName ?? companyIds}` : '';
|
|
382
|
+
const countText = normalCount !== undefined ? `,本期可计提资产 ${normalCount} 项` : '';
|
|
383
|
+
return {
|
|
384
|
+
preview: {
|
|
385
|
+
operation: 'depre',
|
|
386
|
+
calc_month: calcMonth,
|
|
387
|
+
is_group_calc: isGroupCalc,
|
|
388
|
+
task_mode: taskMode,
|
|
389
|
+
...(companyIds ? { company_ids: companyIds } : {}),
|
|
390
|
+
precheckResultCode: precheck?.resultCode,
|
|
391
|
+
precheckResultMsg: precheck?.resultMsg,
|
|
392
|
+
precheck: precheckTable,
|
|
393
|
+
settingCount: settingItems.length,
|
|
394
|
+
},
|
|
395
|
+
confirmationText: `即将对 ${calcMonth} 执行资产折旧计提(${modeText}${companyText}${countText})。确认后执行。`,
|
|
396
|
+
commit: {
|
|
397
|
+
calc_month: calcMonth,
|
|
398
|
+
is_group_calc: isGroupCalc,
|
|
399
|
+
task_mode: taskMode,
|
|
400
|
+
task_status: '0',
|
|
401
|
+
...(companyIds ? { company_ids: companyIds } : {}),
|
|
402
|
+
settingInterfacePk: EB.depreSetting,
|
|
403
|
+
taskInterfacePk: EB.depreTask,
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
async apply(commit, context) {
|
|
408
|
+
// 第 4 步:新增月度计提折旧任务。
|
|
409
|
+
// 契约必填:calc_month + task_mode(按 is_group_calc 推导)+ is_group_calc + task_status(固定 0);
|
|
410
|
+
// 分组计提开启时才带 company_ids(关闭时整项省略,不传空串)。
|
|
411
|
+
const mainTable = {
|
|
412
|
+
calc_month: commit.calc_month,
|
|
413
|
+
task_mode: commit.task_mode,
|
|
414
|
+
is_group_calc: commit.is_group_calc,
|
|
415
|
+
task_status: commit.task_status ?? '0',
|
|
416
|
+
};
|
|
417
|
+
if (typeof commit.company_ids === 'string' && commit.company_ids !== '') {
|
|
418
|
+
mainTable.company_ids = commit.company_ids;
|
|
419
|
+
}
|
|
420
|
+
const result = await context.host.ebuilderRequest({
|
|
421
|
+
endpoint: 'saveFormData',
|
|
422
|
+
interfacePk: String(commit.taskInterfacePk ?? EB.depreTask),
|
|
423
|
+
operation: this.name,
|
|
424
|
+
body: { operationinfo: OPERATIONINFO, datas: [{ mainTable }] },
|
|
425
|
+
});
|
|
426
|
+
const dataIds = result?.datajson?.dataIds ?? [];
|
|
427
|
+
return {
|
|
428
|
+
dataIds,
|
|
429
|
+
count: Array.isArray(dataIds) ? dataIds.length : 0,
|
|
430
|
+
calc_month: commit.calc_month,
|
|
431
|
+
is_group_calc: commit.is_group_calc,
|
|
432
|
+
task_mode: commit.task_mode,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getZiguanjiaOperation } from './operations/registry.js';
|
|
2
|
+
import { asObject } from './operations/shared.js';
|
|
3
|
+
import { assertNoForbiddenKeys } from './host.js';
|
|
4
|
+
export async function executeZiguanjiaOperation(operation, rawInput, context) {
|
|
5
|
+
const handler = getZiguanjiaOperation(operation);
|
|
6
|
+
const input = asObject(rawInput);
|
|
7
|
+
assertNoForbiddenKeys(input);
|
|
8
|
+
return handler.execute(input, context);
|
|
9
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { calendarValidationError } from './errors.js';
|
|
7
|
+
function stateRoot(ctx) {
|
|
8
|
+
const configured = ctx?.config?.path();
|
|
9
|
+
if (configured)
|
|
10
|
+
return resolve(configured, '..');
|
|
11
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
|
|
12
|
+
}
|
|
13
|
+
async function loadKey(ctx) {
|
|
14
|
+
const keysDir = resolve(stateRoot(ctx), 'keys');
|
|
15
|
+
const filename = resolve(keysDir, 'calendar-continuation.key');
|
|
16
|
+
await mkdir(keysDir, { recursive: true, mode: 0o700 });
|
|
17
|
+
if (existsSync(filename))
|
|
18
|
+
return readFile(filename);
|
|
19
|
+
const key = randomBytes(32);
|
|
20
|
+
try {
|
|
21
|
+
await writeFile(filename, key, { flag: 'wx', mode: 0o600 });
|
|
22
|
+
if (process.platform !== 'win32')
|
|
23
|
+
await chmod(filename, 0o600).catch(() => undefined);
|
|
24
|
+
return key;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return readFile(filename);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function encode(value) {
|
|
31
|
+
return Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
32
|
+
}
|
|
33
|
+
function signature(payload, key) {
|
|
34
|
+
return createHmac('sha256', key).update(payload).digest('base64url');
|
|
35
|
+
}
|
|
36
|
+
export function createCalendarContinuationSigner(ctx) {
|
|
37
|
+
return {
|
|
38
|
+
async issue(payload, ttlMs = 10 * 60_000) {
|
|
39
|
+
const issuedAt = Date.now();
|
|
40
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
41
|
+
const sig = signature(body, await loadKey(ctx));
|
|
42
|
+
return `${body}.${sig}`;
|
|
43
|
+
},
|
|
44
|
+
async verify(token, expectedOperation) {
|
|
45
|
+
if (typeof token !== 'string' || !token.includes('.')) {
|
|
46
|
+
throw calendarValidationError('continuation_invalid', 'continuation 无效');
|
|
47
|
+
}
|
|
48
|
+
const [body, provided] = token.split('.');
|
|
49
|
+
const expected = signature(body, await loadKey(ctx));
|
|
50
|
+
const valid = provided.length === expected.length
|
|
51
|
+
&& timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
52
|
+
if (!valid)
|
|
53
|
+
throw calendarValidationError('continuation_invalid', 'continuation 签名校验失败');
|
|
54
|
+
let value;
|
|
55
|
+
try {
|
|
56
|
+
value = JSON.parse(Buffer.from(body, 'base64url').toString('utf8'));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw calendarValidationError('continuation_invalid', 'continuation 内容无法解析');
|
|
60
|
+
}
|
|
61
|
+
if (value.operation !== expectedOperation) {
|
|
62
|
+
throw calendarValidationError('continuation_mismatch', 'continuation 不属于当前操作');
|
|
63
|
+
}
|
|
64
|
+
if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
|
|
65
|
+
throw calendarValidationError('continuation_expired', 'continuation 已过期');
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CliError, ExitCode } from '../../core/errors.js';
|
|
2
|
+
export class CalendarCliError extends CliError {
|
|
3
|
+
type;
|
|
4
|
+
subtype;
|
|
5
|
+
code;
|
|
6
|
+
retryable;
|
|
7
|
+
stage;
|
|
8
|
+
details;
|
|
9
|
+
partialData;
|
|
10
|
+
constructor(type, subtype, message, options = {}) {
|
|
11
|
+
super(message, options.exitCode ?? ExitCode.InternalError);
|
|
12
|
+
this.name = 'CalendarCliError';
|
|
13
|
+
this.type = type;
|
|
14
|
+
this.subtype = subtype;
|
|
15
|
+
this.code = options.code;
|
|
16
|
+
this.retryable = options.retryable ?? false;
|
|
17
|
+
this.stage = options.stage;
|
|
18
|
+
this.details = options.details;
|
|
19
|
+
this.partialData = options.partialData;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function calendarValidationError(subtype, message, details) {
|
|
23
|
+
return new CalendarCliError('validation', subtype, message, {
|
|
24
|
+
details,
|
|
25
|
+
exitCode: ExitCode.UsageError,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function calendarAuthError(subtype, message, details) {
|
|
29
|
+
return new CalendarCliError('authentication', subtype, message, {
|
|
30
|
+
details,
|
|
31
|
+
exitCode: ExitCode.AuthError,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function calendarNetworkError(subtype, message, options = {}) {
|
|
35
|
+
return new CalendarCliError('network', subtype, message, {
|
|
36
|
+
...options,
|
|
37
|
+
retryable: options.retryable ?? true,
|
|
38
|
+
exitCode: ExitCode.NetworkError,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function calendarConfirmationError(action, details) {
|
|
42
|
+
return new CalendarCliError('confirmation', 'required', '该操作需要明确确认', {
|
|
43
|
+
details: { action, ...details },
|
|
44
|
+
exitCode: ExitCode.ConfirmationRequired,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function calendarPartialError(message, partialData, details) {
|
|
48
|
+
return new CalendarCliError('partial', 'write_uncertain', message, {
|
|
49
|
+
details,
|
|
50
|
+
partialData,
|
|
51
|
+
exitCode: ExitCode.Partial,
|
|
52
|
+
});
|
|
53
|
+
}
|