@tocca-systems/twp-cli 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.public.md +12 -0
  2. package/README.md +96 -1
  3. package/dist/{ai-dispatch-KRMDHQEF.js → ai-dispatch-AHCYPQ5Y.js} +1 -1
  4. package/dist/{api-command-IO572BZ4.js → api-command-7PZCMQO5.js} +4 -4
  5. package/dist/{app-Y2RIXLS4.js → app-PNHDMD3V.js} +4 -4
  6. package/dist/{backlog-67JSQYOH.js → backlog-ISEIWKMQ.js} +1 -1
  7. package/dist/{chunk-4ZT5LTRX.js → chunk-43OMEGNH.js} +1 -1
  8. package/dist/{chunk-HAIZHSNZ.js → chunk-6ZUVESMI.js} +1 -1
  9. package/dist/{chunk-QDTYD5PY.js → chunk-7ACENLLZ.js} +4 -4
  10. package/dist/{chunk-BJLXXRSY.js → chunk-B7YCG2T7.js} +1 -1
  11. package/dist/{chunk-MHRGKUMK.js → chunk-BPCK5RAB.js} +1 -1
  12. package/dist/{chunk-RZ54TCQU.js → chunk-BZ7ULFR3.js} +1 -1
  13. package/dist/{chunk-ELXDRPDV.js → chunk-BZAXQOLB.js} +24 -19
  14. package/dist/chunk-EOSSFTNG.js +4 -0
  15. package/dist/chunk-FKS2Z34P.js +70 -0
  16. package/dist/{chunk-QQLWMHGR.js → chunk-H54MGGHB.js} +1 -1
  17. package/dist/chunk-L6AHCTQZ.js +8 -0
  18. package/dist/chunk-PEM3HR7L.js +58 -0
  19. package/dist/{chunk-VECUCVIY.js → chunk-PKWMJIBM.js} +1 -1
  20. package/dist/{chunk-BUZKNZ45.js → chunk-UT4FACHN.js} +5 -3
  21. package/dist/chunk-V3GQEUYI.js +16 -0
  22. package/dist/{chunk-FEOST3GF.js → chunk-VK5T7ULK.js} +1 -1
  23. package/dist/{chunk-C7UDUHQZ.js → chunk-WV3ZKUF4.js} +22 -20
  24. package/dist/{chunk-Y5YDL3MC.js → chunk-X5IVIOGL.js} +1 -1
  25. package/dist/{receivable-AE44YIJO.js → chunk-XN5TUZOT.js} +2 -3
  26. package/dist/cli.js +148 -9
  27. package/dist/{commands-K6DQ3O35.js → commands-PG5VVBKO.js} +1 -1
  28. package/dist/{commands-MLYGGSUE.js → commands-RCDYCU6L.js} +3 -3
  29. package/dist/{company-3KUWW7QA.js → company-4Z4JJVA7.js} +2 -2
  30. package/dist/{completion-6R5D5TQQ.js → completion-EFGQJDIU.js} +1 -1
  31. package/dist/{contract-FGRHTOGI.js → contract-BQ76SGWV.js} +1 -1
  32. package/dist/{department-PN5DCCRL.js → department-YHZRSWLB.js} +1 -1
  33. package/dist/deposit-U4AVQH5O.js +4 -0
  34. package/dist/estimate-U2K7DPGH.js +173 -0
  35. package/dist/{inquiry-3VOJASJH.js → inquiry-5D4U6CLU.js} +1 -1
  36. package/dist/{invoice-KY3BYTHQ.js → invoice-2VLK2BFV.js} +50 -49
  37. package/dist/{job-title-EM6RKGQ6.js → job-title-G7MIYWVA.js} +1 -1
  38. package/dist/{knowledge-F4FZ4MLH.js → knowledge-7QDC775Q.js} +1 -1
  39. package/dist/{leave-D2S7NMJC.js → leave-GHFJOGNC.js} +1 -1
  40. package/dist/{media-SQVQVX2E.js → media-XO6X3UQT.js} +1 -1
  41. package/dist/{notification-NTFUPUMY.js → notification-SUSR5NGQ.js} +1 -1
  42. package/dist/{oneshot-TMGTEN3S.js → oneshot-UGYF2PLB.js} +1 -1
  43. package/dist/{position-D52LXRDT.js → position-UY33ETLX.js} +1 -1
  44. package/dist/{prospect-AQ7EUU4N.js → prospect-G426O6XL.js} +1 -1
  45. package/dist/purchase-3GGAQRE6.js +214 -0
  46. package/dist/receivable-TNH4KCUO.js +4 -0
  47. package/dist/{registry-3WV46K26.js → registry-ODJB7AS3.js} +1 -1
  48. package/dist/{render-MTSSHDAZ.js → render-F4MRN2FQ.js} +1 -1
  49. package/dist/{report-TI2DOJGX.js → report-UC2PCK7B.js} +1 -1
  50. package/dist/run-GDYEOQQK.js +4 -0
  51. package/dist/sales-master-ORLR5VK4.js +71 -0
  52. package/dist/sales-numbering-MBFKVR2C.js +4 -0
  53. package/dist/supplier-payment-AFJ7G6AP.js +110 -0
  54. package/dist/{task-VKVZSF7J.js → task-S3BBBELE.js} +2 -2
  55. package/dist/{user-KEFI7XZI.js → user-O7H5PD4N.js} +1 -1
  56. package/dist/{workflow-4FHTOQZZ.js → workflow-2YL2OF2Y.js} +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-TLN3JSEC.js +0 -7
  59. package/dist/chunk-UVUVEL3B.js +0 -3
  60. package/dist/deposit-XQER6PMG.js +0 -4
  61. package/dist/estimate-IXBEQVGI.js +0 -164
  62. package/dist/run-KNZ43HFF.js +0 -4
@@ -0,0 +1,70 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ import{salesAdminForbidden}from"./chunk-7ACENLLZ.js";import{featureLicenseGuidance,licenseForbidden}from"./chunk-BZ7ULFR3.js";import{repeatedValues}from"./chunk-IOGVQVGD.js";import{booleanText,boundedText}from"./chunk-UDPJ2IGK.js";import{SALES_ESTIMATE_FORMATS_PATH,SALES_ESTIMATE_NO_RULES_PATH,SALES_INVOICE_NO_RULES_PATH,SALES_PURCHASE_NO_RULES_PATH,SALES_ROUNDING_SETTING_PATH,isExactNumericId}from"./chunk-BZAXQOLB.js";import{LIST_PAGING_HELP,PAGE_NUMBER_LIST_FLAGS,
4
+ nonEmpty,pageNumberPaging,pageNumberQuery,pageRangeNotes}from"./chunk-5R4SEO3I.js";import{requireResolved,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var INT_MAX=2147483647;var MEMBER_FORBIDDEN=licenseForbidden(featureLicenseGuidance("\u8CA9\u58F2\u7BA1\u7406"));function envelope(body,what){if(!isRecord(body)||body["result"]!==true)throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306E\u5F62\u304C\u60F3\u5B9A\u3068\u9055\u3044\u307E\u3059\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return body}function recordOf(body,what){const data=envelope(body,what)["data"];if(!isRecord(data)||typeof data["id"]!==
5
+ "string")throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data.id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return data}function serverMessage(body){const message=isRecord(body)?body["message"]:void 0;return typeof message==="string"&&message!==""?[message]:[]}function text(value){return typeof value==="string"||typeof value==="number"?String(value):""}function integerValue(flag,raw,min,max=INT_MAX){const trimmed=raw.
6
+ trim();const value=/^\d+$/.test(trimmed)?Number(trimmed):Number.NaN;if(!Number.isSafeInteger(value)||value<min||value>max)throw new UsageError(`${flag} \u306F ${min} \u4EE5\u4E0A ${max} \u4EE5\u4E0B\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`);return value}var RULE_COLUMNS=["id","rule_name","prefix","digit_count","current_number","count_up_num","next_number","sort_order"];function nextNumber(rule,purchaseFormat){const current=rule["current_number"];const step=rule["\
7
+ count_up_num"]??1;const digits=rule["digit_count"];if(typeof current!=="number"||typeof step!=="number"||typeof digits!=="number")return void 0;const width=purchaseFormat&&digits===0?4:digits;const padded=String(current+step).padStart(width,"0");const prefix=rule["prefix"];if(purchaseFormat)return`${prefix===null||prefix===void 0?"2000":text(prefix)}${padded}`;return typeof prefix==="string"&&prefix!==""&&prefix!=="0"?`${prefix}${padded}`:padded}function withNext(spec,row){const next=nextNumber(
8
+ row,spec.purchaseFormat);return next===void 0?row:{...row,next_number:next}}function ruleUsage(spec,op){return`twp ${spec.parent} no-rule ${op} help`}function ruleIdArg(spec,input,op){const[raw,...rest]=input.args;const id=raw?.trim()??"";if(id==="")throw new UsageError(`${spec.label}\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,ruleUsage(spec,op));if(rest.length>0)throw new UsageError(`\u4F59\u5206\u306A\u5F15\u6570\u304C\u3042\u308A\u307E\u3059: ${rest.join(" ")}`,ruleUsage(
9
+ spec,op));if(!isExactNumericId(id))throw new UsageError(`${spec.label}\u306E ID \u306F\u5148\u982D\u306B 0 \u3092\u4ED8\u3051\u306A\u3044\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,`ID \u306F twp ${spec.parent} no-rule list \u306E id \u5217\u3067\u3059\u3002`);return id}function ruleFlags(spec){return[{name:"--name",summary:"\u30EB\u30FC\u30EB\u540D\uFF08100 \u6587\u5B57\u307E\u3067\u30FB\u4F5C\u6210\u3067\u306F\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u30EB\u30FC\u30EB\u540D\
10
+ >"},{name:"--prefix",summary:`\u756A\u53F7\u306E\u524D\u306B\u4ED8\u3051\u308B\u6587\u5B57\uFF0820 \u6587\u5B57\u307E\u3067${spec.prefixDefault===null?"":`\u30FB\u4F5C\u6210\u3067\u7701\u304F\u3068 ${spec.prefixDefault}`}\uFF09`,takesValue:true,placeholder:"<\u6587\u5B57>"},{name:"--digit-count",summary:"\u9023\u756A\u306E\u6841\u6570\uFF081\u301C10\u30FB\u30BC\u30ED\u57CB\u3081\u3002\u4F5C\u6210\u3067\u306F\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u6841\u6570>"},{name:"--current-number",
11
+ summary:"\u4ECA\u306E\u9023\u756A\uFF080 \u4EE5\u4E0A\u3002\u6B21\u306E\u756A\u53F7\u306F\u3053\u308C\uFF0B\u5897\u5206\u3002\u4F5C\u6210\u3067\u7701\u304F\u3068 0\uFF09",takesValue:true,placeholder:"<\u6574\u6570>"},{name:"--count-up-num",summary:"1\u56DE\u306E\u63A1\u756A\u3067\u9032\u3081\u308B\u6570\uFF081 \u4EE5\u4E0A\u3002\u4F5C\u6210\u3067\u7701\u304F\u3068 1\uFF09",takesValue:true,placeholder:"<\u6574\u6570>"},{name:"--sort",summary:"\u8868\u793A\u9806\uFF080 \u4EE5\u4E0A\u306E\u6574\u6570\u30FB\u5C0F\u3055\u3044\u307B\u3069\u4E0A\uFF09",
12
+ takesValue:true,placeholder:"<\u6574\u6570>"},...spec.hasActive?[{name:"--active",summary:"\u6709\u52B9\u304B\uFF08true / false\uFF09",takesValue:true,placeholder:"<true|false>"}]:[]]}function ruleClearFlag(spec){const effect=spec.purchaseFormat?"\u4ED5\u5165\u306F\u7A7A\u306B\u3059\u308B\u3068\u65E2\u5B9A\u306E 2000 \u304C\u4ED8\u304D\u307E\u3059":"\u756A\u53F7\u306E\u524D\u306B\u4F55\u3082\u4ED8\u3051\u306A\u3044";return{name:"--clear",summary:`\u9805\u76EE\u3092\u7A7A\u306B\u3059\u308B\uFF08prefix \u3060\u3051\u30FB${effect}\
13
+ \uFF09`,takesValue:true,placeholder:"<\u9805\u76EE>",repeatable:true}}function ruleBody(spec,input,op){const body={};const name=boundedText(input,"--name",{maxChars:100,label:"\u30EB\u30FC\u30EB\u540D"});if(name!==void 0)body["rule_name"]=name;const rawPrefix=input.flags.get("--prefix");if(rawPrefix!==void 0){const prefix=rawPrefix.trim();if([...prefix].length>20)throw new UsageError(`--prefix \u304C\u9577\u3059\u304E\u307E\u3059\uFF08${[...prefix].length} \u6587\u5B57\u30FB\u4E0A\u9650 20 \u6587\u5B57\uFF09`);
14
+ body["prefix"]=prefix===""?null:prefix}const digits=input.flags.get("--digit-count");if(digits!==void 0)body["digit_count"]=integerValue("--digit-count",digits,1,10);const current=input.flags.get("--current-number");if(current!==void 0)body["current_number"]=integerValue("--current-number",current,0);const step=input.flags.get("--count-up-num");if(step!==void 0)body["count_up_num"]=integerValue("--count-up-num",step,1);const sort=input.flags.get("--sort");if(sort!==void 0)body["sort_order"]=integerValue(
15
+ "--sort",sort,0);const active=spec.hasActive?input.flags.get("--active"):void 0;if(active!==void 0)body["is_active"]=booleanText("--active",active);if(op==="update"){for(const raw of repeatedValues(input,"--clear")){if(raw.trim()!=="prefix")throw new UsageError(`--clear \u306B\u300C${raw}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,"\u7A7A\u306B\u3067\u304D\u308B\u9805\u76EE: prefix\uFF08\u6841\u6570\u30FB\u9023\u756A\u30FB\u5897\u5206\u30FB\u8868\u793A\u9806\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093\uFF09");
16
+ if(rawPrefix!==void 0)throw new UsageError("prefix \u306B\u5024\u3068 --clear \u306E\u4E21\u65B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059","\u3069\u3061\u3089\u304B\u4E00\u65B9\u3060\u3051\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002");body["prefix"]=null}}return body}function parsedOf(input,key){return JSON.parse(requireResolved(input,key))}function describeRule(spec,rule){const next=nextNumber(rule,spec.purchaseFormat);return`ID ${text(rule["id"])}\u30FB${text(rule["\
17
+ rule_name"])}${next===void 0?"":`\uFF08\u6B21\u306E\u756A\u53F7 ${next}\uFF09`}`}async function formatsUsing(spec,ctx,id){if(spec.formatKey===void 0)return{names:[],partial:false};const body=await ctx.resolver.salesJson(`${SALES_ESTIMATE_FORMATS_PATH}?page_limit=100&page_no=1`,"\u898B\u7A4D\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u4E00\u89A7");const list=Array.isArray(body["list"])?body["list"].filter(isRecord):[];const names=list.filter(row=>row[spec.formatKey]===id).map(row=>`ID ${text(row["id"])}\
18
+ \u300C${text(row["format_name"])}\u300D`);const pageSum=body["page_sum"];return{names,partial:typeof pageSum==="number"&&pageSum>1}}var RULE_LIST_ORDER_HELP=" \u26A0 \u3053\u306E\u4E00\u89A7\u306F\u30DA\u30FC\u30B8\u756A\u53F7\u3067\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\uFF08--cursor \u306F\u30DA\u30FC\u30B8\u756A\u53F7\u3067\u3059\uFF09\u3002\n \u4E26\u3073\u306F\u8868\u793A\u9806\uFF08--sort \u306E\u5024\uFF09\u306E\u5C0F\u3055\u3044\u9806\u30FB\u540C\u3058\u306A\u3089 ID \u306E\u9806\u306B\u30B5\u30FC\u30D0\u304C\u56FA\u5B9A\u3057\u3066\u3044\u307E\u3059\u3002\u8FBF\u3063\u3066\u3044\u308B\u6700\u4E2D\u306B\u30C7\u30FC\u30BF\u304C\u5897\u6E1B\u3059\u308B\u3068\u3001\u53D6\u308A\u3053\u307C\u3057\u30FB\u91CD\u8907\u304C\u8D77\u3053\u308A\u5F97\u307E\u3059\u3002";
19
+ function ruleAbout(spec){return`${spec.label}\u306F\u3001${spec.document}\u3092\u4F5C\u308B\u3068\u304D\u306B\u632F\u308B\u756A\u53F7\u306E\u6C7A\u307E\u308A\u3067\u3059\u3002\u6B21\u306E\u756A\u53F7\u306F\u300C\u4ECA\u306E\u9023\u756A\uFF08current_number\uFF09\uFF0B\u5897\u5206\uFF08count_up_num\uFF09\u300D\u3092
20
+ \u6841\u6570\uFF08digit_count\uFF09\u3067\u30BC\u30ED\u57CB\u3081\u3057\u3001\u524D\u306B prefix \u3092\u4ED8\u3051\u305F\u3082\u306E\u3067\u3059\uFF08next_number \u5217\uFF09\u3002`+(spec.formatKey===void 0?"":`
21
+ \u898B\u7A4D\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\uFF08twp estimate format\uFF09\u304C\u65E2\u5B9A\u306E\u30EB\u30FC\u30EB\u3092 ${spec.formatKey} \u3067\u9078\u3073\u307E\u3059\u3002`)}function ruleListOperation(spec){const paging=pageNumberPaging({label:`${spec.label}\u4E00\u89A7`});const rows=body=>{envelope(body,`${spec.label}\u4E00\u89A7`);return paging.items(body).map(row=>{if(!isRecord(row))throw new ApiResponseError(`${spec.label}\u4E00\u89A7\u306E\u884C\u306E\u5F62\u304C\u60F3\u5B9A\u3068\u9055\u3044\u307E\u3059\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
22
+ return withNext(spec,row)})};return{name:"list",summary:`${spec.label}\u3092\u4E00\u89A7\u3059\u308B\uFF08\u8868\u793A\u9806\u30FB\u6B21\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7\u3064\u304D\uFF09`,usage:`twp ${spec.parent} no-rule list [--keyword <\u8A9E>] [--all] [--limit <\u4EF6\u6570>]`,description:`${ruleAbout(spec)}
23
+
24
+ --keyword \u306F\u30EB\u30FC\u30EB\u540D\u3068 prefix \u306E\u90E8\u5206\u4E00\u81F4\u3067\u3059\u3002
25
+ next_number \u306F CLI \u304C\u30B5\u30FC\u30D0\u306E\u63A1\u756A\u306E\u5F0F\u3067\u8A08\u7B97\u3057\u305F\u5024\u3067\u3059\uFF08--output json \u306B\u3082\u8DB3\u3057\u307E\u3059\uFF09\u3002
26
+ --output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${[...RULE_COLUMNS,...spec.hasActive?["is_active"]:[]].join(" / ")}\uFF09\u3067\u3059\u3002
27
+
28
+ `+LIST_PAGING_HELP+"\n"+RULE_LIST_ORDER_HELP,flags:[...PAGE_NUMBER_LIST_FLAGS,{name:"--keyword",summary:"\u30EB\u30FC\u30EB\u540D\u30FBprefix \u306E\u90E8\u5206\u4E00\u81F4\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u8A9E>"}],paging,forbidden:MEMBER_FORBIDDEN,prepare:async input=>{if(input.args.length>0)throw new UsageError(`list \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,ruleUsage(spec,"list"));pageNumberQuery(input);return input},
29
+ plan:input=>{const{page_no,page_limit}=pageNumberQuery(input);return{method:"GET",path:spec.path,query:{keyword:nonEmpty(input.flags,"--keyword"),page_limit,page_no}}},summarize:body=>rows(body).map(row=>pick(row,[...RULE_COLUMNS,...spec.hasActive?["is_active"]:[]])),raw:rows,notes:body=>{const sum=isRecord(body)?body["sum"]:void 0;return[...pageRangeNotes(body),...typeof sum==="number"?[`\u8A72\u5F53 ${sum} \u4EF6`]:[]]}}}function ruleRecord(spec,body){return withNext(spec,recordOf(body,spec.label))}
30
+ function ruleGetColumns(spec){return[...RULE_COLUMNS,...spec.hasActive?["is_active"]:[],"updated_at"]}function noRuleResource(spec){const writeForbidden=spec.writeLevel==="admin"?salesAdminForbidden(`${spec.label}\u306E\u4F5C\u6210\u30FB\u66F4\u65B0\u30FB\u524A\u9664`):MEMBER_FORBIDDEN;const deleteForbidden=salesAdminForbidden(`${spec.label}\u306E\u524A\u9664`);const flags=ruleFlags(spec);const confirmation=`\u4EE5\u5F8C\u306B\u767A\u884C\u3055\u308C\u308B${spec.document}\u306E\u756A\u53F7\u3092\u5909\u3048\u308B\u64CD\u4F5C`;
31
+ const getOperation={name:"get",summary:`${spec.label}1\u4EF6\u306E\u8A73\u7D30\u3092\u8868\u793A\u3059\u308B\uFF08\u6B21\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7\u3064\u304D\uFF09`,usage:`twp ${spec.parent} no-rule get <\u30EB\u30FC\u30EBID>`,description:`ID \u306F twp ${spec.parent} no-rule list \u306E id \u5217\u306E\u6570\u5B57\u3067\u3059\u3002next_number \u306F CLI \u304C\u8A08\u7B97\u3057\u305F\u6B21\u306E\u756A\u53F7\u3067\u3059\u3002`,flags:[],forbidden:MEMBER_FORBIDDEN,plan:input=>({
32
+ method:"GET",path:`${spec.path}/${ruleIdArg(spec,input,"get")}`}),summarize:body=>pick(ruleRecord(spec,body),ruleGetColumns(spec)),raw:body=>ruleRecord(spec,body)};const createOperation={name:"create",summary:`${spec.label}\u3092\u767B\u9332\u3059\u308B\uFF08--name \u3068 --digit-count \u304C\u5FC5\u9808${spec.writeLevel==="admin"?"\u30FB\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005":""}\uFF09`,usage:`twp ${spec.parent} no-rule create --name <\u30EB\u30FC\u30EB\u540D> --digit-count <\u6841\u6570> [--prefix <\u6587\u5B57>] [--curren\
33
+ t-number <\u6574\u6570>] [--count-up-num <\u6574\u6570>] [--sort <\u6574\u6570>]${spec.hasActive?" [--active true|false]":""}`,description:`POST ${spec.path.replace("/api","")}\u3002
34
+
35
+ ${ruleAbout(spec)}
36
+
37
+ \u9001\u308B\u524D\u306B\u3001\u3053\u306E\u30EB\u30FC\u30EB\u3067\u6700\u521D\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002`,flags,forbidden:writeForbidden,prepare:async input=>{if(input.args.length>0)throw new UsageError(`create \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,ruleUsage(spec,"create"));const missing=["--name","--digit-count"].filter(
38
+ flag=>!input.flags.has(flag));if(missing.length>0)throw new UsageError(`${spec.label}\u306E\u767B\u9332\u306B\u306F ${missing.join(" / ")} \u304C\u8981\u308A\u307E\u3059`,ruleUsage(spec,"create"));return withResolved(input,{body:JSON.stringify(ruleBody(spec,input,"create"))})},plan:input=>({method:"POST",path:spec.path,body:parsedOf(input,"body")}),execute:async(input,ctx)=>{const created=await ctx.send({method:"POST",path:spec.path,body:parsedOf(input,"body")});const id=text(recordOf(created,spec.
39
+ label)["id"]);const fresh=await ctx.send({method:"GET",path:`${spec.path}/${id}`});return{...isRecord(fresh)?fresh:{},message:isRecord(created)?created["message"]:void 0}},plannedNotes:input=>{const body=parsedOf(input,"body");const first=nextNumber({current_number:0,count_up_num:1,prefix:spec.prefixDefault,...body},spec.purchaseFormat);return first===void 0?[]:[`\u3053\u306E\u30EB\u30FC\u30EB\u3067\u6700\u521D\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7: ${first}`]},summarize:body=>pick(ruleRecord(
40
+ spec,body),ruleGetColumns(spec)),raw:body=>ruleRecord(spec,body),notes:serverMessage};const updateOperation={name:"update",summary:`${spec.label}\u3092\u66F8\u304D\u63DB\u3048\u308B\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u30FB--yes \u304C\u8981\u308B\uFF09`,usage:`twp ${spec.parent} no-rule update <\u30EB\u30FC\u30EBID> [\u9805\u76EE\u2026] [--clear prefix] --yes`,description:`PUT ${spec.path.replace("/api","")}/{id}\u3002\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u9001\u308A\u307E\u3059\uFF08\u6307\u5B9A\u3057\u306A\u304B\u3063\u305F\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002
41
+ \u26A0\uFE0F \u4EE5\u5F8C\u306B\u767A\u884C\u3055\u308C\u308B${spec.document}\u306E\u756A\u53F7\u304C\u5909\u308F\u308A\u307E\u3059\u3002--current-number \u3092\u4ECA\u3088\u308A\u5C0F\u3055\u304F\u3059\u308B\u3068\u3001\u767A\u884C\u6E08\u307F\u3068\u540C\u3058\u756A\u53F7\u304C\u518D\u3073\u632F\u3089\u308C\u307E\u3059\u3002
42
+ \u9001\u308B\u524D\u306B\u4ECA\u306E\u5024\u3092\u8AAD\u307F\u3001\u6B21\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7\u3092\u5909\u66F4\u524D\u30FB\u5909\u66F4\u5F8C\u3067 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\u3002--dry-run \u306F --yes \u7121\u3057\u3067\u4F7F\u3048\u307E\u3059\uFF09\u3002
43
+ \u7A7A\u306B\u3067\u304D\u308B\u306E\u306F prefix \u3060\u3051\u3067\u3059\uFF08--clear prefix${spec.purchaseFormat?"\u3002\u4ED5\u5165\u306F\u7A7A\u306B\u3059\u308B\u3068\u65E2\u5B9A\u306E 2000 \u304C\u4ED8\u304D\u3001prefix \u306A\u3057\u306B\u306F\u3067\u304D\u307E\u305B\u3093":""}\uFF09\u3002\u6841\u6570\u30FB\u9023\u756A\u30FB\u5897\u5206\u30FB\u8868\u793A\u9806\u306F\u30B5\u30FC\u30D0\u306E\u5217\u304C\u7A7A\u3092\u53D7\u3051\u307E\u305B\u3093\u3002--prefix \u306E\u524D\u5F8C\u306E\u7A7A\u767D\u306F\u30B5\u30FC\u30D0\u3068\u540C\u3058\u304F\u843D\u3068\u3057\u307E\u3059\u3002`,
44
+ destructive:true,confirmation,flags:[...flags,ruleClearFlag(spec)],forbidden:writeForbidden,prepare:async(input,ctx)=>{const id=ruleIdArg(spec,input,"update");const body=ruleBody(spec,input,"update");if(Object.keys(body).length===0)throw new UsageError("\u66F8\u304D\u63DB\u3048\u308B\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093",ruleUsage(spec,"update"));const current=await ctx.resolver.salesRecord(spec.kind,id,"<\u30EB\u30FC\u30EBID>");return withResolved(input,{body:JSON.stringify(body),current:JSON.
45
+ stringify(current)})},plan:input=>({method:"PUT",path:`${spec.path}/${ruleIdArg(spec,input,"update")}`,body:parsedOf(input,"body")}),plannedNotes:input=>{const current=parsedOf(input,"current");const before=nextNumber(current,spec.purchaseFormat);const after=nextNumber({...current,...parsedOf(input,"body")},spec.purchaseFormat);const lines=[`\u66F8\u304D\u63DB\u3048\u308B${spec.label}: ID ${text(current["id"])}\u30FB${text(current["rule_name"])}`];if(before!==void 0&&after!==void 0){lines.push(before===
46
+ after?`\u6B21\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7: ${before}\uFF08\u5909\u308F\u308A\u307E\u305B\u3093\uFF09`:`\u6B21\u306B\u767A\u884C\u3055\u308C\u308B\u756A\u53F7: ${before} \u2192 ${after}`)}return lines},summarize:body=>pick(ruleRecord(spec,body),ruleGetColumns(spec)),raw:body=>ruleRecord(spec,body),notes:serverMessage};const deleteOperation={name:"delete",summary:`${spec.label}\u3092\u524A\u9664\u3059\u308B\uFF08\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\u30FB--yes \u304C\u8981\u308B\uFF09`,
47
+ usage:`twp ${spec.parent} no-rule delete <\u30EB\u30FC\u30EBID> --yes`,description:`DELETE ${spec.path.replace("/api","")}/{id}\uFF08\u8AD6\u7406\u524A\u9664\uFF09\u3002\u767A\u884C\u6E08\u307F\u306E${spec.document}\u306F\u756A\u53F7\u3092\u81EA\u5206\u3067\u6301\u3063\u3066\u3044\u308B\u306E\u3067\u3001\u756A\u53F7\u306F\u6D88\u3048\u307E\u305B\u3093\u3002
48
+ `+(spec.formatKey===void 0?"\u4F7F\u7528\u4E2D\u3067\u3082\u30B5\u30FC\u30D0\u306F\u524A\u9664\u3092\u65AD\u308A\u307E\u305B\u3093\u3002\n":`\u898B\u7A4D\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u304C\u65E2\u5B9A\uFF08${spec.formatKey}\uFF09\u306B\u9078\u3093\u3067\u3044\u3066\u3082\u30B5\u30FC\u30D0\u306F\u524A\u9664\u3092\u65AD\u308A\u307E\u305B\u3093\u3002\u9001\u308B\u524D\u306B\u3001\u9078\u3093\u3067\u3044\u308B\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\u3002
49
+ `)+"\u9001\u308B\u524D\u306B\u5BFE\u8C61\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002",destructive:true,flags:[],forbidden:deleteForbidden,prepare:async(input,ctx)=>{const id=ruleIdArg(spec,input,"delete");const current=await ctx.resolver.salesRecord(spec.kind,id,"<\u30EB\u30FC\u30EBID>");const using=await formatsUsing(spec,ctx,id);return withResolved(input,{current:JSON.stringify(current),using:JSON.stringify(using)})},plan:input=>({method:"\
50
+ DELETE",path:`${spec.path}/${ruleIdArg(spec,input,"delete")}`}),plannedNotes:input=>{const using=parsedOf(input,"using");const lines=[`\u524A\u9664\u3059\u308B${spec.label}: ${describeRule(spec,parsedOf(input,"current"))}`];if(using.names.length>0){lines.push(`\u26A0\uFE0F \u6B21\u306E\u898B\u7A4D\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u304C\u3053\u306E\u30EB\u30FC\u30EB\u3092\u65E2\u5B9A\u306B\u9078\u3093\u3067\u3044\u307E\u3059: ${using.names.join(" / ")}\u3002\u9078\u3073\u76F4\u3059\u307E\u3067\u3001\u3053\u308C\u3089\u306E\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3067\u4F5C\u308B${spec.
51
+ document}\uFF08\u81EA\u52D5\u8ACB\u6C42\u3092\u542B\u3080\uFF09\u306B\u306F\u756A\u53F7\u304C\u632F\u3089\u308C\u307E\u305B\u3093\u3002twp estimate format update \u3067\u9078\u3073\u76F4\u3057\u3066\u304F\u3060\u3055\u3044`)}if(using.partial)lines.push("\uFF08\u898B\u7A4D\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u306F\u5148\u982D 100 \u4EF6\u3060\u3051\u3092\u78BA\u304B\u3081\u307E\u3057\u305F\uFF09");return lines},summarize:body=>acknowledgement(body,`${spec.label}\u524A\u9664`),raw:body=>acknowledgement(
52
+ body,`${spec.label}\u524A\u9664`)};return{name:"no-rule",summary:`${spec.label}\uFF08${spec.document}\u306E\u756A\u53F7\u306E\u632F\u308A\u65B9\u3002\u4E00\u89A7\u30FB\u8A73\u7D30\u30FB\u767B\u9332\u30FB\u66F4\u65B0\u30FB\u524A\u9664\uFF09`,operations:[ruleListOperation(spec),getOperation,createOperation,updateOperation,deleteOperation]}}var estimateNoRuleResource=noRuleResource({parent:"estimate",label:"\u898B\u7A4D\u756A\u53F7\u30EB\u30FC\u30EB",document:"\u898B\u7A4D",path:SALES_ESTIMATE_NO_RULES_PATH,
53
+ kind:"estimate-no-rule",writeLevel:"admin",hasActive:false,formatKey:"default_estimate_no_id",prefixDefault:null,purchaseFormat:false});var invoiceNoRuleResource=noRuleResource({parent:"invoice",label:"\u8ACB\u6C42\u756A\u53F7\u30EB\u30FC\u30EB",document:"\u8ACB\u6C42",path:SALES_INVOICE_NO_RULES_PATH,kind:"invoice-no-rule",writeLevel:"admin",hasActive:false,formatKey:"default_invoice_no_id",prefixDefault:null,purchaseFormat:false});var purchaseNoRuleResource=noRuleResource({parent:"purchase",label:"\
54
+ \u4ED5\u5165\u756A\u53F7\u30EB\u30FC\u30EB",document:"\u4ED5\u5165\uFF08\u6CE8\u6587\u66F8\uFF09",path:SALES_PURCHASE_NO_RULES_PATH,kind:"purchase-no-rule",writeLevel:"member",hasActive:true,prefixDefault:"2000",purchaseFormat:true});var ROUNDING_METHODS={round:"\u56DB\u6368\u4E94\u5165",ceil:"\u5207\u308A\u4E0A\u3052",floor:"\u5207\u308A\u6368\u3066"};function roundingMethod(raw){const value=raw.trim();const key=Object.hasOwn(ROUNDING_METHODS,value.toLowerCase())?value.toLowerCase():Object.keys(
55
+ ROUNDING_METHODS).find(k=>ROUNDING_METHODS[k]===value);if(key===void 0){throw new UsageError(`--method \u306B\u300C${raw}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u5024: ${Object.entries(ROUNDING_METHODS).map(([k,label])=>`${k}\uFF08${label}\uFF09`).join(" / ")}`)}return key}function roundingOf(body){const data=envelope(body,"\u7AEF\u6570\u51E6\u7406\u8A2D\u5B9A")["data"];if(!isRecord(data)||typeof data["rounding_method"]!=="string")throw new ApiResponseError(
56
+ "\u7AEF\u6570\u51E6\u7406\u8A2D\u5B9A\u306E\u5FDC\u7B54\u306B data.rounding_method \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");const method=data["rounding_method"];return{...data,rounding_method_label:Object.hasOwn(ROUNDING_METHODS,method)?ROUNDING_METHODS[method]:method}}var ROUNDING_COLUMNS=["rounding_method","rounding_method_label","updated_at","updated_by"];function roundingNotes(record){return record["updated_at"]===
57
+ null?["\u307E\u3060\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u65E2\u5B9A\u306E\u56DB\u6368\u4E94\u5165\u3067\u8A08\u7B97\u3057\u3066\u3044\u307E\u3059"]:[]}var ROUNDING_ABOUT="\u7AEF\u6570\u51E6\u7406\u306F\u3001\u898B\u7A4D\u30FB\u8ACB\u6C42\u30FB\u5951\u7D04\u30FB\u4ED5\u5165\u30FB\u652F\u6255\u306E\u91D1\u984D\uFF08\u7A0E\u984D\u306A\u3069\uFF09\u306E1\u5186\u672A\u6E80\u3092\u3069\u3046\u4E38\u3081\u308B\u304B\u306E\u30C6\u30CA\u30F3\u30C8\u306E\u8A2D\u5B9A\u3067\u3059\uFF08round\uFF1D\u56DB\u6368\u4E94\u5165 / ceil\uFF1D\u5207\u308A\u4E0A\u3052 / floor\uFF1D\u5207\u308A\u6368\u3066\uFF09\u3002\n\u5909\u3048\u308B\u3068\u3001\u3053\u308C\u4EE5\u964D\u306B\u4F5C\u308B\u5E33\u7968\u304B\u3089\u52B9\u304D\u307E\u3059\u3002\u4F5C\u6210\u6E08\u307F\u306E\u898B\u7A4D\u30FB\u8ACB\u6C42\u30FB\u5951\u7D04\u30FB\u4ED5\u5165\u306F\u4F5C\u3063\u305F\u6642\u70B9\u306E\u65B9\u5F0F\u3092\u6301\u3063\u3066\u3044\u308B\u306E\u3067\u3001\u91D1\u984D\u306F\u5909\u308F\u308A\u307E\u305B\u3093\u3002\n\u305F\u3060\u3057\u652F\u6255\u306F\u65B9\u5F0F\u3092\u6301\u305F\u305A\u3001\u91D1\u984D\u30FB\u7A0E\u7387\u3092\u66F8\u304D\u63DB\u3048\u308B\u305F\u3073\u306B\u305D\u306E\u6642\u70B9\u306E\u65B9\u5F0F\u3067\u7A0E\u629C\u984D\u3092\u8A08\u7B97\u3057\u76F4\u3057\u307E\u3059\u3002";
58
+ var roundingGet={name:"get",summary:"\u7AEF\u6570\u51E6\u7406\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3059\u308B",usage:"twp rounding-setting get",description:`GET /api/v2/sales/rounding-setting\u3002\u8CA9\u58F2\u7BA1\u7406\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u304C\u4F7F\u3048\u307E\u3059\u3002
59
+
60
+ ${ROUNDING_ABOUT}`,flags:[],forbidden:MEMBER_FORBIDDEN,plan:input=>{if(input.args.length>0)throw new UsageError(`get \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,"twp rounding-setting get help");return{method:"GET",path:SALES_ROUNDING_SETTING_PATH}},summarize:body=>pick(roundingOf(body),ROUNDING_COLUMNS),raw:roundingOf,notes:body=>roundingNotes(roundingOf(body))};var roundingUpdate={name:"update",summary:"\u7AEF\u6570\u51E6\u7406\u306E\u65B9\u5F0F\u3092\u5909\u3048\u308B\uFF08\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\u30FB--yes \u304C\u8981\u308B\uFF09",
61
+ usage:"twp rounding-setting update --method <round|ceil|floor> --yes",description:`PUT /api/v2/sales/rounding-setting\uFF08\u307E\u3060\u8A2D\u5B9A\u304C\u7121\u3051\u308C\u3070\u4F5C\u3089\u308C\u307E\u3059\uFF09\u3002\u8CA9\u58F2\u7BA1\u7406\u306E\u300C\u7BA1\u7406\u8005\u300D\u3060\u3051\u304C\u4F7F\u3048\u307E\u3059\u3002
62
+
63
+ ${ROUNDING_ABOUT}
64
+
65
+ --method \u306F round / ceil / floor \u306E\u307B\u304B\u3001\u56DB\u6368\u4E94\u5165 / \u5207\u308A\u4E0A\u3052 / \u5207\u308A\u6368\u3066 \u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
66
+ \u9001\u308B\u524D\u306B\u4ECA\u306E\u65B9\u5F0F\u3092\u8AAD\u307F\u3001\u5909\u66F4\u524D\u30FB\u5909\u66F4\u5F8C\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\u3002--dry-run \u306F --yes \u7121\u3057\u3067\u4F7F\u3048\u307E\u3059\uFF09\u3002`,destructive:true,confirmation:"\u4EE5\u5F8C\u306B\u4F5C\u308B\u898B\u7A4D\u30FB\u8ACB\u6C42\u30FB\u5951\u7D04\u30FB\u4ED5\u5165\u30FB\u652F\u6255\u306E\u91D1\u984D\u306E\u4E38\u3081\u3092\u5909\u3048\u308B\u64CD\u4F5C",
67
+ flags:[{name:"--method",summary:"\u7AEF\u6570\u51E6\u7406\u306E\u65B9\u5F0F\uFF08round / ceil / floor\u30FB\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u65B9\u5F0F>"}],forbidden:salesAdminForbidden("\u7AEF\u6570\u51E6\u7406\u306E\u5909\u66F4"),prepare:async(input,ctx)=>{if(input.args.length>0)throw new UsageError(`update \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,"twp rounding-setting update help");const raw=input.flags.get("--method");if(raw===
68
+ void 0)throw new UsageError("--method \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","twp rounding-setting update help");const method=roundingMethod(raw);const current=roundingOf(await ctx.resolver.salesJson(SALES_ROUNDING_SETTING_PATH,"\u7AEF\u6570\u51E6\u7406\u8A2D\u5B9A"));return withResolved(input,{method,current:JSON.stringify(current)})},plan:input=>({method:"PUT",path:SALES_ROUNDING_SETTING_PATH,body:{rounding_method:requireResolved(input,"method")}}),plannedNotes:input=>{const current=parsedOf(
69
+ input,"current");const before=text(current["rounding_method"]);const after=requireResolved(input,"method");const label=key=>`${key}\uFF08${Object.hasOwn(ROUNDING_METHODS,key)?ROUNDING_METHODS[key]:key}\uFF09`;return[before===after?`\u7AEF\u6570\u51E6\u7406: ${label(before)}\uFF08\u5909\u308F\u308A\u307E\u305B\u3093\uFF09`:`\u7AEF\u6570\u51E6\u7406: ${label(before)} \u2192 ${label(after)}`,...current["updated_at"]===null?["\u4ECA\u306F\u307E\u3060\u8A2D\u5B9A\u304C\u7121\u304F\u65E2\u5B9A\u306E\u56DB\u6368\u4E94\u5165\u3067\u3059\u3002\u9001\u308B\u3068\u8A2D\u5B9A\u304C\u4F5C\u3089\u308C\u307E\u3059"]:
70
+ []]},summarize:body=>pick(roundingOf(body),ROUNDING_COLUMNS),raw:roundingOf,notes:serverMessage};var roundingSettingDomain={name:"rounding-setting",summary:"\u8CA9\u58F2\u7BA1\u7406\u306E\u7AEF\u6570\u51E6\u7406\uFF08\u898B\u7A4D\u30FB\u8ACB\u6C42\u30FB\u5951\u7D04\u30FB\u4ED5\u5165\u30FB\u652F\u6255\u306E\u91D1\u984D\u306E\u4E38\u3081\u65B9\u3002\u8868\u793A\u3068\u5909\u66F4\uFF09",operations:[roundingGet,roundingUpdate]};export{nextNumber,estimateNoRuleResource,invoiceNoRuleResource,purchaseNoRuleResource,roundingSettingDomain};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{contentTypeFor,inspectLocalFile,issued}from"./chunk-VECUCVIY.js";import{checkUploadQuota}from"./chunk-DDKZ5IPT.js";import{createFlags,fieldBody,hasAnyField,updateFlags}from"./chunk-MHRGKUMK.js";import{readCsvFileText}from"./chunk-I6DWJXPC.js";import{featureLicenseGuidance}from"./chunk-RZ54TCQU.js";import{CUSTOMERS_PATH,SALES_COMPANIES_PATH,isExactNumericId}from"./chunk-ELXDRPDV.js";import{ApiError,errorListMessages}from"./chunk-IF2K4PM5.js";import{
3
+ import{createFlags,fieldBody,hasAnyField,updateFlags}from"./chunk-BPCK5RAB.js";import{contentTypeFor,inspectLocalFile,issued}from"./chunk-PKWMJIBM.js";import{checkUploadQuota}from"./chunk-DDKZ5IPT.js";import{readCsvFileText}from"./chunk-I6DWJXPC.js";import{featureLicenseGuidance}from"./chunk-BZ7ULFR3.js";import{CUSTOMERS_PATH,SALES_COMPANIES_PATH,isExactNumericId}from"./chunk-BZAXQOLB.js";import{ApiError,errorListMessages}from"./chunk-IF2K4PM5.js";import{
4
4
  isSafePathSegment}from"./chunk-GMBJTG6A.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";import{requireResolved,singleRef,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiRejectedError,ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";import fs from"fs";import path from"path";function levelForbidden(licenseGuidance,levelGuidance){return body=>body?.error==="permission_denied"?licenseGuidance:levelGuidance}var COMPANY_LICENSE="\u53D6\u5F15\u5148\u3092\u6271\u3046\u306B\u306F\u8CA9\u58F2\u7BA1\u7406\u304B\u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u304C\u3001\u3069\u3061\u3089\u3082\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u304C\u3069\u3061\u3089\u3082\u5951\u7D04\u3057\u3066\u3044\u306A\u3044\u304B\u3001\u3042\u306A\u305F\u306E\u6A29\u9650\u304C\u3069\u3061\u3089\u3082\u300C\u306A\u3057\u300D\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
5
5
  var CUSTOMER_LICENSE=featureLicenseGuidance("\u9867\u5BA2\u7BA1\u7406");var COMPANY_WRITE_FORBIDDEN=levelForbidden(COMPANY_LICENSE,"\u9867\u5BA2\u306E\u4F5C\u6210\u30FB\u66F4\u65B0\u306B\u306F\u3001\u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7DE8\u96C6\u8005\u300D\u4EE5\u4E0A\u304B\u3001\u8CA9\u58F2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u30E1\u30F3\u30D0\u30FC\u300D\u4EE5\u4E0A\u306E\u3069\u3061\u3089\u304B\u304C\u8981\u308A\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
6
6
  var LEVEL_LABELS={admin:"\u7BA1\u7406\u8005",editor:"\u7DE8\u96C6\u8005",viewer:"\u95B2\u89A7\u8005",none:"\u306A\u3057"};var CHILD_DELETE_NEEDS="\u62C5\u5F53\u8005\u30FB\u5BFE\u5FDC\u5C65\u6B74\u306E\u524A\u9664\u306B\u306F\u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7BA1\u7406\u8005\u300D\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059";var CUSTOMER_DELETE_FORBIDDEN=levelForbidden(COMPANY_LICENSE,"\u9867\u5BA2\u306E\u524A\u9664\u306B\u306F\u3001\u4F01\u696D\u306E\u524A\u9664\u306B\u9867\u5BA2\u7BA1\u7406\u306E\u300C\u7BA1\u7406\u8005\u300D\u304B\u8CA9\u58F2\u7BA1\u7406\u306E\u300C\u30E1\u30F3\u30D0\u30FC\u300D\u4EE5\u4E0A\u3001\u62C5\u5F53\u8005\u30FB\u5BFE\u5FDC\u5C65\u6B74\u306E\u524A\u9664\u306B\u9867\u5BA2\u7BA1\u7406\u306E\u300C\u7BA1\u7406\u8005\u300D\u304C\u8981\u308A\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\
@@ -0,0 +1,8 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ var LOADERS={"agent-loop":async()=>(await import("./agent-loop-4U5RLC4L.js")).agentLoopDomain,attendance:async()=>(await import("./attendance-5KE2JPK4.js")).attendanceDomain,backlog:async()=>(await import("./backlog-ISEIWKMQ.js")).backlogDomain,"business-place":async()=>(await import("./sales-master-ORLR5VK4.js")).businessPlaceDomain,company:async()=>(await import("./company-4Z4JJVA7.js")).companyDomain,contract:async()=>(await import("./contract-BQ76SGWV.js")).contractDomain,customer:async()=>(await import("./company-4Z4JJVA7.js")).
4
+ customerDomain,department:async()=>(await import("./department-YHZRSWLB.js")).departmentDomain,deposit:async()=>(await import("./deposit-U4AVQH5O.js")).depositDomain,estimate:async()=>(await import("./estimate-U2K7DPGH.js")).estimateDomain,inquiry:async()=>(await import("./inquiry-5D4U6CLU.js")).inquiryDomain,invoice:async()=>(await import("./invoice-2VLK2BFV.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-G7MIYWVA.js")).jobTitleDomain,leave:async()=>(await import("./leave-GHFJOGNC.js")).
5
+ leaveDomain,media:async()=>(await import("./media-XO6X3UQT.js")).mediaDomain,meeting:async()=>(await import("./knowledge-7QDC775Q.js")).meetingDomain,note:async()=>(await import("./knowledge-7QDC775Q.js")).noteDomain,notification:async()=>(await import("./notification-SUSR5NGQ.js")).notificationDomain,payee:async()=>(await import("./sales-master-ORLR5VK4.js")).payeeDomain,position:async()=>(await import("./position-UY33ETLX.js")).positionDomain,project:async()=>(await import("./project-ZGOB5W25.js")).
6
+ projectDomain,prospect:async()=>(await import("./prospect-G426O6XL.js")).prospectDomain,purchase:async()=>(await import("./purchase-3GGAQRE6.js")).purchaseDomain,receivable:async()=>(await import("./receivable-TNH4KCUO.js")).receivableDomain,report:async()=>(await import("./report-UC2PCK7B.js")).reportDomain,"rounding-setting":async()=>(await import("./sales-numbering-MBFKVR2C.js")).roundingSettingDomain,"seal-impression":async()=>(await import("./sales-master-ORLR5VK4.js")).sealImpressionDomain,
7
+ shift:async()=>(await import("./attendance-lists-MXQNWUIH.js")).shiftDomain,storage:async()=>(await import("./storage-ANKKJJJO.js")).storageDomain,"supplier-payment":async()=>(await import("./supplier-payment-AFJ7G6AP.js")).supplierPaymentDomain,task:async()=>(await import("./task-S3BBBELE.js")).taskDomain,user:async()=>(await import("./user-O7H5PD4N.js")).userDomain,wiki:async()=>(await import("./knowledge-7QDC775Q.js")).wikiDomain,workchange:async()=>(await import("./attendance-lists-MXQNWUIH.js")).
8
+ workchangeDomain,workflow:async()=>(await import("./workflow-2YL2OF2Y.js")).workflowDomain};async function loadDomain(name){return LOADERS[name]()}export{loadDomain};
@@ -0,0 +1,58 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ import{FORCE_FLAG,OUT_FLAG,REV_FLAG,revOf,singleId,uploadStaged}from"./chunk-43OMEGNH.js";import{CUSTOMER_LICENSE,childForbidden,levelForbidden}from"./chunk-H54MGGHB.js";import{createFlags,fieldBody,hasAnyField,updateFlags}from"./chunk-BPCK5RAB.js";import{inspectLocalFile}from"./chunk-PKWMJIBM.js";import{SALES_ESTIMATES_PATH,isExactNumericId}from"./chunk-BZAXQOLB.js";import{nonEmpty}from"./chunk-5R4SEO3I.js";import{requireResolved,withResolved}from"./chunk-ZN5EFDH7.js";
4
+ import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";import fs from"fs";import path from"path";var DOCUMENT_TYPES=["order_form","individual_contract","other"];var DOCUMENT_TYPE_HELP="order_form\uFF1D\u6CE8\u6587\u66F8 / individual_contract\uFF1D\u500B\u5225\u5951\u7D04\u66F8 / other\uFF1D\u305D\u306E\u4ED6\u6848\u4EF6\u66F8\u985E";var MAGIC_BYTES={pdf:["%PDF-"],jpg:["\xFF\xD8\xFF"],jpeg:["\xFF\xD8\xFF"],png:["\x89PNG\r\n\n"],xlsx:["PK","PK","PK\x07\b"],docx:["PK","PK","PK\x07\b"],xls:["\xD0\xCF\xE0\xA1\xB1\xE1"],doc:["\xD0\xCF\xE0\xA1\xB1\xE1"]};var FILE_NAME_MAX_CHARS=255;var FIELDS=[
5
+ {kind:"text",flag:"--name",key:"document_name",label:"\u66F8\u985E\u540D",maxChars:255,summary:"\u66F8\u985E\u540D\uFF08create \u3067\u306F\u5FC5\u9808\uFF09"},{kind:"enum",flag:"--type",key:"document_type",values:DOCUMENT_TYPES,summary:`\u66F8\u985E\u7A2E\u5225\uFF08${DOCUMENT_TYPE_HELP}\u30FBcreate \u3067\u306F\u5FC5\u9808\uFF09`}];var COLUMNS=["document_id","estimate_id","document_type","document_type_label","document_name","current_version","updated_by_name","updated_at"];var VERSION_COLUMNS=[
6
+ "version_number","file_name","file_size","is_current","created_by_name","created_at"];var ESTIMATE_FLAG={name:"--estimate",summary:"\u898B\u7A4D\u306E ID\uFF08twp estimate list \u306E id \u5217\u306E\u6570\u5B57\u30FB\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u898B\u7A4DID>"};var FILE_FLAG={name:"--file",summary:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3059\u308B\u30D5\u30A1\u30A4\u30EB\uFF08PDF\u30FBJPEG\u30FBPNG\u30FBWord\u30FBExcel\u3002\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\
7
+ \u30D1\u30B9>"};var REF_HELP="--estimate\uFF08\u898B\u7A4D\u306E ID\uFF09\u304C\u5FC5\u9808\u3067\u3059\u3002<\u66F8\u985EID> \u306F twp estimate case-document list \u306E document_id \u5217\u306E\u5024\u3067\u3059\u3002\n\u9867\u5BA2\u3092\u307E\u305F\u3044\u3060\u4E00\u89A7\u306F twp customer case-document list --customer <\u9867\u5BA2> \u3067\u898B\u3089\u308C\u307E\u3059\u3002";var VIEW_FORBIDDEN=levelForbidden(CUSTOMER_LICENSE,"\u6848\u4EF6\u66F8\u985E\u3092\u898B\u308B\u306B\u306F\u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
8
+ var EDIT_FORBIDDEN=childForbidden("\u6848\u4EF6\u66F8\u985E","edit");var usageOf=op=>`twp estimate case-document ${op} help`;function estimateBase(input,op){const raw=nonEmpty(input.flags,ESTIMATE_FLAG.name);if(raw===void 0)throw new UsageError(`${ESTIMATE_FLAG.name} \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,usageOf(op));const id=raw.trim();if(!isExactNumericId(id))throw new UsageError(`${ESTIMATE_FLAG.name} \u306F\u898B\u7A4D\u306E ID\uFF08\u6570\u5B57\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,
9
+ usageOf(op));return`${SALES_ESTIMATES_PATH}/${id}/case-documents`}var docId=(input,op)=>singleId(input,"\u66F8\u985E",usageOf(op),"twp estimate case-document list --estimate <\u898B\u7A4DID> \u306E document_id \u5217\u306E\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002");var docPath=(input,op)=>`${estimateBase(input,op)}/${encodeURIComponent(docId(input,op))}`;function noArgs(input,op){if(input.args.length>0)throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.
10
+ args.join(" ")}`,usageOf(op))}function itemsOf(body){const items=isRecord(body)?body["items"]:void 0;if(!isRecord(body)||body["result"]!==true||!Array.isArray(items)||!items.every(isRecord)){throw new ApiResponseError("\u6848\u4EF6\u66F8\u985E\u4E00\u89A7\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return items}function docOf(body,what){const doc=isRecord(body)?body["case_docu\
11
+ ment"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(doc)||typeof doc["document_id"]!=="string"){throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B case_document.document_id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return doc}function summaryOf(body,what){const doc=docOf(body,what);const versions=doc["versions"];return{...pick(doc,COLUMNS),versions:Array.isArray(versions)?versions.length:0}}function inspectCaseDocumentFile(raw,flag,usage,label){
12
+ const{file,size}=inspectLocalFile(raw,flag,usage);const name=path.basename(file);const extension=path.extname(name).slice(1).toLowerCase();const signatures=MAGIC_BYTES[extension];if(signatures===void 0){throw new UsageError(`${label}\u306F PDF\u30FB\u753B\u50CF\uFF08JPEG/PNG\uFF09\u30FBOffice\uFF08Word/Excel\uFF09\u3060\u3051\u3092\u767B\u9332\u3067\u304D\u307E\u3059: ${name}`)}if(Array.from(name).length>FILE_NAME_MAX_CHARS){throw new UsageError(`\u30D5\u30A1\u30A4\u30EB\u540D\u306F ${FILE_NAME_MAX_CHARS}\
13
+ \u6587\u5B57\u307E\u3067\u3067\u3059\uFF08${Array.from(name).length} \u6587\u5B57\uFF09: ${name}`)}const head=Buffer.alloc(Math.max(...signatures.map(s=>s.length)));let read;try{const fd=fs.openSync(file,"r");try{read=fs.readSync(fd,head,0,head.length,0)}finally{fs.closeSync(fd)}}catch(err){throw new UsageError(`\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\uFF08${flag}\uFF09: ${file}\uFF08${err.code??err.message}\uFF09`)}const text=head.subarray(0,read).toString("lat\
14
+ in1");if(!signatures.some(signature=>text.startsWith(signature))){throw new UsageError(`\u30D5\u30A1\u30A4\u30EB\u306E\u5185\u5BB9\u304C\u62E1\u5F35\u5B50\uFF08.${extension}\uFF09\u3068\u5408\u3044\u307E\u305B\u3093\uFF08\u58CA\u308C\u3066\u3044\u308B\u304B\u5225\u306E\u5F62\u5F0F\u3067\u3059\uFF09: ${file}`)}return{file,name,size}}function localDocument(input,op){return inspectCaseDocumentFile(input.flags.get(FILE_FLAG.name),FILE_FLAG.name,usageOf(op),"\u6848\u4EF6\u66F8\u985E")}function uploadUrlPlan(input,op){
15
+ return{method:"POST",path:`${estimateBase(input,op)}/upload-url`,body:{file_name:requireResolved(input,"fileName"),file_size:Number(requireResolved(input,"fileSize"))}}}function prepareFile(input,op){estimateBase(input,op);const doc=localDocument(input,op);return Promise.resolve(withResolved(input,{file:doc.file,fileName:doc.name,fileSize:String(doc.size)}))}function estimateOf(input){return(input.flags.get(ESTIMATE_FLAG.name)??"").trim()}async function createDocument(input,ctx){const body=fieldBody(
16
+ input,FIELDS);return uploadStaged(input,ctx,{label:"\u6848\u4EF6\u66F8\u985E",issue:uploadUrlPlan(input,"create"),retry:`twp estimate case-document list --estimate ${estimateOf(input)}`,register:async uploadKey=>{const created=docOf(await ctx.send({method:"POST",path:estimateBase(input,"create"),body:{...body,upload_key:uploadKey,file_name:requireResolved(input,"fileName")}}),"\u6848\u4EF6\u66F8\u985E\u306E\u767B\u9332");return{result:true,case_document:created}}})}async function addVersion(input,ctx){
17
+ const target=docPath(input,"add-version");const before=docOf(await ctx.send({method:"GET",path:target}),"\u6848\u4EF6\u66F8\u985E");const previous=typeof before["current_version"]==="number"?before["current_version"]:0;return uploadStaged(input,ctx,{label:"\u6848\u4EF6\u66F8\u985E",issue:uploadUrlPlan(input,"add-version"),retry:`twp estimate case-document get ${docId(input,"add-version")} --estimate ${estimateOf(input)}`,register:async uploadKey=>{const after=docOf(await ctx.send({method:"POST",
18
+ path:`${target}/versions`,body:{upload_key:uploadKey,file_name:requireResolved(input,"fileName")}}),"\u7248\u306E\u5DEE\u66FF\u3048");const current=after["current_version"];if(typeof current!=="number"||current<=previous){throw new ApiResponseError(`\u7248\u306E\u5DEE\u66FF\u3048\u306E\u5FDC\u7B54\u3067\u73FE\u884C\u7248\u304C\u9032\u3093\u3067\u3044\u307E\u305B\u3093\uFF08\u5DEE\u66FF\u3048\u524D ${previous} \u2192 \u5FDC\u7B54 ${String(current)}\uFF09\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}
19
+ return{result:true,case_document:after}}})}var estimateCaseDocumentResource={name:"case-document",summary:"\u898B\u7A4D\u306E\u6848\u4EF6\u66F8\u985E\uFF08\u6CE8\u6587\u66F8\u30FB\u500B\u5225\u5951\u7D04\u66F8\u306A\u3069\u3002\u4E00\u89A7\u30FB\u8A73\u7D30\u30FB\u767B\u9332\u30FB\u7248\u306E\u5DEE\u66FF\u3048\u30FB\u66F4\u65B0\u30FB\u524A\u9664\u30FB\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\uFF09",operations:[{name:"list",summary:"\u898B\u7A4D\u306E\u6848\u4EF6\u66F8\u985E\u3092\u4E00\u89A7\u3059\u308B",
20
+ usage:"twp estimate case-document list --estimate <\u898B\u7A4DID>",description:`\u898B\u7A4D\u306B\u767B\u9332\u3055\u308C\u305F\u6848\u4EF6\u66F8\u985E\uFF08\u524A\u9664\u3057\u305F\u3082\u306E\u3092\u9664\u304F\uFF09\u3092\u3059\u3079\u3066\u8FD4\u3057\u307E\u3059\uFF08\u3053\u306E API \u306F\u30DA\u30FC\u30B8\u30F3\u30B0\u3092\u6301\u3061\u307E\u305B\u3093\uFF09\u3002
21
+
22
+ --output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
23
+ --output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002`,flags:[ESTIMATE_FLAG],forbidden:VIEW_FORBIDDEN,plan(input){noArgs(input,"list");return{method:"GET",path:estimateBase(input,"list")}},summarize:body=>itemsOf(body).map(row=>pick(row,COLUMNS)),raw:itemsOf},{name:"get",summary:"\u6848\u4EF6\u66F8\u985E1\u4EF6\u306E\u8A73\u7D30\u3092\u8868\u793A\u3059\u308B\uFF08\u73FE\u884C\u7248\u30FB\u904E\u53BB\u7248\u3092\u542B\u3080\uFF09",usage:"twp esti\
24
+ mate case-document get <\u66F8\u985EID> --estimate <\u898B\u7A4DID>",description:`${REF_HELP}
25
+
26
+ --output json \u306F\u73FE\u884C\u7248\u30FB\u904E\u53BB\u7248\uFF08versions\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
27
+ --output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${COLUMNS.join(" / ")} / versions\uFF1D\u7248\u306E\u6570\uFF09\u3067\u3059\u3002
28
+ \u7248\u3054\u3068\u306E\u5217\u306F ${VERSION_COLUMNS.join(" / ")} \u3067\u3059\uFF08--output json\uFF09\u3002`,flags:[ESTIMATE_FLAG],forbidden:VIEW_FORBIDDEN,plan:input=>({method:"GET",path:docPath(input,"get")}),summarize:body=>summaryOf(body,"\u6848\u4EF6\u66F8\u985E"),raw:body=>docOf(body,"\u6848\u4EF6\u66F8\u985E")},{name:"create",summary:"\u30D5\u30A1\u30A4\u30EB\u3092\u898B\u7A4D\u306E\u6848\u4EF6\u66F8\u985E\u3068\u3057\u3066\u767B\u9332\u3059\u308B\uFF08\u5BB9\u91CF\u691C\u67FB\u30FB\u8EE2\u9001\u30FB\u767B\u9332\u30921\u30B3\u30DE\u30F3\u30C9\u3067\uFF09",
29
+ usage:"twp estimate case-document create --estimate <\u898B\u7A4DID> --file <\u30D1\u30B9> --type <\u7A2E\u5225> --name <\u66F8\u985E\u540D>",description:`--estimate\u30FB--file\u30FB--type\uFF08${DOCUMENT_TYPE_HELP}\uFF09\u30FB--name \u304C\u5FC5\u9808\u3067\u3059\u3002
30
+
31
+ \u6B21\u306E\u9806\u306B\u9001\u308A\u307E\u3059\u3002
32
+ 0. POST /api/v2/storage/check-upload\uFF08\u30C6\u30CA\u30F3\u30C8\u306E\u5BB9\u91CF\u691C\u67FB\u3002\u8D85\u904E\u306A\u3089\u4F55\u3082\u9001\u3089\u305A\u306B\u6B62\u307E\u308A\u307E\u3059\uFF09
33
+ 1. POST \u2026/case-documents/upload-url\uFF08\u7F72\u540DURL\u306E\u767A\u884C\uFF09
34
+ 2. \u7F72\u540DURL\u3078 PUT\uFF08\u30D5\u30A1\u30A4\u30EB\u672C\u4F53\u3002TWP \u306E\u8A8D\u8A3C\u60C5\u5831\u306F\u9001\u308A\u307E\u305B\u3093\uFF09
35
+ 3. POST \u2026/case-documents\uFF08\u66F8\u985E\u306E\u767B\u9332\u3002\u3053\u3053\u3067\u6848\u4EF6\u66F8\u985E\u304C\u6210\u7ACB\u3057\u307E\u3059\uFF09
36
+ \u5BFE\u5FDC\u5916\u306E\u5F62\u5F0F\uFF08\u62E1\u5F35\u5B50\u304C PDF\u30FBJPEG\u30FBPNG\u30FBWord\u30FBExcel \u3067\u306A\u3044\u30FB\u4E2D\u8EAB\u304C\u62E1\u5F35\u5B50\u3068\u5408\u308F\u306A\u3044\uFF09\u306F\u3001\u4F55\u3082\u9001\u3089\u305A\u306B\u6B62\u3081\u307E\u3059
37
+ \uFF08\u30B5\u30FC\u30D0\u3082\u540C\u3058\u6761\u4EF6\u3067\u65AD\u308A\u307E\u3059\uFF09\u3002--dry-run \u306F 1 \u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u3060\u3051\u3092\u8868\u793A\u3057\u307E\u3059\u3002
38
+ \u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7DE8\u96C6\u8005\u300D\u4EE5\u4E0A\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\uFF08\u8CA9\u58F2\u7BA1\u7406\u306E\u6A29\u9650\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002`,flags:[ESTIMATE_FLAG,FILE_FLAG,...createFlags(FIELDS)],forbidden:EDIT_FORBIDDEN,prepare(input){noArgs(input,"create");fieldBody(input,FIELDS);for(const flag of["--type","--name"]){if(!input.flags.has(flag))throw new UsageError(`${flag} \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,
39
+ usageOf("create"))}return prepareFile(input,"create")},plan:input=>uploadUrlPlan(input,"create"),plannedNotes:input=>[`\u5B9F\u884C\u6642\u306F\u3001\u3053\u306E\u524D\u306B\u5BB9\u91CF\u691C\u67FB\uFF08POST /api/v2/storage/check-upload\uFF09\u3092\u9001\u308A\u3001\u3053\u306E\u3042\u3068\u7F72\u540DURL\u3078 ${requireResolved(input,"fileSize")} \u30D0\u30A4\u30C8\u3092 PUT \u3057\u3066\u304B\u3089\u3001POST ${estimateBase(input,"create")} \u3067\u6848\u4EF6\u66F8\u985E\u3092\u767B\u9332\u3057\u307E\u3059\u3002`],
40
+ execute:createDocument,summarize:body=>summaryOf(body,"\u6848\u4EF6\u66F8\u985E\u306E\u767B\u9332"),raw:body=>docOf(body,"\u6848\u4EF6\u66F8\u985E\u306E\u767B\u9332")},{name:"add-version",summary:"\u6848\u4EF6\u66F8\u985E\u306B\u65B0\u3057\u3044\u7248\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u767B\u9332\u3059\u308B\uFF08\u5DEE\u66FF\u3048\u3002\u904E\u53BB\u7248\u306F\u6B8B\u308A\u307E\u3059\uFF09",usage:"twp estimate case-document add-version <\u66F8\u985EID> --estimate <\u898B\u7A4DID> --file <\u30D1\u30B9>",
41
+ description:`${REF_HELP}
42
+
43
+ \u66F8\u985E\u304C\u3053\u306E\u898B\u7A4D\u306B\u3042\u308B\u3053\u3068\u3092\u78BA\u304B\u3081\u3066\u304B\u3089\u3001\u5BB9\u91CF\u691C\u67FB \u2192 \u7F72\u540DURL\u306E\u767A\u884C \u2192 PUT \u2192 POST \u2026/{\u66F8\u985EID}/versions \u306E\u9806\u306B\u9001\u308A\u307E\u3059\u3002
44
+ \u767B\u9332\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u304C\u73FE\u884C\u7248\u306B\u306A\u308A\u3001\u305D\u308C\u307E\u3067\u306E\u7248\u306F\u904E\u53BB\u7248\u3068\u3057\u3066\u6B8B\u308A\u307E\u3059\uFF08get \u306E versions\uFF09\u3002
45
+ \u5FDC\u7B54\u3067\u73FE\u884C\u7248\u306E\u756A\u53F7\u304C\u9032\u3093\u3060\u3053\u3068\u3092\u78BA\u304B\u3081\u3066\u304B\u3089\u6210\u529F\u3092\u540D\u4E57\u308A\u307E\u3059\u3002--dry-run \u306F\u7F72\u540DURL\u306E\u767A\u884C\u3060\u3051\u3092\u8868\u793A\u3057\u307E\u3059\u3002
46
+ \u9867\u5BA2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7DE8\u96C6\u8005\u300D\u4EE5\u4E0A\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\u3002`,flags:[ESTIMATE_FLAG,FILE_FLAG],forbidden:EDIT_FORBIDDEN,prepare(input){docId(input,"add-version");return prepareFile(input,"add-version")},plan:input=>uploadUrlPlan(input,"add-version"),plannedNotes:input=>[`\u5B9F\u884C\u6642\u306F\u3001\u3053\u306E\u524D\u306B GET ${docPath(input,"add-version")}\uFF08\u66F8\u985E\u306E\u78BA\u8A8D\uFF09\u3068\u5BB9\u91CF\u691C\u67FB\u3092\u9001\u308A\u3001\u3053\u306E\u3042\u3068\u7F72\u540DURL\u3078 ${requireResolved(
47
+ input,"fileSize")} \u30D0\u30A4\u30C8\u3092 PUT \u3057\u3066\u304B\u3089\u3001POST ${docPath(input,"add-version")}/versions \u3067\u7248\u3092\u767B\u9332\u3057\u307E\u3059\u3002`],execute:addVersion,summarize:body=>summaryOf(body,"\u7248\u306E\u5DEE\u66FF\u3048"),raw:body=>docOf(body,"\u7248\u306E\u5DEE\u66FF\u3048")},{name:"update",summary:"\u6848\u4EF6\u66F8\u985E\u306E\u66F8\u985E\u540D\u30FB\u7A2E\u5225\u3092\u5909\u66F4\u3059\u308B\uFF08\u30D5\u30A1\u30A4\u30EB\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09",
48
+ usage:"twp estimate case-document update <\u66F8\u985EID> --estimate <\u898B\u7A4DID> [--name <\u66F8\u985E\u540D>] [--type <\u7A2E\u5225>]",description:`${REF_HELP}
49
+
50
+ \u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u5909\u66F4\u3057\u307E\u3059\u3002\u5909\u66F4\u3059\u308B\u9805\u76EE\u30921\u3064\u3082\u6307\u5B9A\u3057\u306A\u3044\u3068\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u3059\u3002
51
+ \u30D5\u30A1\u30A4\u30EB\u3092\u5DEE\u3057\u66FF\u3048\u308B\u306A\u3089 twp estimate case-document add-version \u3092\u4F7F\u3044\u307E\u3059\u3002`,flags:[ESTIMATE_FLAG,...updateFlags(FIELDS)],forbidden:EDIT_FORBIDDEN,plan(input){if(!hasAnyField(input,FIELDS))throw new UsageError("\u5909\u66F4\u3059\u308B\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("update"));return{method:"PATCH",path:docPath(input,"update"),body:fieldBody(input,FIELDS)}},summarize:body=>summaryOf(
52
+ body,"\u6848\u4EF6\u66F8\u985E\u306E\u66F4\u65B0"),raw:body=>docOf(body,"\u6848\u4EF6\u66F8\u985E\u306E\u66F4\u65B0")},{name:"delete",summary:"\u6848\u4EF6\u66F8\u985E\u3092\u524A\u9664\u3059\u308B\uFF08\u5168\u7248\u3002\u9867\u5BA2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\u306E\u307F\u30FB--yes \u304C\u8981\u308B\uFF09",usage:"twp estimate case-document delete <\u66F8\u985EID> --estimate <\u898B\u7A4DID> --yes",description:`${REF_HELP}
53
+
54
+ \u66F8\u985E\u3092\u904E\u53BB\u7248\u3054\u3068\u524A\u9664\u3057\u307E\u3059\uFF08\u30B5\u30FC\u30D0\u306F\u8AD6\u7406\u524A\u9664\u3067\u3001\u4E00\u89A7\u30FB\u8A73\u7D30\u30FB\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u304B\u3089\u6D88\u3048\u307E\u3059\uFF09\u3002`,destructive:true,flags:[ESTIMATE_FLAG],forbidden:childForbidden("\u6848\u4EF6\u66F8\u985E","delete"),plan:input=>({method:"DELETE",path:docPath(input,"delete")}),summarize:body=>acknowledgement(body,"\u6848\u4EF6\u66F8\u985E\u524A\u9664"),
55
+ raw:body=>acknowledgement(body,"\u6848\u4EF6\u66F8\u985E\u524A\u9664")},{name:"download",summary:"\u6848\u4EF6\u66F8\u985E\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3057\u3066\u30D5\u30A1\u30A4\u30EB\u3078\u66F8\u304D\u51FA\u3059\uFF08\u65E2\u5B9A\u306F\u73FE\u884C\u7248\uFF09",usage:"twp estimate case-document download <\u66F8\u985EID> --estimate <\u898B\u7A4DID> --out <\u30D1\u30B9> [--rev <\u7248\u756A\u53F7>] [--force]",description:`${REF_HELP}
56
+
57
+ \u66F8\u304D\u51FA\u3057\u5148\u306F --out \u3067\u5FC5\u305A\u6307\u5B9A\u3057\u307E\u3059\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u306F --force \u304C\u7121\u3051\u308C\u3070\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\u3002
58
+ \u904E\u53BB\u7248\u306F --rev \u3067\u7248\u756A\u53F7\u3092\u6307\u5B9A\u3057\u307E\u3059\uFF08get \u306E versions \u306E version_number\uFF09\u3002`,flags:[ESTIMATE_FLAG,OUT_FLAG,REV_FLAG,FORCE_FLAG],forbidden:VIEW_FORBIDDEN,download:{outFlag:OUT_FLAG.name,forceFlag:FORCE_FLAG.name},plan:input=>({method:"GET",path:`${docPath(input,"download")}/download`,query:{version:revOf(input,usageOf("download"))}}),summarize:body=>body,raw:body=>body}]};export{inspectCaseDocumentFile,estimateCaseDocumentResource};
@@ -54,4 +54,4 @@ execute:list,summarize:body=>attachmentRows(body).map(row=>pick(row,LIST_COLUMNS
54
54
  --dry-run \u306F 1 \u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u3060\u3051\u3092\u8868\u793A\u3057\u307E\u3059\uFF082 \u4EE5\u964D\u306F 1 \u306E\u5FDC\u7B54\u306B\u4F9D\u5B58\u3059\u308B\u305F\u3081\uFF09\u3002`,flags:[FILE_FLAG,NAME_FLAG,CONTENT_TYPE_FLAG,TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const local=localFile(input);const resolved=await resolveTask(input,ctx,"twp task attachment upload help");return withResolved(resolved,{file:local.file,fileName:local.name,fileSize:String(local.size),
55
55
  contentType:local.contentType})},plan:uploadUrlPlan,plannedNotes:input=>[`\u5B9F\u884C\u6642\u306F\u3001\u3053\u306E\u524D\u306B\u5BB9\u91CF\u691C\u67FB\uFF08POST /api/v2/storage/check-upload\uFF09\u3092\u9001\u308A\u3001\u3053\u306E\u3042\u3068\u7F72\u540DURL\u3078 ${requireResolved(input,"fileSize")} \u30D0\u30A4\u30C8\u3092 PUT \u3057\u3001\u30BF\u30B9\u30AF\u306E attachment_ids \u306B\u8FFD\u52A0\u3057\u3066 PUT \u3057\u307E\u3059\u3002`],execute:upload,summarize:body=>pick(body,UPLOAD_COLUMNS),
56
56
  raw:body=>body},{name:"download",summary:"\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3057\u3066\u30D5\u30A1\u30A4\u30EB\u3078\u66F8\u304D\u51FA\u3059",usage:"twp task attachment download <\u6DFB\u4ED8ID> --out <\u30D1\u30B9> [--force]",description:"\u6DFB\u4ED8 ID \u306F twp task attachment list \u306E id \u3067\u3059\u3002\n\u66F8\u304D\u51FA\u3057\u5148\u306F --out \u3067\u5FC5\u305A\u6307\u5B9A\u3057\u307E\u3059\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u306F --force \u304C\u7121\u3051\u308C\u3070\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\u3002",
57
- flags:[ATTACHMENT_REF_FLAG,OUT_FLAG,FORCE_FLAG],download:{outFlag:"--out",forceFlag:"--force"},plan(input){const id=singleRef(input,{flag:"--attachment",label:"\u6DFB\u4ED8ID",usage:"twp task attachment download help"});if(!isSafePathSegment(id))throw new UsageError(`\u6DFB\u4ED8ID \u306E\u5F62\u5F0F\u304C\u9055\u3044\u307E\u3059: ${id}`);return{method:"GET",path:`/api/v2/attachments/${encodeURIComponent(id)}/download`}},summarize:body=>body,raw:body=>body}]};export{classifyTaskRef,wantsPrivateSurface,taskSurface,rejectPrivateSurface,resolveTaskLocation,rejectRedundantProject,TASK_REF_FLAG,PROJECT_FLAG,TASK_REF_HELP,contentTypeFor,inspectLocalFile,issued,taskAttachmentResource};
57
+ flags:[ATTACHMENT_REF_FLAG,OUT_FLAG,FORCE_FLAG],download:{outFlag:"--out",forceFlag:"--force"},plan(input){const id=singleRef(input,{flag:"--attachment",label:"\u6DFB\u4ED8ID",usage:"twp task attachment download help"});if(!isSafePathSegment(id))throw new UsageError(`\u6DFB\u4ED8ID \u306E\u5F62\u5F0F\u304C\u9055\u3044\u307E\u3059: ${id}`);return{method:"GET",path:`/api/v2/attachments/${encodeURIComponent(id)}/download`}},summarize:body=>body,raw:body=>body}]};export{classifyTaskRef,wantsPrivateSurface,taskSurface,rejectPrivateSurface,resolveTaskLocation,rejectRedundantProject,TASK_REF_FLAG,PROJECT_FLAG,TASK_REF_HELP,contentTypeFor,attachmentRows,inspectLocalFile,issued,taskAttachmentResource};
@@ -5,8 +5,10 @@ import{stripTerminalControls}from"./chunk-NHYMHCAT.js";var SENSITIVE_HEADERS=new
5
5
  item=>redactSecretValues(item));if(value!==null&&typeof value==="object"){const out={};for(const[key,item]of Object.entries(value)){out[key]=SECRET_KEY_NAME.test(key)?REDACTED:redactSecretValues(item)}return out}return value}function formatHeaders(headers){if(!headers)return[];const entries=headers instanceof Headers?[...headers.entries()]:Array.isArray(headers)?headers:Object.entries(headers);return entries.map(([name,value])=>{const shown=SENSITIVE_HEADERS.has(name.toLowerCase())?REDACTED:redactSecrets(
6
6
  String(value));return` ${name.toLowerCase()}: ${shown}`})}var BODY_LIMIT=4e3;function formatBody(raw){const safe=redactSecrets(stripTerminalControls(raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
7
7
  \u2026\uFF08\u4EE5\u964D ${safe.length-BODY_LIMIT} \u6587\u5B57\u3092\u7701\u7565\uFF09`:safe}function isTextualContentType(contentType){if(contentType===null)return false;return/^\s*(text\/|application\/(json|xml|javascript|x-www-form-urlencoded)|application\/[\w.+-]*\+(json|xml))/i.test(contentType)}function withDebug(inner,options={}){const write=options.write??(text=>void process.stderr.write(text));const now=options.now??(()=>Date.now());return async(input,init)=>{const method=init?.method??
8
- "GET";const lines=[`[debug] \u2192 ${method} ${redactSecrets(input)}`,...formatHeaders(init?.headers)];if(typeof init?.body==="string")lines.push(` ${formatBody(init.body)}`);else if(init?.body instanceof Uint8Array)lines.push(` \uFF08\u672C\u6587\u306F ${init.body.byteLength} \u30D0\u30A4\u30C8\u306E\u30D0\u30A4\u30C8\u5217\u3002\u51FA\u529B\u3057\u306A\u3044\uFF09`);write(`${lines.join("\n")}
8
+ "GET";const lines=[`[debug] \u2192 ${method} ${redactSecrets(input)}`,...formatHeaders(init?.headers)];if(options.omitBodies!==void 0&&init?.body!==void 0&&init.body!==null)lines.push(` \uFF08\u672C\u6587\u306F${options.omitBodies}\u305F\u3081\u51FA\u529B\u3057\u306A\u3044\uFF09`);else if(typeof init?.body==="string")lines.push(` ${formatBody(init.body)}`);else if(init?.body instanceof Uint8Array)lines.push(` \uFF08\u672C\u6587\u306F ${init.body.byteLength} \u30D0\u30A4\u30C8\u306E\u30D0\u30A4\u30C8\u5217\u3002\u51FA\u529B\u3057\u306A\u3044\uFF09`);
9
+ write(`${lines.join("\n")}
9
10
  `);const started=now();let res;try{res=await inner(input,init)}catch(err){write(`[debug] \u2717 \u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F (${now()-started}ms): ${redactSecrets(err.message)}
10
- `);throw err}const out=[`[debug] \u2190 ${res.status} ${res.statusText} (${now()-started}ms)`,...formatHeaders(res.headers)];const contentType=res.headers.get("content-type");const attachment=/^\s*attachment\b/i.test(res.headers.get("content-disposition")??"");if(isTextualContentType(contentType)&&!attachment){const raw=await res.clone().text().catch(()=>"\uFF08\u672C\u6587\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\uFF09");if(raw!=="")out.push(` ${formatBody(raw)}`)}else{const length=res.
11
- headers.get("content-length");out.push(` \uFF08\u672C\u6587\u306F ${contentType??"content-type \u4E0D\u660E"}\u30FB${length===null?"\u30B5\u30A4\u30BA\u4E0D\u660E":`${length} \u30D0\u30A4\u30C8`}\u3002${attachment?"\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306E\u672C\u4F53\u306E\u305F\u3081":"\u30C6\u30AD\u30B9\u30C8\u3067\u306A\u3044\u305F\u3081"}\u51FA\u529B\u3057\u306A\u3044\uFF09`)}write(`${out.join("\n")}
11
+ `);throw err}const out=[`[debug] \u2190 ${res.status} ${res.statusText} (${now()-started}ms)`,...formatHeaders(res.headers)];const contentType=res.headers.get("content-type");const attachment=/^\s*attachment\b/i.test(res.headers.get("content-disposition")??"");if(options.omitBodies!==void 0){out.push(` \uFF08\u672C\u6587\u306F${options.omitBodies}\u305F\u3081\u51FA\u529B\u3057\u306A\u3044\uFF09`)}else if(isTextualContentType(contentType)&&!attachment){const raw=await res.clone().text().catch(()=>"\
12
+ \uFF08\u672C\u6587\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\uFF09");if(raw!=="")out.push(` ${formatBody(raw)}`)}else{const length=res.headers.get("content-length");out.push(` \uFF08\u672C\u6587\u306F ${contentType??"content-type \u4E0D\u660E"}\u30FB${length===null?"\u30B5\u30A4\u30BA\u4E0D\u660E":`${length} \u30D0\u30A4\u30C8`}\u3002${attachment?"\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306E\u672C\u4F53\u306E\u305F\u3081":"\u30C6\u30AD\u30B9\u30C8\u3067\u306A\u3044\u305F\u3081"}\u51FA\u529B\u3057\u306A\u3044\
13
+ \uFF09`)}write(`${out.join("\n")}
12
14
  `);return res}}export{redactSecrets,redactSecretValues,withDebug};
@@ -0,0 +1,16 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ import{featureLicenseGuidance}from"./chunk-BZ7ULFR3.js";import{isExactNumericId}from"./chunk-BZAXQOLB.js";import{nonEmpty}from"./chunk-5R4SEO3I.js";import{UsageError}from"./chunk-7WSNIXTQ.js";var PDF_PATH="/api/v2/sales/pdf";var FEATURE_DENIED="\u3053\u306E\u6A5F\u80FD\u306B\u30A2\u30AF\u30BB\u30B9\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002";function pdfForbidden(body){if(body?.error==="permission_denied"||body?.error==="forbidden"&&body.error_description===FEATURE_DENIED){return featureLicenseGuidance("\u8CA9\u58F2\u7BA1\u7406")}const reason=body?.error;if(typeof reason==="string"&&reason.endsWith("\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093")){return`${reason}\
4
+ \uFF08\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u7D10\u3065\u304F\u66F8\u985E\u306F\u305D\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30E1\u30F3\u30D0\u30FC\u3001\u7D10\u3065\u304B\u306A\u3044\u66F8\u985E\u306F\u4F5C\u6210\u8005\u30FB\u62C5\u5F53\u8005\u3068\u7BA1\u7406\u8005\u3060\u3051\u304C\u51FA\u529B\u3067\u304D\u307E\u3059\uFF09`}return void 0}var ESTIMATE={name:"estimate",label:"\u898B\u7A4D",noExample:"EST0000063",defaultKind:"estimate",kinds:{estimate:{segment:"estimate",label:"\u898B\u7A4D\
5
+ \u66F8"},order:{segment:"order",label:"\u6CE8\u6587\u66F8"},"order-acceptance":{segment:"order-acceptance",label:"\u6CE8\u6587\u8ACB\u66F8"}}};var INVOICE={name:"invoice",label:"\u8ACB\u6C42",noExample:"INV0000170",defaultKind:"invoice",kinds:{invoice:{segment:"invoice",label:"\u8ACB\u6C42\u66F8"},delivery:{segment:"delivery",label:"\u7D0D\u54C1\u66F8"},inspection:{segment:"inspection",label:"\u691C\u53CE\u66F8"}}};var PURCHASE={name:"purchase",label:"\u4ED5\u5165",defaultKind:"order",kinds:{order:{
6
+ segment:"purchase-order",label:"\u6CE8\u6587\u66F8"},"order-acceptance":{segment:"purchase-order-acceptance",label:"\u6CE8\u6587\u8ACB\u66F8"}}};var OUT_FLAG={name:"--out",summary:"\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\uFF08\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9.pdf>"};var FORCE_FLAG={name:"--force",summary:"\u65E2\u5B58\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u4E0A\u66F8\u304D\u3059\u308B",takesValue:false};function usageOf(resource){return`\
7
+ twp ${resource.name} download help`}function kindList(resource){return Object.entries(resource.kinds).map(([key,kind])=>`${key}\uFF08${kind.label}\uFF09`).join(" / ")}function kindOf(input,resource){const raw=nonEmpty(input.flags,"--kind")?.trim()??resource.defaultKind;if(!Object.hasOwn(resource.kinds,raw)){throw new UsageError(`--kind \u306F ${kindList(resource)} \u306E\u3069\u308C\u304B\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,usageOf(resource))}return resource.kinds[raw]}
8
+ function recordId(input,resource){const[raw,...rest]=input.args;const id=raw?.trim()??"";if(id==="")throw new UsageError(`${resource.label}\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,usageOf(resource));if(rest.length>0)throw new UsageError(`\u53D7\u3051\u53D6\u308C\u308B${resource.label}\u306E ID \u306F1\u3064\u3060\u3051\u3067\u3059: ${rest.join(" ")}`,usageOf(resource));if(!isExactNumericId(id)){throw new UsageError(`${resource.label}\u306E ID \u306F\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,
9
+ `${resource.label}\u756A\u53F7${resource.noExample===void 0?"":`\uFF08${resource.noExample} \u306E\u3088\u3046\u306A\u5024\uFF09`}\u3067\u63A2\u3059\u306A\u3089 twp ${resource.name} list --keyword <\u756A\u53F7> \u306E id \u5217\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`)}return id}function pdfOperation(resource){const labels=Object.values(resource.kinds).map(kind=>kind.label);const defaultLabel=resource.kinds[resource.defaultKind]?.label??resource.defaultKind;return{name:"download",
10
+ summary:`${resource.label}\u306E\u5E33\u7968 PDF\uFF08${labels.join("\u30FB")}\uFF09\u3092\u66F8\u304D\u51FA\u3059\uFF08--out\u30FB--kind\uFF09`,usage:`twp ${resource.name} download <${resource.label}ID> --out <\u30D1\u30B9.pdf> [--kind ${Object.keys(resource.kinds).join("|")}] [--force]`,description:`\u753B\u9762\u306E\u300CPDF\u51FA\u529B\u300D\u3068\u540C\u3058\u5E33\u7968\u3092\u30D5\u30A1\u30A4\u30EB\u306B\u66F8\u304D\u51FA\u3057\u307E\u3059\u3002--kind \u3092\u7701\u304F\u3068${defaultLabel}\
11
+ \u3067\u3059\u3002
12
+ --kind: ${kindList(resource)}
13
+ ID \u306F twp ${resource.name} list \u306E id \u5217\u306E\u6570\u5B57\u3067\u3059\uFF08${resource.label}\u756A\u53F7\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002
14
+ \u5370\u5F71\u30FB\u62BC\u5370\u306E\u6709\u7121\u306F\u30B5\u30FC\u30D0\u304C\u66F8\u985E\u3054\u3068\u306B\u6C7A\u3081\u307E\u3059\uFF08\u753B\u9762\u3067\u51FA\u529B\u3057\u305F\u3082\u306E\u3068\u540C\u3058\u306B\u306A\u308A\u307E\u3059\uFF09\u3002
15
+ \u65E2\u5B58\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\uFF08\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 --force\uFF09\u3002\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\u3002`,flags:[OUT_FLAG,FORCE_FLAG,{name:"--kind",summary:`\u5E33\u7968\u306E\u7A2E\u5225\uFF08${kindList(resource)}\u3002\u65E2\u5B9A ${resource.defaultKind}\uFF09`,takesValue:true,placeholder:"<\u7A2E\u5225>"}],download:{outFlag:OUT_FLAG.name,forceFlag:FORCE_FLAG.name},forbidden:pdfForbidden,
16
+ plan:input=>({method:"GET",path:`${PDF_PATH}/${kindOf(input,resource).segment}/${encodeURIComponent(recordId(input,resource))}`}),summarize:body=>body,raw:body=>body}}var estimatePdfOperation=pdfOperation(ESTIMATE);var invoicePdfOperation=pdfOperation(INVOICE);var purchasePdfOperation=pdfOperation(PURCHASE);export{estimatePdfOperation,invoicePdfOperation,purchasePdfOperation};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{redactSecretValues,redactSecrets}from"./chunk-BUZKNZ45.js";import{formatOutput}from"./chunk-K2ONOH3L.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";function renderOutput(value,format,noRedact=false){if(noRedact)return formatOutput(value,format);return redactSecrets(formatOutput(redactSecretValues(value),format))}function renderDocument(text,noRedact=false){const visible=stripTerminalControls(text);return noRedact?visible:redactSecrets(visible)}export{renderOutput,renderDocument};
3
+ import{redactSecretValues,redactSecrets}from"./chunk-UT4FACHN.js";import{formatOutput}from"./chunk-K2ONOH3L.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";function renderOutput(value,format,noRedact=false){if(noRedact)return formatOutput(value,format);return redactSecrets(formatOutput(redactSecretValues(value),format))}function renderDocument(text,noRedact=false){const visible=stripTerminalControls(text);return noRedact?visible:redactSecrets(visible)}export{renderOutput,renderDocument};
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{loadDomain}from"./chunk-TLN3JSEC.js";import{evaluateQuery}from"./chunk-GDM2QUBL.js";import{renderDocument,renderOutput}from"./chunk-FEOST3GF.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BUZKNZ45.js";import{parseOperationArgs}from"./chunk-IOGVQVGD.js";import{Resolver,requireDefaultProject}from"./chunk-ELXDRPDV.js";import{ApiError,MultipartBody,TwpApiClient,appendQuery}from"./chunk-IF2K4PM5.js";import{ResolveError}from"./chunk-GMBJTG6A.js";
4
- import{GLOBAL_OPTIONS_HELP}from"./chunk-I4ARX6NM.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-4VZKNEVN.js";import{HELP_TOKEN}from"./chunk-UVUVEL3B.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-K2ONOH3L.js";import{stringWidth}from"./chunk-WVS4W5FY.js";import{
5
- stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-5R4SEO3I.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-7WSNIXTQ.js";import fs from"fs";import path from"path";var NO_REDACT_FLAG={name:"--no-redact",summary:"\u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u3066\u751F\u306E\u5024\u3092\u51FA\u3059\uFF08\u9375\u306E\u53D7\u3051\u53D6\u308A\u7B49\uFF09",takesValue:false};var NO_REDACT_NOTICE="\u6CE8\u8A18: --no-redact \u306E\u305F\u3081\u51FA\u529B\u3092\u4F0F\u5B57\u5316\u3057\u307E\u305B\u3093\uFF08\u7AEF\u672B\u3068\u30ED\u30B0\u306B\u5E73\u6587\u3067\u6B8B\u308A\u307E\u3059\uFF09\u3002";function withCommonFlags(flags){return flags.some(flag=>flag.
3
+ import{evaluateQuery}from"./chunk-GDM2QUBL.js";import{renderDocument,renderOutput}from"./chunk-VK5T7ULK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-UT4FACHN.js";import{loadDomain}from"./chunk-L6AHCTQZ.js";import{parseOperationArgs}from"./chunk-IOGVQVGD.js";import{Resolver,requireDefaultProject}from"./chunk-BZAXQOLB.js";import{ApiError,MultipartBody,TwpApiClient,appendQuery}from"./chunk-IF2K4PM5.js";import{ResolveError}from"./chunk-GMBJTG6A.js";
4
+ import{GLOBAL_OPTIONS_HELP}from"./chunk-I4ARX6NM.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-4VZKNEVN.js";import{HELP_TOKEN}from"./chunk-EOSSFTNG.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-K2ONOH3L.js";import{stringWidth}from"./chunk-WVS4W5FY.js";import{
5
+ stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-5R4SEO3I.js";import{isRecord}from"./chunk-ZWVYVS2A.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-7WSNIXTQ.js";import fs from"fs";import path from"path";var NO_REDACT_FLAG={name:"--no-redact",summary:"\u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u3066\u751F\u306E\u5024\u3092\u51FA\u3059\uFF08\u9375\u306E\u53D7\u3051\u53D6\u308A\u7B49\uFF09",takesValue:false};var NO_REDACT_NOTICE="\u6CE8\u8A18: --no-redact \u306E\u305F\u3081\u51FA\u529B\u3092\u4F0F\u5B57\u5316\u3057\u307E\u305B\u3093\uFF08\u7AEF\u672B\u3068\u30ED\u30B0\u306B\u5E73\u6587\u3067\u6B8B\u308A\u307E\u3059\uFF09\u3002";function withCommonFlags(flags){return flags.some(flag=>flag.
6
6
  name===NO_REDACT_FLAG.name)?flags:[...flags,NO_REDACT_FLAG]}function alignedList(entries,indent=" "){const width=entries.reduce((max,[left])=>Math.max(max,stringWidth(left)),0);return entries.map(([left,right])=>`${indent}${left}${" ".repeat(Math.max(0,width-stringWidth(left)))} ${right}`).join("\n")}function subresourcesOf(resource){return resource.subresources??[]}function renderResourceHelp(resource,path2){const subresources=subresourcesOf(resource);const operationSection=resource.operations.length===0?"":`
7
7
  \u64CD\u4F5C:
8
8
  ${alignedList(resource.operations.map(op=>[op.name,op.summary]))}
@@ -24,18 +24,19 @@ return EXIT_AUTH;if(err instanceof ApiError)return exitCodeForStatus(err.status)
24
24
  Error?err.message:String(err));const rawHint=err instanceof UsageError?err.hint:void 0;const hint=rawHint!==void 0?safeText(rawHint):void 0;if(format==="json"){const body={code,message};if(err instanceof ApiError)body["status"]=err.status;if(err instanceof ResolveError&&err.status!==null)body["status"]=err.status;if(hint!==void 0)body["hint"]=hint;write(`${JSON.stringify({error:body},null,2)}
25
25
  `);return}write(`${message}
26
26
  `);if(hint!==void 0)write(`${hint}
27
- `)}function dryRunValue(apiUrl,plan){const value={method:plan.method,url:`${apiUrl}${appendQuery(plan.path,plan.query)}`};if(plan.body!==void 0)value["body"]=plan.body instanceof MultipartBody?plan.body.toJSON():plan.body;return value}async function send(client,apiUrl,plan){try{return await client.request(plan.method,appendQuery(plan.path,plan.query),plan.body)}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError){throw err}throw new NetworkError(
28
- `${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}}async function putSigned(fetchImpl,url,bytes,contentType){let res;try{res=await fetchImpl(url,{method:"PUT",headers:{"Content-Type":contentType},body:bytes})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\
29
- \u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.status}\uFF09`)}}async function getSigned(fetchImpl,url){let res;try{res=await fetchImpl(url,{method:"GET"})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u304B\u3089\u306E\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u304B\u3089\u306E\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.
30
- status}\uFF09`)}return{bytes:new Uint8Array(await res.arrayBuffer()),contentType:res.headers.get("content-type")}}function resolveDownloadTarget(spec,commandPath,operationName,input){const raw=input.flags.get(spec.outFlag);if(raw===void 0||raw.trim()===""){throw new UsageError(`${spec.outFlag} \u306F\u5FC5\u9808\u3067\u3059\uFF08twp ${commandPath} ${operationName}\uFF09`,`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002`)}
31
- return{out:path.resolve(raw.trim()),force:input.flags.has(spec.forceFlag)}}function assertWritableTarget(target,forceFlag){if(!target.force&&fs.existsSync(target.out)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${target.out}`,`\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 ${forceFlag} \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A\u3067\u306F\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\uFF09\u3002`)}const dir=path.dirname(target.
32
- out);if(!fs.existsSync(dir)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u3042\u308A\u307E\u305B\u3093: ${dir}`,"\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u4F5C\u3063\u3066\u304B\u3089\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u81EA\u52D5\u3067\u306F\u4F5C\u6210\u3057\u307E\u305B\u3093\uFF09\u3002")}}async function download(args){let received;if(args.signed!==void 0){const url=args.signed.signedUrl(await send(args.client,args.
33
- apiUrl,args.plan),args.plan);received=await getSigned(args.signed.fetchImpl,url)}else{try{received=await args.client.requestBinary(args.plan.method,appendQuery(args.plan.path,args.plan.query))}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError)throw err;throw new NetworkError(`${args.apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}}try{fs.writeFileSync(args.target.out,received.bytes,{
34
- flag:args.target.force?"w":"wx"})}catch(err){const code=err.code;if(code==="EEXIST"){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${args.target.out}`,"\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 --force \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}throw new Error(`\u66F8\u304D\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${args.target.out}\uFF09: ${err.message}`,{cause:err})}const captured={};for(const name of args.captureHeaders??
35
- []){const value=received.headers?.get(name);if(typeof value==="string")captured[name]=value}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType,...Object.keys(captured).length>0?{headers:captured}:{}}}function resumeHint(vocabulary,cursor){return vocabulary.resume!==void 0?vocabulary.resume(cursor):`${vocabulary.resumeFlag} ${shellQuote(cursor)}`}var CURATED_PAGING_VOCABULARY={mode:"--all",resumeFlag:"--cursor",capAdvice:"--limit \u3092\u5927\u304D\u304F\u3057\u3066\u5F80\u5FA9\u3092\u6E1B\u3089\u3059\u304B\u3001--max-pages \
36
- / --max-items \u3092\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\u3002"};function capExceeded(vocabulary,reason,pages,count,cursor){return new UsageError(`${vocabulary.mode} \u304C\u4E0A\u9650\u306B\u9054\u3057\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\uFF08${reason}\uFF0F${pages} \u30DA\u30FC\u30B8\u30FB${count} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`,`${vocabulary.capAdvice}\u7D9A\u304D\u3060\u3051\u3092\u53D6\u308B\u306A\u3089 ${resumeHint(
37
- vocabulary,cursor)} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059`)}async function fetchAllPages(args){const{paging,maxPages,maxItems}=args;const vocabulary=args.vocabulary??CURATED_PAGING_VOCABULARY;const merged=[];const first=args.plan.query?.[paging.cursorParam];let sent=typeof first==="string"?first:"";let scanTruncated=false;for(let page=1;;page+=1){const plan=page===1?args.plan:{...args.plan,query:{...args.plan.query,[paging.cursorParam]:sent}};let body;try{body=page===1&&"firstPage"in args?
38
- args.firstPage:await send(args.client,args.apiUrl,plan)}catch(err){if(page>1){(args.warn??writeErr)(`${vocabulary.mode} \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-1} \u30DA\u30FC\u30B8\u30FB${merged.length} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F ${resumeHint(vocabulary,stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
27
+ `)}function dryRunValue(apiUrl,plan,sensitiveBody){const value={method:plan.method,url:`${apiUrl}${appendQuery(plan.path,plan.query)}`};if(plan.body!==void 0)value["body"]=plan.body instanceof MultipartBody?plan.body.toJSON():plan.body;if(sensitiveBody!==void 0&&isRecord(value["body"])){const hidden=`\uFF08${sensitiveBody}\u305F\u3081\u8868\u793A\u3057\u306A\u3044\u30FB--no-redact \u3067\u8868\u793A\uFF09`;value["body"]=Object.fromEntries(Object.keys(value["body"]).map(key=>[key,hidden]))}return value}
28
+ async function send(client,apiUrl,plan){try{return await client.request(plan.method,appendQuery(plan.path,plan.query),plan.body)}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError){throw err}throw new NetworkError(`${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}}async function putSigned(fetchImpl,url,bytes,contentType){let res;try{res=await fetchImpl(url,{method:"PUT",headers:{"Con\
29
+ tent-Type":contentType},body:bytes})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.status}\uFF09`)}}async function getSigned(fetchImpl,url){let res;try{res=await fetchImpl(url,{method:"\
30
+ GET"})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u304B\u3089\u306E\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u304B\u3089\u306E\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.status}\uFF09`)}return{bytes:new Uint8Array(await res.arrayBuffer()),contentType:res.headers.get("content-type")}}function resolveDownloadTarget(spec,commandPath,operationName,input){
31
+ const raw=input.flags.get(spec.outFlag);if(raw===void 0||raw.trim()===""){throw new UsageError(`${spec.outFlag} \u306F\u5FC5\u9808\u3067\u3059\uFF08twp ${commandPath} ${operationName}\uFF09`,`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002`)}return{out:path.resolve(raw.trim()),force:input.flags.has(spec.forceFlag)}}function assertWritableTarget(target,forceFlag){
32
+ if(!target.force&&fs.existsSync(target.out)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${target.out}`,`\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 ${forceFlag} \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A\u3067\u306F\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\uFF09\u3002`)}const dir=path.dirname(target.out);if(!fs.existsSync(dir)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u3042\u308A\u307E\u305B\u3093: ${dir}`,
33
+ "\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u4F5C\u3063\u3066\u304B\u3089\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u81EA\u52D5\u3067\u306F\u4F5C\u6210\u3057\u307E\u305B\u3093\uFF09\u3002")}}async function download(args){let received;if(args.signed!==void 0){const url=args.signed.signedUrl(await send(args.client,args.apiUrl,args.plan),args.plan);received=await getSigned(args.signed.fetchImpl,url)}else{try{received=await args.client.requestBinary(args.plan.method,appendQuery(args.plan.
34
+ path,args.plan.query))}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError)throw err;throw new NetworkError(`${args.apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}}try{fs.writeFileSync(args.target.out,received.bytes,{flag:args.target.force?"w":"wx"})}catch(err){const code=err.code;if(code==="EEXIST"){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${args.
35
+ target.out}`,"\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 --force \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}throw new Error(`\u66F8\u304D\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${args.target.out}\uFF09: ${err.message}`,{cause:err})}const captured={};for(const name of args.captureHeaders??[]){const value=received.headers?.get(name);if(typeof value==="string")captured[name]=value}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType,
36
+ ...Object.keys(captured).length>0?{headers:captured}:{}}}function resumeHint(vocabulary,cursor){return vocabulary.resume!==void 0?vocabulary.resume(cursor):`${vocabulary.resumeFlag} ${shellQuote(cursor)}`}var CURATED_PAGING_VOCABULARY={mode:"--all",resumeFlag:"--cursor",capAdvice:"--limit \u3092\u5927\u304D\u304F\u3057\u3066\u5F80\u5FA9\u3092\u6E1B\u3089\u3059\u304B\u3001--max-pages / --max-items \u3092\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\u3002"};function capExceeded(vocabulary,reason,pages,count,cursor){
37
+ return new UsageError(`${vocabulary.mode} \u304C\u4E0A\u9650\u306B\u9054\u3057\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\uFF08${reason}\uFF0F${pages} \u30DA\u30FC\u30B8\u30FB${count} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`,`${vocabulary.capAdvice}\u7D9A\u304D\u3060\u3051\u3092\u53D6\u308B\u306A\u3089 ${resumeHint(vocabulary,cursor)} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059`)}async function fetchAllPages(args){
38
+ const{paging,maxPages,maxItems}=args;const vocabulary=args.vocabulary??CURATED_PAGING_VOCABULARY;const merged=[];const first=args.plan.query?.[paging.cursorParam];let sent=typeof first==="string"?first:"";let scanTruncated=false;for(let page=1;;page+=1){const plan=page===1?args.plan:{...args.plan,query:{...args.plan.query,[paging.cursorParam]:sent}};let body;try{body=page===1&&"firstPage"in args?args.firstPage:await send(args.client,args.apiUrl,plan)}catch(err){if(page>1){(args.warn??writeErr)(`${vocabulary.
39
+ mode} \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-1} \u30DA\u30FC\u30B8\u30FB${merged.length} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F ${resumeHint(vocabulary,stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
39
40
  `)}throw err}for(const item of paging.items(body))merged.push(item);if(typeof body==="object"&&body!==null&&body["scan_truncated"]===true)scanTruncated=true;const next=paging.nextCursor(body);if(next===null){const combined=paging.withItems(body,merged);const flagged=scanTruncated&&typeof combined==="object"&&combined!==null&&!Array.isArray(combined)?{...combined,scan_truncated:true}:combined;return{body:flagged,pages:page,count:merged.length}}if(merged.length>=maxItems)throw capExceeded(vocabulary,
40
41
  `\u6700\u5927\u4EF6\u6570 ${maxItems} \u4EF6`,page,merged.length,next);if(page>=maxPages)throw capExceeded(vocabulary,`\u6700\u5927\u30DA\u30FC\u30B8\u6570 ${maxPages}`,page,merged.length,next);if(next===sent){throw new ApiResponseError(`\u540C\u3058\u30AB\u30FC\u30BD\u30EB\uFF08${next}\uFF09\u304C\u7E70\u308A\u8FD4\u3057\u8FD4\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\u3002${merged.length} \u4EF6\u3092\u53D6\u5F97\u3057\u305F\u6642\u70B9\u3067\u3001\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`)}
41
42
  sent=next}}function resolvePaging(operation,path2,input){const all=input.flags.has("--all");const maxPages=positiveInteger(input.flags,"--max-pages")??DEFAULT_MAX_PAGES;const maxItems=positiveInteger(input.flags,"--max-items")??DEFAULT_MAX_ITEMS;positiveInteger(input.flags,"--limit");if(all&&operation.paging===void 0){throw new UsageError(`twp ${path2} ${operation.name} \u306F --all \u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093`)}for(const name of["--max-pages","--max-items"]){if(!all&&
@@ -46,12 +47,13 @@ null){throw new UsageError(`--output \u306B\u300C${globals.output??""}\u300D\u30
46
47
  name===extra);if(target===void 0||rest2.length>0){throw new UsageError(renderUnknownOperation(domain,domain.name,extra))}out(renderResourceHelp(target,`${domain.name} ${extra}`));return EXIT_OK}const sub=domain.subresources?.find(resource2=>resource2.name===options.operation);const resource=sub??domain;const path2=sub===void 0?domain.name:`${domain.name} ${sub.name}`;const operationName=sub===void 0?options.operation:options.argv[0];const rest=sub===void 0?options.argv:options.argv.slice(1);if(sub!==
47
48
  void 0&&(operationName===HELP_TOKEN||options.help&&operationName===void 0)){out(renderResourceHelp(sub,path2));return EXIT_OK}const operation=resource.operations.find(op=>op.name===operationName);if(operation===void 0){throw new UsageError(renderUnknownOperation(resource,path2,operationName))}forbidden=operation.forbidden;rejected=operation.rejected;if(options.help||rest[0]===HELP_TOKEN){out(renderOperationHelp(operation,path2));return EXIT_OK}const input=parseOperationArgs(rest,withCommonFlags(
48
49
  operation.flags));const noRedact=input.flags.has("--no-redact");if(!globals.dryRun&&requiresYes(operation,globals.yes)){throw new UsageError(`twp ${path2} ${operation.name} \u306F${operation.confirmation??"\u7834\u58CA\u7684\u306A\u64CD\u4F5C"}\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`)}const paging=resolvePaging(operation,path2,input);const downloadTarget=operation.download===void 0?void 0:resolveDownloadTarget(operation.
49
- download,path2,operation.name,input);const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport,{write:errOut}):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);const ctx=buildPrepareContext({resolver:new Resolver(client,{profile:profile.name,refresh:globals.refresh,
50
- ...profileAliases(profile.name)}),profileName:profile.name,env:process.env,cwd:process.cwd()});const prepared=operation.prepare===void 0?input:await operation.prepare(input,ctx);const plan=operation.plan(prepared);if(operation.execute!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: execute \u306F download / paging / fetchCached \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}
51
- if(operation.narrow!==void 0&&(operation.execute!==void 0||operation.download!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: narrow \u306F execute / download / fetchCached \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.invalidates!==void 0&&(operation.fetchCached!==void 0||plan.method==="GET")){throw new Error(`twp ${path2} ${operation.name}: invalidates \u306F\u66F8\u304D\u8FBC\u307F\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\
52
- \u8AA4\u308A\uFF09`)}if(operation.fetchCached!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.destructive===true||plan.method!=="GET")){throw new Error(`twp ${path2} ${operation.name}: fetchCached \u306F\u9001\u4FE1\u3057\u306A\u3044\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}for(const note of operation.plannedNotes?.(prepared)??[])errOut(`${safeText(note)}
50
+ download,path2,operation.name,input);const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport,{write:errOut,...operation.sensitiveBody!==void 0?{omitBodies:operation.sensitiveBody}:{}}):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);const ctx=buildPrepareContext(
51
+ {resolver:new Resolver(client,{profile:profile.name,refresh:globals.refresh,...profileAliases(profile.name)}),profileName:profile.name,env:process.env,cwd:process.cwd()});const prepared=operation.prepare===void 0?input:await operation.prepare(input,ctx);const plan=operation.plan(prepared);if(operation.execute!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: execute \u306F download / paging / fetchCache\
52
+ d \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.narrow!==void 0&&(operation.execute!==void 0||operation.download!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: narrow \u306F execute / download / fetchCached \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.invalidates!==void 0&&(operation.fetchCached!==
53
+ void 0||plan.method==="GET")){throw new Error(`twp ${path2} ${operation.name}: invalidates \u306F\u66F8\u304D\u8FBC\u307F\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.fetchCached!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.destructive===true||plan.method!=="GET")){throw new Error(`twp ${path2} ${operation.name}: fetchCached \u306F\u9001\u4FE1\u3057\u306A\u3044\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}
54
+ for(const note of operation.plannedNotes?.(prepared)??[])errOut(`${safeText(note)}
53
55
  `);if(noRedact)errOut(`${NO_REDACT_NOTICE}
54
- `);if(globals.dryRun){out(line(renderOutput(dryRunValue(apiUrl,plan),format,noRedact)));return EXIT_OK}let body;let paged;try{if(operation.execute!==void 0){const executeCtx={send:next=>send(client,apiUrl,next),putSigned:(url,bytes,contentType)=>putSigned(fetchImpl,url,bytes,contentType),warn:text=>errOut(`${safeText(text)}
56
+ `);if(globals.dryRun){out(line(renderOutput(dryRunValue(apiUrl,plan,noRedact?void 0:operation.sensitiveBody),format,noRedact)));return EXIT_OK}let body;let paged;try{if(operation.execute!==void 0){const executeCtx={send:next=>send(client,apiUrl,next),putSigned:(url,bytes,contentType)=>putSigned(fetchImpl,url,bytes,contentType),warn:text=>errOut(`${safeText(text)}
55
57
  `)};body=await operation.execute(prepared,executeCtx)}else if(operation.fetchCached!==void 0){body=await operation.fetchCached(prepared,ctx)}else if(operation.download!==void 0&&downloadTarget!==void 0){assertWritableTarget(downloadTarget,operation.download.forceFlag);const signedUrl=operation.download.signedUrl;body=await download({client,apiUrl,plan,target:downloadTarget,...signedUrl===void 0?{}:{signed:{fetchImpl,signedUrl}},...operation.download.captureHeaders===void 0?{}:{captureHeaders:operation.
56
58
  download.captureHeaders}})}else if(paging.all&&operation.paging!==void 0){paged=await fetchAllPages({client,apiUrl,plan,paging:operation.paging,maxPages:paging.maxPages,maxItems:paging.maxItems,warn:errOut});body=paged.body}else{body=await send(client,apiUrl,plan)}}finally{try{operation.invalidates?.(prepared,ctx)}catch{}}if(operation.narrow!==void 0){body=operation.narrow(body,prepared);if(paged!==void 0&&operation.paging!==void 0){paged={...paged,count:operation.paging.items(body).length}}}const visible=noRedact?
57
59
  body:redactSecretValues(body);const document=globals.query===void 0&&format==="text"&&operation.document!==void 0?operation.document(visible):void 0;const value=document!==void 0?void 0:globals.query!==void 0?await evaluateQuery(globals.query,operation.raw(visible)):outputValue(operation,format,visible);out(line(document!==void 0?renderDocument(document,noRedact):renderOutput(value,format,noRedact)));if(paged!==void 0){errOut(`--all: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{readBody}from"./chunk-HGTG5XQ7.js";import{WORKFLOWS_PATH}from"./chunk-ELXDRPDV.js";import{UUID_RE,isSafePathSegment}from"./chunk-GMBJTG6A.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";import{requireResolved,singleRef,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var WORKFLOW_FLAG={name:"--workflow",summary:"\u7533\u8ACB\u66F8\uFF08\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\uFF09\u306E\u540D\u524D\u304B ID \u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC>"};var CATEGORIES={undefined:"\u6C4E\u7528",paid_holiday:"\u6709\u7D66\u4F11\u6687",substitute_holiday:"\u632F\u66FF\u4F11\u6687",comp_holiday:"\u4EE3\u4F11",absence:"\u6B20\u52E4",special_holiday:"\u7279\u5225\u4F11\u6687",other_leave:"\u305D\u306E\u4ED6\u4F11\u6687\u30FB\u6B20\u52E4",
3
+ import{readBody}from"./chunk-HGTG5XQ7.js";import{WORKFLOWS_PATH}from"./chunk-BZAXQOLB.js";import{UUID_RE,isSafePathSegment}from"./chunk-GMBJTG6A.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";import{requireResolved,singleRef,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var WORKFLOW_FLAG={name:"--workflow",summary:"\u7533\u8ACB\u66F8\uFF08\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\uFF09\u306E\u540D\u524D\u304B ID \u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC>"};var CATEGORIES={undefined:"\u6C4E\u7528",paid_holiday:"\u6709\u7D66\u4F11\u6687",substitute_holiday:"\u632F\u66FF\u4F11\u6687",comp_holiday:"\u4EE3\u4F11",absence:"\u6B20\u52E4",special_holiday:"\u7279\u5225\u4F11\u6687",other_leave:"\u305D\u306E\u4ED6\u4F11\u6687\u30FB\u6B20\u52E4",
4
4
  sales:"\u53D6\u5F15",commuting_expenses:"\u901A\u52E4\u4EA4\u901A\u8CBB",cms_publish:"\u30B3\u30F3\u30C6\u30F3\u30C4\u516C\u958B",equipment_lending:"\u5099\u54C1\u8CB8\u51FA",ai_tool_license:"AI\u30C4\u30FC\u30EB\u30E9\u30A4\u30BB\u30F3\u30B9",qualification_bonus:"\u5408\u683C\u304A\u795D\u3044\u91D1"};var CATEGORY_HELP=`\u30AB\u30C6\u30B4\u30EA: ${Object.entries(CATEGORIES).map(([key,label])=>`${key}\uFF08${label}\uFF09`).join(" / ")}`;var WORKFLOW_STATUSES=["active","inactive","draft"];var INSTANCE_STATUSES=[
5
5
  "new","in_progress","approved","rejected","canceled","sent_back"];var INSTANCE_STATUS_HELP="\u72B6\u614B: new\uFF08\u4E0B\u66F8\u304D\uFF09/ in_progress\uFF08\u627F\u8A8D\u5F85\u3061\uFF09/ approved\uFF08\u627F\u8A8D\u6E08\u307F\uFF09/ rejected\uFF08\u5374\u4E0B\uFF09/ canceled\uFF08\u53D6\u6D88\uFF09/ sent_back\uFF08\u5DEE\u3057\u623B\u3057\uFF09";var WORKFLOW_COLUMNS=["id","name","defined_category","status","is_hidden","valid_from","valid_to"];var WORKFLOW_ADMIN_COLUMNS=[...WORKFLOW_COLUMNS,"s\
6
6
  tep_count"];var WORKFLOW_GET_COLUMNS=["id","name","defined_category","status","is_hidden","valid_from","valid_to","description"];var INSTANCE_COLUMNS=["id","title","workflow_name","status","current_step_no","applicant_name","applied_at","completed_at"];var INSTANCE_GET_COLUMNS=["id","title","workflow_id","workflow_name","status","current_step_no","applicant_name","applied_at","completed_at","can_approve","is_editable","is_cancelable"];var PENDING_COLUMNS=["id","title","workflow_name","applicant_\
@@ -1,7 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{salesAdminForbidden}from"./chunk-QDTYD5PY.js";import"./chunk-I6DWJXPC.js";import"./chunk-HGTG5XQ7.js";import"./chunk-RZ54TCQU.js";import"./chunk-IOGVQVGD.js";import"./chunk-UDPJ2IGK.js";import"./chunk-ELXDRPDV.js";import"./chunk-IF2K4PM5.js";import"./chunk-GMBJTG6A.js";import"./chunk-J7QYPKVK.js";import"./chunk-4VZKNEVN.js";import"./chunk-QQRJLH6B.js";import"./chunk-NHYMHCAT.js";import{nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";
4
- import"./chunk-II5RVJQN.js";import{withResolved}from"./chunk-ZN5EFDH7.js";import{isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";import"./chunk-RZVI6PMW.js";import"./chunk-VSJBJXZO.js";var PATH="/api/v2/sales/receivables";var FORBIDDEN=salesAdminForbidden("\u58F2\u639B\u91D1\u6B8B\u9AD8\u3068\u7DE0\u3081");var CLOSING_LIST_MAX=36;var SUMMARY_LABELS=[["previous_balance","\u524D\u6708\u6B8B\u9AD8"],["current_debit","\u5F53\u6708\u501F\u65B9\uFF08\u5F53\u6708\u8ACB\u6C42\u984D\uFF09"],["current_credit","\u5F53\u6708\u8CB8\u65B9\uFF08\u5F53\u6708\u5165\u91D1\u5F15\u5F53\u984D\uFF09"],["current_balance","\u5F53\u6708\u6B8B\u9AD8"],["current_month_uncollected","\u2460 \u5F53\u6708\u8ACB\u6C42 \u672A\u56DE\u53CE"],
3
+ import{salesAdminForbidden}from"./chunk-7ACENLLZ.js";import{nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";import{withResolved}from"./chunk-ZN5EFDH7.js";import{isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var PATH="/api/v2/sales/receivables";var FORBIDDEN=salesAdminForbidden("\u58F2\u639B\u91D1\u6B8B\u9AD8\u3068\u7DE0\u3081");var CLOSING_LIST_MAX=36;var SUMMARY_LABELS=[["previous_balance","\u524D\u6708\u6B8B\u9AD8"],["current_debit","\u5F53\u6708\u501F\u65B9\uFF08\u5F53\u6708\u8ACB\u6C42\u984D\uFF09"],["current_credit","\u5F53\u6708\u8CB8\u65B9\uFF08\u5F53\u6708\u5165\u91D1\u5F15\u5F53\u984D\uFF09"],["current_balance","\u5F53\u6708\u6B8B\u9AD8"],["current_month_uncollected","\u2460 \u5F53\u6708\u8ACB\u6C42 \u672A\u56DE\u53CE"],
5
4
  ["previous_uncollected","\u2461 \u524D\u6708\u4EE5\u524D \u672A\u5165\u91D1\u58F2\u639B\u91D1"],["advance_received","\u524D\u53D7\u91D1\uFF08\u7FCC\u6708\u4EE5\u964D\u8ACB\u6C42\u3078\u306E\u5165\u91D1\uFF09"],["future_invoice_total","\u2462 \u7FCC\u6708\u4EE5\u964D \u58F2\u639B\u91D1\uFF08\u8ACB\u6C42\u7DCF\u984D\u30FB\u53C2\u8003\uFF09"]];var ITEM_COLUMNS=["invoice_id","invoice_no","company_name","title","invoice_date","due_date","total","collected","uncollected"];var CLOSING_COLUMNS=["year_mo\
6
5
  nth","basis_date","closed_at","closed_by_name","has_variance"];function usageOf(op){return`twp receivable ${op} help`}function yen(value){return typeof value==="number"?`${value.toLocaleString("ja-JP")} \u5186`:"\uFF08\u4E0D\u660E\uFF09"}function text(value){return typeof value==="string"||typeof value==="number"?String(value):""}function yearMonthValue(raw,label){const value=raw.trim();if(!/^\d{4}-(0[1-9]|1[0-2])$/.test(value))throw new UsageError(`${label} \u306F YYYY-MM \u306E\u5F62\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,
7
6
  "\u4F8B: 2026-09");return value}function previousYearMonth(yearMonth){const[y,m]=yearMonth.split("-").map(Number);return m===1?`${y-1}-12`:`${y}-${String(m-1).padStart(2,"0")}`}function envelope(body,what){if(!isRecord(body)||body["result"]!==true)throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306E\u5F62\u304C\u60F3\u5B9A\u3068\u9055\u3044\u307E\u3059\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return body}function withoutResult(body){return Object.
@@ -46,4 +45,4 @@ en",summary:"\u6708\u306E\u7DE0\u3081\u3092\u89E3\u9664\u3059\u308B\uFF08\u78BA\
46
45
  \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002",destructive:true,flags:[],forbidden:FORBIDDEN,prepare:prepareReopen,plan:input=>({method:"DELETE",path:`${PATH}/closings/${yearMonthArg(input,"reopen")}`}),plannedNotes(input){const yearMonth=yearMonthArg(input,"reopen");const target=resolvedJson(input,"target");if(target["is_closed"]!==true)return[`${yearMonth} \u306F\u7DE0\u3081\u3066\u3044\u307E\u305B\u3093\uFF08\u30B5\u30FC\u30D0\u304C\u65AD\u308A\u307E\u3059\uFF09`];
47
46
  const closing=isRecord(target["closing"])?target["closing"]:{};return[`${yearMonth} \u306E\u7DE0\u3081\uFF08${text(closing["closed_at"])}${text(closing["closed_by_name"])===""?"":` / ${text(closing["closed_by_name"])}`}\uFF09\u3092\u89E3\u9664\u3057\u307E\u3059\u3002\u6D88\u3048\u308B\u78BA\u5B9A\u5024:`,...summaryLines(closing["snapshot_summary"]),...hasVariance(target["variance"])?["\u7DE0\u3081\u305F\u5F8C\u306B\u5024\u304C\u52D5\u3044\u3066\u3044\u307E\u3059\uFF08\u78BA\u5B9A\u5024 \u2192 \u73FE\u5728\u5024\uFF09:",
48
47
  ...varianceLines(target["variance"])]:[]]},summarize:body=>({result:envelope(body,"\u7DE0\u3081\u306E\u89E3\u9664")["result"],message:body["message"]??null}),raw:body=>({result:envelope(body,"\u7DE0\u3081\u306E\u89E3\u9664")["result"],message:body["message"]??null})};var closingResource={name:"closing",summary:"\u58F2\u639B\u91D1\u306E\u6708\u6B21\u7DE0\u3081\uFF08\u4E00\u89A7\u30FB\u72B6\u614B\u30FB\u7DE0\u3081\u30FB\u7DE0\u3081\u306E\u89E3\u9664\uFF09",operations:[closingListOperation,closingGetOperation,
49
- closingCloseOperation,closingReopenOperation]};var receivableDomain={name:"receivable",summary:"\u8CA9\u58F2\u7BA1\u7406\u306E\u58F2\u639B\u91D1\u6B8B\u9AD8\uFF08\u57FA\u6E96\u5E74\u6708\u306E\u30B5\u30DE\u30EA\u30FC\u3068\u660E\u7D30\u30FBCSV\uFF09\u3068\u6708\u6B21\u7DE0\u3081\uFF08\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\uFF09",operations:[listOperation,exportOperation],subresources:[closingResource]};export{balanceRows,previousYearMonth,receivableDomain,yearMonthValue};
48
+ closingCloseOperation,closingReopenOperation]};var receivableDomain={name:"receivable",summary:"\u8CA9\u58F2\u7BA1\u7406\u306E\u58F2\u639B\u91D1\u6B8B\u9AD8\uFF08\u57FA\u6E96\u5E74\u6708\u306E\u30B5\u30DE\u30EA\u30FC\u3068\u660E\u7D30\u30FBCSV\uFF09\u3068\u6708\u6B21\u7DE0\u3081\uFF08\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\uFF09",operations:[listOperation,exportOperation],subresources:[closingResource]};export{yearMonthValue,previousYearMonth,balanceRows,receivableDomain};