weaver-work-cli 0.1.7 → 0.1.20
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 +11 -11
- package/dist/cmd/action.js +76 -0
- package/dist/cmd/index.js +2 -0
- package/dist/cmd/refs/index.js +103 -0
- package/dist/cmd/register.js +31 -0
- package/dist/cmd/root.js +1 -0
- package/dist/cmd/setup/index.js +25 -5
- package/dist/cmd/skills/index.js +37 -5
- package/dist/core/connector.js +54 -0
- package/dist/core/context.js +2 -1
- package/dist/core/input.js +48 -0
- package/dist/core/output.js +298 -3
- package/dist/core/refs.js +432 -0
- package/dist/core/state.js +26 -0
- package/dist/internal/e10/auth/commands.js +2 -2
- package/dist/internal/e10/auth/session.js +14 -0
- package/dist/internal/e10/auth/xiaoe.js +116 -51
- package/dist/internal/e10/request-runtime.js +5 -0
- package/dist/internal/skills/install.js +148 -28
- package/dist/internal/skills/reader.js +12 -9
- package/dist/shortcuts/blog/continuation.js +74 -0
- package/dist/shortcuts/blog/errors.js +60 -0
- package/dist/shortcuts/blog/host.js +175 -0
- package/dist/shortcuts/blog/index.js +324 -0
- package/dist/shortcuts/blog/manifest.js +415 -0
- package/dist/shortcuts/blog/operations/comment.js +125 -0
- package/dist/shortcuts/blog/operations/comments.js +31 -0
- package/dist/shortcuts/blog/operations/edit.js +131 -0
- package/dist/shortcuts/blog/operations/export.js +46 -0
- package/dist/shortcuts/blog/operations/like.js +80 -0
- package/dist/shortcuts/blog/operations/publish.js +157 -0
- package/dist/shortcuts/blog/operations/query-user.js +58 -0
- package/dist/shortcuts/blog/operations/query.js +96 -0
- package/dist/shortcuts/blog/operations/registry.js +54 -0
- package/dist/shortcuts/blog/operations/remind.js +176 -0
- package/dist/shortcuts/blog/operations/shared.js +330 -0
- package/dist/shortcuts/blog/operations/types.js +16 -0
- package/dist/shortcuts/blog/operations.js +9 -0
- package/dist/shortcuts/caizhilian/continuation.js +70 -0
- package/dist/shortcuts/caizhilian/errors.js +53 -0
- package/dist/shortcuts/caizhilian/host.js +190 -0
- package/dist/shortcuts/caizhilian/index.js +186 -0
- package/dist/shortcuts/caizhilian/manifest.js +42 -0
- package/dist/shortcuts/caizhilian/operations/api.js +801 -0
- package/dist/shortcuts/caizhilian/operations/confirm.js +75 -0
- package/dist/shortcuts/caizhilian/operations/files.js +306 -0
- package/dist/shortcuts/caizhilian/operations/form.js +170 -0
- package/dist/shortcuts/caizhilian/operations/handlers/collab.js +611 -0
- package/dist/shortcuts/caizhilian/operations/handlers/document.js +890 -0
- package/dist/shortcuts/caizhilian/operations/handlers/file-collection.js +346 -0
- package/dist/shortcuts/caizhilian/operations/handlers/file-upload.js +192 -0
- package/dist/shortcuts/caizhilian/operations/handlers/fileops.js +570 -0
- package/dist/shortcuts/caizhilian/operations/handlers/folder.js +969 -0
- package/dist/shortcuts/caizhilian/operations/handlers/search.js +318 -0
- package/dist/shortcuts/caizhilian/operations/handlers/setting-attach.js +294 -0
- package/dist/shortcuts/caizhilian/operations/handlers/setting-backup.js +423 -0
- package/dist/shortcuts/caizhilian/operations/handlers/setting-encrypt.js +238 -0
- package/dist/shortcuts/caizhilian/operations/handlers/setting-storage.js +364 -0
- package/dist/shortcuts/caizhilian/operations/handlers/system.js +106 -0
- package/dist/shortcuts/caizhilian/operations/registry.js +151 -0
- package/dist/shortcuts/caizhilian/operations/shared.js +408 -0
- package/dist/shortcuts/caizhilian/operations/specs.js +623 -0
- package/dist/shortcuts/caizhilian/operations/types.js +57 -0
- package/dist/shortcuts/caizhilian/operations.js +21 -0
- package/dist/shortcuts/contract/continuation.js +70 -0
- package/dist/shortcuts/contract/errors.js +62 -0
- package/dist/shortcuts/contract/host.js +205 -0
- package/dist/shortcuts/contract/index.js +318 -0
- package/dist/shortcuts/contract/manifest.js +596 -0
- package/dist/shortcuts/contract/operations/clause-reference.js +78 -0
- package/dist/shortcuts/contract/operations/form-info.js +371 -0
- package/dist/shortcuts/contract/operations/read.js +118 -0
- package/dist/shortcuts/contract/operations/registry.js +43 -0
- package/dist/shortcuts/contract/operations/request.js +300 -0
- package/dist/shortcuts/contract/operations/shared.js +133 -0
- package/dist/shortcuts/contract/operations/subject.js +157 -0
- package/dist/shortcuts/contract/operations/template.js +81 -0
- package/dist/shortcuts/contract/operations/types.js +7 -0
- package/dist/shortcuts/contract/operations/workflow.js +52 -0
- package/dist/shortcuts/contract/operations/write.js +131 -0
- package/dist/shortcuts/contract/operations.js +8 -0
- package/dist/shortcuts/hrm/index.js +83 -2
- package/dist/shortcuts/hrm/operations/employee.js +160 -30
- package/dist/shortcuts/hrm/operations/org.js +17 -3
- package/dist/shortcuts/hrm/operations/position.js +18 -2
- package/dist/shortcuts/index.js +5 -1
- package/dist/shortcuts/invoice/index.js +74 -36
- package/dist/shortcuts/invoice/manifest.js +674 -4
- package/dist/shortcuts/invoice/markdown.js +172 -0
- package/dist/shortcuts/invoice/operations/add.js +3 -3
- package/dist/shortcuts/invoice/operations/delete.js +2 -2
- package/dist/shortcuts/invoice/operations/get.js +10 -2
- package/dist/shortcuts/invoice/operations/import.js +2 -2
- package/dist/shortcuts/invoice/operations/registry.js +8 -1
- package/dist/shortcuts/invoice/operations/reim-auto.js +719 -0
- package/dist/shortcuts/invoice/operations/reim.js +85 -2
- package/dist/shortcuts/invoice/operations/shared.js +75 -8
- package/dist/shortcuts/invoice/operations/update.js +2 -2
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +93 -0
- package/dist/shortcuts/invoice/operations/validate-preview.js +2 -1
- package/dist/shortcuts/invoice/projection.js +328 -0
- package/dist/shortcuts/meeting/host.js +18 -1
- package/dist/shortcuts/meeting/manifest.js +30 -18
- package/dist/shortcuts/meeting/operations/eb/catalog.js +390 -0
- package/dist/shortcuts/meeting/operations/eb/conflict.js +389 -0
- package/dist/shortcuts/meeting/operations/eb/factory.js +389 -0
- package/dist/shortcuts/meeting/operations/eb/index.js +22 -0
- package/dist/shortcuts/meeting/operations/env.js +8 -1
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/meeting/operations/signs.js +216 -2
- package/dist/shortcuts/workflow/endpoints.js +2 -1
- package/dist/shortcuts/workflow/errors.js +8 -2
- package/dist/shortcuts/workflow/host.js +6 -3
- package/dist/shortcuts/workflow/operations/form.js +931 -533
- package/dist/shortcuts/workflow/operations/read.js +462 -81
- package/dist/shortcuts/workflow/operations/shared.js +44 -0
- package/dist/shortcuts/workflow/operations/write.js +760 -56
- package/dist/shortcuts/workflow/operations.js +36 -10
- package/docs/_catalog.md +6 -0
- package/docs/agent-invoice.md +5 -1
- package/docs/agent-io-channel-design.md +468 -0
- package/docs/agent-skill-install.md +9 -4
- package/docs/blog.md +123 -0
- package/docs/caizhilian.md +304 -0
- package/docs/contract.md +91 -0
- package/docs/e10-auth.md +2 -2
- package/docs/hrm.md +19 -9
- package/docs/invoice.md +5 -1
- package/docs/meeting.md +1 -1
- package/docs/operation-manual.md +15 -3
- package/docs/skill-review-2026-09-19.md +2 -2
- package/package.json +2 -2
- package/scripts/package-skill.mjs +33 -20
- package/skill-template/business-info.json +113 -14
- package/skill-template/domains/blog.md +24 -0
- package/skill-template/domains/caizhilian.md +22 -0
- package/skill-template/domains/jinchengda.md +23 -0
- package/skill-template/domains/meeting.md +1 -1
- package/skill-template/domains/workflow.md +1 -1
- package/skill-template/skill-template.md +1 -1
- package/skills/weaver-e10-blog/SKILL.md +111 -0
- package/skills/weaver-e10-blog/references/blog-comment.md +51 -0
- package/skills/weaver-e10-blog/references/blog-comments.md +39 -0
- package/skills/weaver-e10-blog/references/blog-default-permission.md +38 -0
- package/skills/weaver-e10-blog/references/blog-disabled-capabilities.md +11 -0
- package/skills/weaver-e10-blog/references/blog-edit.md +51 -0
- package/skills/weaver-e10-blog/references/blog-export.md +42 -0
- package/skills/weaver-e10-blog/references/blog-like.md +50 -0
- package/skills/weaver-e10-blog/references/blog-publish.md +52 -0
- package/skills/weaver-e10-blog/references/blog-query-user.md +45 -0
- package/skills/weaver-e10-blog/references/blog-query.md +49 -0
- package/skills/weaver-e10-blog/references/blog-remind.md +51 -0
- package/skills/weaver-e10-blog/references/blog-resolve-users.md +38 -0
- package/skills/weaver-e10-blog/references/source-manifest.json +1540 -0
- package/skills/weaver-e10-caizhilian/SKILL.md +216 -0
- package/skills/weaver-e10-caizhilian/references/agent-entry.md +106 -0
- package/skills/weaver-e10-caizhilian/references/collaboration.md +112 -0
- package/skills/weaver-e10-caizhilian/references/document.md +111 -0
- package/skills/weaver-e10-caizhilian/references/file-collection.md +136 -0
- package/skills/weaver-e10-caizhilian/references/file-upload.md +309 -0
- package/skills/weaver-e10-caizhilian/references/files.md +120 -0
- package/skills/weaver-e10-caizhilian/references/folder.md +118 -0
- package/skills/weaver-e10-caizhilian/references/org-browser.md +104 -0
- package/skills/weaver-e10-caizhilian/references/setting-attach.md +410 -0
- package/skills/weaver-e10-caizhilian/references/setting-backup.md +372 -0
- package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +399 -0
- package/skills/weaver-e10-caizhilian/references/setting-storage.md +603 -0
- package/skills/weaver-e10-caizhilian/references/source-manifest.json +5079 -0
- package/skills/weaver-e10-caizhilian/references/withheld.md +93 -0
- package/skills/weaver-e10-caizhilian/references/write-protocol.md +120 -0
- package/skills/weaver-e10-calendar/SKILL.md +4 -3
- package/skills/weaver-e10-ebuilder-form/SKILL.md +4 -9
- package/skills/weaver-e10-ebuilder-form/references/context-routing.md +0 -9
- package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -5
- package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +1 -5
- package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +1 -5
- package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +1 -5
- package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -5
- package/skills/weaver-e10-esb/SKILL.md +2 -2
- package/skills/weaver-e10-esb/references/source-manifest.json +9 -9
- package/skills/weaver-e10-hrm/SKILL.md +54 -6
- package/skills/weaver-e10-hrm/references/employee.md +89 -15
- package/skills/weaver-e10-hrm/references/org.md +7 -4
- package/skills/weaver-e10-hrm/references/position.md +14 -7
- package/skills/weaver-e10-hrm/references/source-manifest.json +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +166 -0
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +82 -0
- package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +69 -0
- package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +78 -0
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +27 -0
- package/skills/weaver-e10-jinchengda/references/contract-request-status.md +71 -0
- package/skills/weaver-e10-jinchengda/references/contract-request-write.md +94 -0
- package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +89 -0
- package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +77 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +66 -0
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +94 -0
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +259 -0
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -11
- package/skills/weaver-e10-jucailin/SKILL.md +4 -3
- package/skills/weaver-e10-mail/SKILL.md +4 -11
- package/skills/weaver-e10-meeting/SKILL.md +66 -32
- package/skills/weaver-e10-meeting/references/meeting-change.md +5 -2
- package/skills/weaver-e10-meeting/references/meeting-create.md +2 -1
- package/skills/weaver-e10-meeting/references/meeting-eb.md +114 -0
- package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +9 -8
- package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +35 -7
- package/skills/weaver-e10-meeting/references/meeting-update.md +1 -1
- package/skills/weaver-e10-okr/SKILL.md +6 -11
- package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
- package/skills/weaver-e10-plan/SKILL.md +3 -3
- package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +1 -1
- package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +1 -1
- package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
- package/skills/weaver-e10-qiyecheng/SKILL.md +4 -10
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
- package/skills/weaver-e10-shared/SKILL.md +36 -25
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +10 -31
- package/skills/weaver-e10-shared/references/json-output-contract.md +20 -11
- package/skills/weaver-e10-shijingran/SKILL.md +2 -1
- package/skills/weaver-e10-shijingran/references/source-manifest.json +9 -9
- package/skills/weaver-e10-skill-maker/SKILL.md +4 -10
- package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +5 -3
- package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +12 -27
- package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +17 -5
- package/skills/weaver-e10-skill-maker/references/source-update-detection.md +4 -27
- package/skills/weaver-e10-wenshuding/SKILL.md +5 -16
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +7 -7
- package/skills/weaver-e10-workflow/SKILL.md +32 -37
- package/skills/weaver-e10-workflow/references/source-manifest.json +40 -77
- package/skills/weaver-e10-workflow/references/workflow-batch.md +90 -29
- package/skills/weaver-e10-workflow/references/workflow-create.md +79 -109
- package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -9
- package/skills/weaver-e10-workflow/references/workflow-operate.md +2 -2
- package/skills/weaver-e10-workflow/references/workflow-query.md +37 -20
- package/skills/weaver-e10-workflow/references/workflow-share.md +18 -2
- package/skills/weaver-e10-workflow/references/workflow-view.md +4 -4
- package/skills/weaver-e10-yepiaotong/SKILL.md +75 -39
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +22 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +5 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +135 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +15 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-summarize.py +217 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +88 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +7 -2
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +90 -10
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -0
- package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +70 -49
- package/skills/weaver-e10-yepiaotong/references/reim-fast-path.md +119 -0
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +55 -36
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +4 -0
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +149 -0
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +125 -5
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +430 -63
- package/skills/weaver-e10-yimiaoban/SKILL.md +4 -12
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
- package/skills/weaver-e10-ziguanjia/SKILL.md +2 -1
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +3 -3
- package/tools/weaver-skill-detector-1.0.13/SKILL.md +9 -9
- package/tools/weaver-skill-detector-1.0.13/references/checklist.md +3 -3
- package/tools/weaver-skill-detector-1.0.13/scripts/__pycache__/validate_skill.cpython-313.pyc +0 -0
- package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +98 -91
- package/scripts/sync-connector-skills.mjs +0 -172
package/dist/shortcuts/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { caizhilianShortcut } from './caizhilian/index.js';
|
|
1
2
|
import { projectShortcut } from './project/index.js';
|
|
3
|
+
import { blogShortcut } from './blog/index.js';
|
|
2
4
|
import { archiveShortcut } from './archive/index.js';
|
|
3
5
|
import { calendarShortcut } from './calendar/index.js';
|
|
4
6
|
import { ehrShortcut } from './ehr/index.js';
|
|
@@ -32,5 +34,7 @@ export const builtinShortcuts = [
|
|
|
32
34
|
assetShortcut,
|
|
33
35
|
imShortcut,
|
|
34
36
|
projectShortcut,
|
|
35
|
-
workflowShortcut
|
|
37
|
+
workflowShortcut,
|
|
38
|
+
blogShortcut,
|
|
39
|
+
caizhilianShortcut
|
|
36
40
|
];
|
|
@@ -4,6 +4,8 @@ import { createInvoiceContinuationSigner } from './continuation.js';
|
|
|
4
4
|
import { createInvoiceHost } from './host.js';
|
|
5
5
|
import { invoiceManifest } from './manifest.js';
|
|
6
6
|
import { executeInvoiceOperation } from './operations.js';
|
|
7
|
+
import { normalizeFields, normalizeView, formatFrom, assertProjectionSupported, applyInvoiceProjection, } from './projection.js';
|
|
8
|
+
import { renderInvoiceMarkdown } from './markdown.js';
|
|
7
9
|
import { invoiceValidationError } from './errors.js';
|
|
8
10
|
function asOptions(value) {
|
|
9
11
|
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
@@ -57,6 +59,32 @@ function withJsonInputOptions(command) {
|
|
|
57
59
|
.option('--input-json <json>', 'inline JSON input object');
|
|
58
60
|
return command;
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* 输出投影选项:让调用方一次拿到可读结果,而不必再写脚本解析完整 envelope。
|
|
64
|
+
* `--view summary` 只对 list 类 operation 生效、`--view detail` 只对 invoice.get 生效(见 projection.ts);
|
|
65
|
+
* `--fields` 对所有 operation 生效;`--format markdown` 是渲染档,直接出表格文本(见 markdown.ts)。
|
|
66
|
+
*/
|
|
67
|
+
function withOutputOptions(command) {
|
|
68
|
+
command
|
|
69
|
+
.option('--view <mode>', 'output view: full (default), summary (list ops) or detail (invoice.get)')
|
|
70
|
+
.option('--format <mode>', 'output format: json (default) or markdown (human-readable text)')
|
|
71
|
+
.option('--fields <paths>', 'comma-separated dot paths to keep, e.g. number,detailUrl');
|
|
72
|
+
return command;
|
|
73
|
+
}
|
|
74
|
+
function withInvoiceOptions(command) {
|
|
75
|
+
return withOutputOptions(withJsonInputOptions(command));
|
|
76
|
+
}
|
|
77
|
+
function projectionFrom(options) {
|
|
78
|
+
const opts = asOptions(options);
|
|
79
|
+
const view = normalizeView(opts.view);
|
|
80
|
+
const fields = normalizeFields(opts.fields);
|
|
81
|
+
const format = formatFrom(opts.format);
|
|
82
|
+
return {
|
|
83
|
+
...(view ? { view } : {}),
|
|
84
|
+
...(fields ? { fields } : {}),
|
|
85
|
+
...(format ? { format } : {}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
60
88
|
function intOption(value) {
|
|
61
89
|
if (value === undefined || value === null || value === '')
|
|
62
90
|
return undefined;
|
|
@@ -68,13 +96,13 @@ function stringOption(value) {
|
|
|
68
96
|
return undefined;
|
|
69
97
|
return String(value);
|
|
70
98
|
}
|
|
71
|
-
function successEnvelope(operation, result) {
|
|
99
|
+
function successEnvelope(operation, result, meta) {
|
|
72
100
|
return {
|
|
73
101
|
schemaVersion: 1,
|
|
74
102
|
ok: true,
|
|
75
103
|
operation,
|
|
76
104
|
data: result.data,
|
|
77
|
-
meta: { status: result.status },
|
|
105
|
+
meta: { status: result.status, ...(meta ?? {}) },
|
|
78
106
|
warnings: [],
|
|
79
107
|
};
|
|
80
108
|
}
|
|
@@ -87,13 +115,23 @@ function failureEnvelope(error) {
|
|
|
87
115
|
error: toErrorEnvelope(error),
|
|
88
116
|
};
|
|
89
117
|
}
|
|
90
|
-
async function executeAndPrint(ctx, operation, input) {
|
|
118
|
+
async function executeAndPrint(ctx, operation, input, projection = {}) {
|
|
91
119
|
try {
|
|
120
|
+
assertProjectionSupported(operation, projection);
|
|
92
121
|
const result = await executeInvoiceOperation(operation, input, {
|
|
93
122
|
host: createInvoiceHost(ctx),
|
|
94
123
|
continuation: createInvoiceContinuationSigner(ctx),
|
|
95
124
|
});
|
|
96
|
-
|
|
125
|
+
const projected = applyInvoiceProjection(operation, result.data, projection);
|
|
126
|
+
if (projection.format === 'markdown') {
|
|
127
|
+
// 渲染档输出的是文本,不是 envelope:与 --json 混用会让调用方误判输出契约,直接拦住。
|
|
128
|
+
if (ctx.getGlobalOptions().json) {
|
|
129
|
+
throw invoiceValidationError('input_conflict', '--format markdown 与 --json 互斥:markdown 是渲染档(文本),不是 JSON。去掉 --json 再试');
|
|
130
|
+
}
|
|
131
|
+
process.stdout.write(renderInvoiceMarkdown(operation, projected.data));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
ctx.output.write(successEnvelope(operation, { status: result.status, data: projected.data }, projected.meta), { json: true });
|
|
97
135
|
}
|
|
98
136
|
catch (error) {
|
|
99
137
|
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
@@ -111,13 +149,13 @@ export const invoiceShortcut = {
|
|
|
111
149
|
.action(action((ctx) => {
|
|
112
150
|
ctx.output.write(invoiceManifest, { json: true });
|
|
113
151
|
}));
|
|
114
|
-
|
|
152
|
+
withInvoiceOptions(invoice.command('run')
|
|
115
153
|
.description('Run an invoice operation with JSON input')
|
|
116
154
|
.argument('<operation>', 'operation name, e.g. invoice.list'))
|
|
117
155
|
.action(action(async (ctx, operation, options) => {
|
|
118
|
-
await executeAndPrint(ctx, String(operation), await inputFrom(options));
|
|
156
|
+
await executeAndPrint(ctx, String(operation), await inputFrom(options), projectionFrom(options));
|
|
119
157
|
}));
|
|
120
|
-
|
|
158
|
+
withInvoiceOptions(invoice.command('list')
|
|
121
159
|
.description('List personal invoice folder entries')
|
|
122
160
|
.option('--content <keyword>', 'keyword search')
|
|
123
161
|
.option('--page-size <size>', 'page size')
|
|
@@ -130,10 +168,10 @@ export const invoiceShortcut = {
|
|
|
130
168
|
page_size: intOption(opts.pageSize),
|
|
131
169
|
start_pos: intOption(opts.startPos),
|
|
132
170
|
sreim: stringOption(opts.sreim),
|
|
133
|
-
}));
|
|
171
|
+
}), projectionFrom(options));
|
|
134
172
|
}));
|
|
135
173
|
const enterprise = invoice.command('enterprise').description('Enterprise invoice folder commands');
|
|
136
|
-
|
|
174
|
+
withInvoiceOptions(enterprise.command('list')
|
|
137
175
|
.description('List enterprise invoice folder entries')
|
|
138
176
|
.option('--content <keyword>', 'keyword search')
|
|
139
177
|
.option('--page-size <size>', 'page size')
|
|
@@ -146,9 +184,9 @@ export const invoiceShortcut = {
|
|
|
146
184
|
page_size: intOption(opts.pageSize),
|
|
147
185
|
start_pos: intOption(opts.startPos),
|
|
148
186
|
sreim: stringOption(opts.sreim),
|
|
149
|
-
}));
|
|
187
|
+
}), projectionFrom(options));
|
|
150
188
|
}));
|
|
151
|
-
|
|
189
|
+
withInvoiceOptions(invoice.command('get')
|
|
152
190
|
.description('Get invoice detail by fid or number')
|
|
153
191
|
.option('--fid <fid>', 'invoice fid')
|
|
154
192
|
.option('--number <number>', 'invoice number'))
|
|
@@ -157,9 +195,9 @@ export const invoiceShortcut = {
|
|
|
157
195
|
await executeAndPrint(ctx, 'invoice.get', await inputFrom(options, {
|
|
158
196
|
fid: opts.fid,
|
|
159
197
|
number: opts.number,
|
|
160
|
-
}));
|
|
198
|
+
}), projectionFrom(options));
|
|
161
199
|
}));
|
|
162
|
-
|
|
200
|
+
withInvoiceOptions(invoice.command('upload')
|
|
163
201
|
.description('Upload an invoice file for OCR')
|
|
164
202
|
.option('--file <path>', 'local invoice file')
|
|
165
203
|
.option('--url <url>', 'server-accessible file URL'))
|
|
@@ -168,10 +206,10 @@ export const invoiceShortcut = {
|
|
|
168
206
|
await executeAndPrint(ctx, 'invoice.upload', await inputFrom(options, {
|
|
169
207
|
file: opts.file,
|
|
170
208
|
url: opts.url,
|
|
171
|
-
}));
|
|
209
|
+
}), projectionFrom(options));
|
|
172
210
|
}));
|
|
173
211
|
const ocr = invoice.command('ocr').description('Invoice OCR commands');
|
|
174
|
-
|
|
212
|
+
withInvoiceOptions(ocr.command('preview')
|
|
175
213
|
.description('Preview OCR result without saving an invoice')
|
|
176
214
|
.option('--file <path>', 'local invoice file')
|
|
177
215
|
.option('--url <url>', 'server-accessible file URL'))
|
|
@@ -180,10 +218,10 @@ export const invoiceShortcut = {
|
|
|
180
218
|
await executeAndPrint(ctx, 'invoice.ocr.preview', await inputFrom(options, {
|
|
181
219
|
file: opts.file,
|
|
182
220
|
url: opts.url,
|
|
183
|
-
}));
|
|
221
|
+
}), projectionFrom(options));
|
|
184
222
|
}));
|
|
185
223
|
const validate = invoice.command('validate').description('Invoice validation commands');
|
|
186
|
-
|
|
224
|
+
withInvoiceOptions(validate.command('preview')
|
|
187
225
|
.description('Validate an existing invoice without saving validation result')
|
|
188
226
|
.option('--fid <fid>', 'invoice fid')
|
|
189
227
|
.option('--scope <scope>', 'personal or enterprise'))
|
|
@@ -192,10 +230,10 @@ export const invoiceShortcut = {
|
|
|
192
230
|
await executeAndPrint(ctx, 'invoice.validate.preview', await inputFrom(options, {
|
|
193
231
|
fid: opts.fid,
|
|
194
232
|
scope: opts.scope,
|
|
195
|
-
}));
|
|
233
|
+
}), projectionFrom(options));
|
|
196
234
|
}));
|
|
197
235
|
const importCommand = invoice.command('import').description('Invoice file import commands');
|
|
198
|
-
|
|
236
|
+
withInvoiceOptions(importCommand.command('prepare')
|
|
199
237
|
.description('Prepare a confirmed invoice file import')
|
|
200
238
|
.option('--file <path>', 'local invoice file')
|
|
201
239
|
.option('--validate', 'request validation before import')
|
|
@@ -208,9 +246,9 @@ export const invoiceShortcut = {
|
|
|
208
246
|
file: opts.file,
|
|
209
247
|
validate: typeof opts.validate === 'boolean' ? opts.validate : undefined,
|
|
210
248
|
syncToOa: typeof opts.syncToOa === 'boolean' ? opts.syncToOa : undefined,
|
|
211
|
-
}));
|
|
249
|
+
}), projectionFrom(options));
|
|
212
250
|
}));
|
|
213
|
-
|
|
251
|
+
withInvoiceOptions(importCommand.command('apply')
|
|
214
252
|
.description('Apply a prepared invoice file import')
|
|
215
253
|
.option('--file <path>', 'local invoice file')
|
|
216
254
|
.option('--continuation <token>', 'continuation token from prepare')
|
|
@@ -221,17 +259,17 @@ export const invoiceShortcut = {
|
|
|
221
259
|
file: opts.file,
|
|
222
260
|
continuation: opts.continuation,
|
|
223
261
|
confirm: opts.yes === true ? true : undefined,
|
|
224
|
-
}));
|
|
262
|
+
}), projectionFrom(options));
|
|
225
263
|
}));
|
|
226
264
|
const add = invoice.command('add').description('Manual invoice add commands');
|
|
227
|
-
|
|
265
|
+
withInvoiceOptions(add.command('prepare')
|
|
228
266
|
.description('Prepare a confirmed manual invoice add')
|
|
229
267
|
.option('--scope <scope>', 'personal or enterprise'))
|
|
230
268
|
.action(action(async (ctx, options) => {
|
|
231
269
|
const opts = asOptions(options);
|
|
232
|
-
await executeAndPrint(ctx, 'invoice.add.prepare', await inputFrom(options, { scope: opts.scope }));
|
|
270
|
+
await executeAndPrint(ctx, 'invoice.add.prepare', await inputFrom(options, { scope: opts.scope }), projectionFrom(options));
|
|
233
271
|
}));
|
|
234
|
-
|
|
272
|
+
withInvoiceOptions(add.command('apply')
|
|
235
273
|
.description('Apply a prepared manual invoice add')
|
|
236
274
|
.option('--continuation <token>', 'continuation token from prepare')
|
|
237
275
|
.option('--yes', 'confirm the write operation'))
|
|
@@ -240,10 +278,10 @@ export const invoiceShortcut = {
|
|
|
240
278
|
await executeAndPrint(ctx, 'invoice.add.apply', await inputFrom(options, {
|
|
241
279
|
continuation: opts.continuation,
|
|
242
280
|
confirm: opts.yes === true ? true : undefined,
|
|
243
|
-
}));
|
|
281
|
+
}), projectionFrom(options));
|
|
244
282
|
}));
|
|
245
283
|
const update = invoice.command('update').description('Invoice update commands');
|
|
246
|
-
|
|
284
|
+
withInvoiceOptions(update.command('prepare')
|
|
247
285
|
.description('Prepare an invoice update')
|
|
248
286
|
.option('--fid <fid>', 'invoice fid')
|
|
249
287
|
.option('--scope <scope>', 'personal or enterprise'))
|
|
@@ -252,9 +290,9 @@ export const invoiceShortcut = {
|
|
|
252
290
|
await executeAndPrint(ctx, 'invoice.update.prepare', await inputFrom(options, {
|
|
253
291
|
fid: opts.fid,
|
|
254
292
|
scope: opts.scope,
|
|
255
|
-
}));
|
|
293
|
+
}), projectionFrom(options));
|
|
256
294
|
}));
|
|
257
|
-
|
|
295
|
+
withInvoiceOptions(update.command('apply')
|
|
258
296
|
.description('Apply a prepared invoice update')
|
|
259
297
|
.option('--continuation <token>', 'continuation token from prepare')
|
|
260
298
|
.option('--yes', 'confirm the write operation'))
|
|
@@ -263,9 +301,9 @@ export const invoiceShortcut = {
|
|
|
263
301
|
await executeAndPrint(ctx, 'invoice.update.apply', await inputFrom(options, {
|
|
264
302
|
continuation: opts.continuation,
|
|
265
303
|
confirm: opts.yes === true ? true : undefined,
|
|
266
|
-
}));
|
|
304
|
+
}), projectionFrom(options));
|
|
267
305
|
}));
|
|
268
|
-
|
|
306
|
+
withInvoiceOptions(invoice.command('download')
|
|
269
307
|
.description('Download an invoice attachment after verifying ownership')
|
|
270
308
|
.option('--fid <fid>', 'invoice fid')
|
|
271
309
|
.option('--file-id <id>', 'invoice file id')
|
|
@@ -276,10 +314,10 @@ export const invoiceShortcut = {
|
|
|
276
314
|
fid: opts.fid,
|
|
277
315
|
fileId: opts.fileId,
|
|
278
316
|
output: opts.output,
|
|
279
|
-
}));
|
|
317
|
+
}), projectionFrom(options));
|
|
280
318
|
}));
|
|
281
319
|
const del = invoice.command('delete').description('Invoice delete commands');
|
|
282
|
-
|
|
320
|
+
withInvoiceOptions(del.command('prepare')
|
|
283
321
|
.description('Prepare an invoice soft delete')
|
|
284
322
|
.option('--fid <fid>', 'invoice fid')
|
|
285
323
|
.option('--scope <scope>', 'personal or enterprise'))
|
|
@@ -288,9 +326,9 @@ export const invoiceShortcut = {
|
|
|
288
326
|
await executeAndPrint(ctx, 'invoice.delete.prepare', await inputFrom(options, {
|
|
289
327
|
fid: opts.fid,
|
|
290
328
|
scope: opts.scope,
|
|
291
|
-
}));
|
|
329
|
+
}), projectionFrom(options));
|
|
292
330
|
}));
|
|
293
|
-
|
|
331
|
+
withInvoiceOptions(del.command('apply')
|
|
294
332
|
.description('Apply a prepared invoice soft delete')
|
|
295
333
|
.option('--continuation <token>', 'continuation token from prepare')
|
|
296
334
|
.option('--yes', 'confirm the write operation'))
|
|
@@ -299,7 +337,7 @@ export const invoiceShortcut = {
|
|
|
299
337
|
await executeAndPrint(ctx, 'invoice.delete.apply', await inputFrom(options, {
|
|
300
338
|
continuation: opts.continuation,
|
|
301
339
|
confirm: opts.yes === true ? true : undefined,
|
|
302
|
-
}));
|
|
340
|
+
}), projectionFrom(options));
|
|
303
341
|
}));
|
|
304
342
|
},
|
|
305
343
|
};
|