@tocca-systems/twp-cli 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/command-model/_routes.json +1939 -0
- package/command-model/analysis.json +4 -4
- package/command-model/attendance.json +2 -2
- package/command-model/badge.json +4 -4
- package/command-model/dynamo-inquiry.json +41 -0
- package/command-model/holiday.json +19 -19
- package/command-model/index.json +5 -5
- package/command-model/invoice.json +1 -1
- package/command-model/project.json +42 -0
- package/command-model/sales.json +150 -150
- package/command-model/staff-kpi.json +47 -6
- package/command-model/staffing-plan.json +41 -0
- package/command-model/user-group.json +2 -2
- package/dist/api-command-UIL4WGMG.js +127 -0
- package/dist/{chunk-2SGDY6YP.js → chunk-2VISRLWS.js} +1 -1
- package/dist/{chunk-BPMSIIOU.js → chunk-KXFT226N.js} +11 -11
- package/dist/cli.js +3 -3
- package/dist/{project-KIPSH5GP.js → project-OKTJ32JT.js} +1 -1
- package/dist/run-DWQEHR6I.js +4 -0
- package/dist/{task-UK4QO26W.js → task-7K54BO5U.js} +1 -1
- package/package.json +1 -1
- package/dist/api-command-HGTPIEAP.js +0 -73
- package/dist/run-BJQLIPWN.js +0 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{readBody}from"./chunk-QVXZEUKN.js";import{OUTPUT_FORMATS,evaluateQuery,exitCodeFor,fetchAllPages,redactSecretValues,renderOutput,reportError,resolveOutputFormat,withDebug}from"./chunk-KXFT226N.js";import"./chunk-WVS4W5FY.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-63LDNYGW.js";import{GLOBAL_OPTIONS_HELP,HELP_TOKEN}from"./chunk-FKIZ5ZJU.js";import{parseOperationArgs,repeatedValues}from"./chunk-O52CUEDO.js";import"./chunk-QQRJLH6B.js";
|
|
4
|
+
import"./chunk-7WEYBZSK.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JKSXUBND.js";import"./chunk-II5RVJQN.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,positiveInteger,readEnvelopeCursor,shellQuote}from"./chunk-2VISRLWS.js";
|
|
5
|
+
import{EXIT_OK,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";import{readFile}from"fs/promises";import{existsSync}from"fs";import{dirname,join,resolve}from"path";import{fileURLToPath}from"url";var DIR_NAME="command-model";var cachedDir;function commandModelDir(){if(cachedDir!==void 0)return cachedDir;let current=dirname(fileURLToPath(import.meta.url));for(let depth=0;depth<6;depth+=1){const candidate=join(current,DIR_NAME);if(existsSync(join(candidate,"index.json"))){cachedDir=candidate;return cachedDir}if(existsSync(join(current,"package.json")))break;const parent=resolve(
|
|
6
|
+
current,"..");if(parent===current)break;current=parent}cachedDir=null;return cachedDir}var CommandModelMissingError=class extends Error{constructor(detail){super(`\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\uFF08${DIR_NAME}/\uFF09\u3092\u8AAD\u3081\u307E\u305B\u3093: ${detail}
|
|
7
|
+
\u958B\u767A\u6642\u306F \`npm run generate:command-model -- --spec <api.json>\` \u3067\u751F\u6210\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);this.name="CommandModelMissingError"}};var domainCache=new Map;var routesCache=null;async function readJson(file){const dir=commandModelDir();if(dir===null)throw new CommandModelMissingError("\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u3042\u308A\u307E\u305B\u3093");const path=join(dir,file);try{return JSON.parse(await readFile(path,"utf8"))}catch(cause){throw new CommandModelMissingError(`${path} \u3092\u8AAD\u3081\u307E\u305B\u3093\uFF08${cause.message}\uFF09`)}}async function loadCommandModelRoutes(){if(routesCache!==null)return routesCache;const file=await readJson("_routes.json");if(typeof file?.routes!=="object"||file.routes===null||Array.isArray(file.routes)){throw new CommandModelMissingError("_routes.json \u306E\u5F62\u304C\u9055\u3044\u307E\u3059\uFF08routes \u304C\u8AAD\u3081\u307E\u305B\u3093\uFF09")}routesCache=file;return routesCache}async function loadCommandModelDomain(domain){const cached=domainCache.get(domain);if(cached!==void 0)return cached;
|
|
8
|
+
if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(domain)){throw new CommandModelMissingError(`\u30C9\u30E1\u30A4\u30F3\u540D\u3068\u3057\u3066\u4E0D\u6B63\u3067\u3059: ${domain}`)}const file=await readJson(`${domain}.json`);if(typeof file?.domain!=="string"||!Array.isArray(file?.operations)){throw new CommandModelMissingError(`${domain}.json \u306E\u5F62\u304C\u9055\u3044\u307E\u3059\uFF08domain / operations \u304C\u8AAD\u3081\u307E\u305B\u3093\uFF09`)}domainCache.set(domain,file);return file}var MIN_SEGMENT_CHARS=3;var parsedCache=new WeakMap;function splitSegments(path){return path.split("/").filter(segment=>segment!=="")}function parseRoutes(routes){const cached=parsedCache.get(routes);if(cached!==void 0)return cached;const parsed=[];for(const[key,domain]of Object.entries(routes.routes)){const space=key.indexOf(" ");if(space<=0)continue;const template=key.slice(space+1);parsed.push({method:key.slice(0,space),template,domain,segments:splitSegments(template).map(segment=>/^\{[^/{}]+\}$/.
|
|
9
|
+
test(segment)?null:segment)})}parsedCache.set(routes,parsed);return parsed}function matches(route,segments){if(route.segments.length!==segments.length)return false;return route.segments.every((literal,i)=>literal===null||literal===segments[i])}function compareSpecificity(a,b){const literals=route=>route.segments.filter(segment=>segment!==null).length;const diff=literals(b)-literals(a);if(diff!==0)return diff;for(let i=0;i<a.segments.length;i+=1){const aLiteral=a.segments[i]!==null;const bLiteral=b.
|
|
10
|
+
segments[i]!==null;if(aLiteral!==bLiteral)return aLiteral?-1:1}return 0}function lookupRoute(routes,method,path){const segments=splitSegments(path);const hits=parseRoutes(routes).filter(route=>matches(route,segments));const sameMethod=hits.filter(route=>route.method===method).sort(compareSpecificity);const best=sameMethod[0];if(best!==void 0)return{kind:"matched",domain:best.domain,template:best.template};if(hits.length>0){const[top]=[...hits].sort(compareSpecificity);const template=top.template;
|
|
11
|
+
const methods=[...new Set(hits.filter(route=>route.template===template).map(route=>route.method))].sort();return{kind:"method-mismatch",template,methods}}return{kind:"unknown"}}function pickOperation(operations,method,template){return operations.find(op=>op.method===method&&op.path===template)??null}async function suggestRoutes(routes,path,limit=5){const{default:fuzzysort}=await import("./fuzzysort-DFVKV4B4.js");const parsed=parseRoutes(routes);const templates=[...new Set(parsed.map(route=>route.
|
|
12
|
+
template))];const literals=new Set(parsed.flatMap(route=>route.segments.filter(segment=>segment!==null)));const kept=splitSegments(path).filter(segment=>literals.has(segment)||!/\d/.test(segment));for(let length=kept.length;length>=2;length-=1){const head=kept.slice(0,length-1);const last=kept[length-1];for(let cut=last.length;cut>=Math.min(MIN_SEGMENT_CHARS,last.length);cut-=1){const results=fuzzysort.go(`/${[...head,last.slice(0,cut)].join("/")}`,templates,{limit});if(results.length>0)return results.
|
|
13
|
+
map(result=>result.target)}}return[]}var MAX_REPORTED_VIOLATIONS=20;function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function typesOf(schema){const type=schema["type"];if(typeof type==="string")return[type];if(Array.isArray(type)&&type.every(t=>typeof t==="string"))return type;return null}var INTEGER_STRING=/^[+-]?\d+$/;var BOOLEAN_STRINGS=new Set(["0","1","true","false","yes","no","on","off"]);var NUMBER_STRING=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function matchesType(type,value){switch(type){case"\
|
|
14
|
+
null":return value===null;case"string":return typeof value==="string";case"integer":return typeof value==="number"&&Number.isInteger(value)||typeof value==="string"&&INTEGER_STRING.test(value);case"number":return typeof value==="number"&&Number.isFinite(value)||typeof value==="string"&&NUMBER_STRING.test(value);case"boolean":return typeof value==="boolean"||value===0||value===1||typeof value==="string"&&BOOLEAN_STRINGS.has(value.toLowerCase());case"array":case"object":return typeof value==="obje\
|
|
15
|
+
ct"&&value!==null;default:return true}}function describe(value){if(value===null)return"null";if(Array.isArray(value))return"\u914D\u5217";if(typeof value==="object")return"\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8";if(typeof value==="string")return`\u6587\u5B57\u5217\uFF08${[...value].length} \u6587\u5B57\uFF09`;return`${typeof value==="number"?"\u6570\u5024":typeof value==="boolean"?"\u771F\u507D\u5024":typeof value} ${String(value)}`}function numericValue(value){if(typeof value==="number")return value;
|
|
16
|
+
if(typeof value==="string"&&NUMBER_STRING.test(value))return Number(value);return null}var PHP_DELIMITED=/^([^A-Za-z0-9\\\s^])[\s\S]*\1[A-Za-z]*$/;function compilePattern(pattern){if(PHP_DELIMITED.test(pattern))return null;try{return new RegExp(pattern,"u")}catch{return null}}function walk(schema,value,at,out){if(!isRecord(schema))return;const types=typesOf(schema);if(types!==null&&!types.some(type=>matchesType(type,value))){out.push(`${at}: ${types.join(" / ")} \u3092\u671F\u5F85\u3057\u307E\u3057\u305F\u304C ${describe(
|
|
17
|
+
value)} \u3067\u3059`);return}if(value===null)return;const enumValues=schema["enum"];if(Array.isArray(enumValues)&&enumValues.length>0){const allowed=enumValues.filter(item=>item!==null).map(item=>String(item));if(!allowed.includes(String(value))){out.push(`${at}: ${allowed.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${describe(value)}\uFF09`)}}if(typeof value==="string"){const length=[...value].length;
|
|
18
|
+
const max=schema["maxLength"];const min=schema["minLength"];if(typeof max==="number"&&length>max)out.push(`${at}: ${max} \u6587\u5B57\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${length} \u6587\u5B57\uFF09`);if(typeof min==="number"&&length<min)out.push(`${at}: ${min} \u6587\u5B57\u4EE5\u4E0A\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${length} \u6587\u5B57\uFF09`);const pattern=schema["pattern"];if(typeof pattern==="string"){const re=compilePattern(pattern);if(re!==null&&!re.
|
|
19
|
+
test(value))out.push(`${at}: \u5F62\u5F0F\u304C\u9055\u3044\u307E\u3059\uFF08${pattern}\uFF09`)}}const numeric=types?.some(type=>type==="integer"||type==="number")?numericValue(value):null;if(numeric!==null){const minimum=schema["minimum"];const maximum=schema["maximum"];if(typeof minimum==="number"&&numeric<minimum)out.push(`${at}: ${minimum} \u4EE5\u4E0A\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${numeric}\uFF09`);if(typeof maximum==="number"&&numeric>maximum)out.push(`${at}: ${maximum} \u4EE5\
|
|
20
|
+
\u4E0B\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${numeric}\uFF09`)}if(Array.isArray(value)){const maxItems=schema["maxItems"];const minItems=schema["minItems"];if(typeof maxItems==="number"&&value.length>maxItems)out.push(`${at}: \u8981\u7D20\u306F ${maxItems} \u4EF6\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${value.length} \u4EF6\uFF09`);if(typeof minItems==="number"&&value.length<minItems)out.push(`${at}: \u8981\u7D20\u306F ${minItems} \u4EF6\u4EE5\u4E0A\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${value.
|
|
21
|
+
length} \u4EF6\uFF09`);if(isRecord(schema["items"]))value.forEach((item,i)=>walk(schema["items"],item,`${at}[${i}]`,out));return}if(isRecord(value)){const required=schema["required"];if(Array.isArray(required)){for(const key of required){if(typeof key==="string"&&!Object.prototype.hasOwnProperty.call(value,key))out.push(`${at}.${key}: \u5FC5\u9808\u3067\u3059`)}}const properties=schema["properties"];if(isRecord(properties)){for(const[key,child]of Object.entries(properties)){if(Object.prototype.hasOwnProperty.
|
|
22
|
+
call(value,key))walk(child,value[key],`${at}.${key}`,out)}}}}function validateBody(schema,body){const out=[];walk(schema,body,"body",out);return out}function validateQuery(params,query){const out=[];for(const param of params){const has=Object.prototype.hasOwnProperty.call(query,param.name)&&query[param.name]!==void 0;if(!has){if(param.required)out.push(`query.${param.name}: \u5FC5\u9808\u3067\u3059`);continue}if(param.source!=="spec")continue;const declared=param.type;const types=typeof declared===
|
|
23
|
+
"string"?[declared]:Array.isArray(declared)?declared.filter(t=>typeof t==="string"):[];const checked=types.filter(type=>type==="integer"||type==="number"||type==="boolean");if(checked.length===0||types.includes("string"))continue;const raw=query[param.name];if(types.includes("null")&&raw==="")continue;if(!checked.some(type=>matchesType(type,raw))){out.push(`query.${param.name}: ${checked.join(" / ")} \u3092\u671F\u5F85\u3057\u307E\u3057\u305F\u304C ${describe(raw)} \u3067\u3059`)}}return out}var API_COMMAND_HELP=`twp api \u2014 API \u306E\u30D1\u30B9\u3092\u76F4\u63A5\u53E9\u304F\uFF08\u30A8\u30B9\u30B1\u30FC\u30D7\u30CF\u30C3\u30C1\uFF09
|
|
24
|
+
|
|
25
|
+
\u4F7F\u3044\u65B9:
|
|
26
|
+
twp api <\u30D1\u30B9> [\u30AA\u30D7\u30B7\u30E7\u30F3]
|
|
27
|
+
|
|
28
|
+
\u753B\u9762\u3067\u3067\u304D\u308B\u64CD\u4F5C\u306F\u3059\u3079\u3066 API \u306E\u30D1\u30B9\u3092\u6301\u3064\u306E\u3067\u3001\u30AD\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\u5C64\uFF08twp task / twp project \u2026\uFF09\u306B
|
|
29
|
+
\u51FA\u3066\u3044\u306A\u3044\u64CD\u4F5C\u3078\u306F\u3053\u3053\u304B\u3089\u5230\u9054\u3067\u304D\u307E\u3059\u3002\u30D1\u30B9\u306F API \u306E\u5951\u7D04\u305D\u306E\u3082\u306E\u306A\u306E\u3067\u3001
|
|
30
|
+
\u3053\u306E CLI \u306F\u30D1\u30B9\u306B\u3064\u3044\u3066\u5F8C\u65B9\u4E92\u63DB\u3092\u7D04\u675F\u3057\u307E\u305B\u3093\u3002
|
|
31
|
+
|
|
32
|
+
\u4F8B:
|
|
33
|
+
twp api /v2/projects?limit=10
|
|
34
|
+
twp api /v2/projects --query-param limit=10
|
|
35
|
+
twp api /v2/tasks/{taskId} --method PUT --body-file body.json --yes
|
|
36
|
+
twp api /v2/attendance/records --method POST --generate-cli-skeleton > in.json
|
|
37
|
+
twp api /v2/attendance/records --method POST --cli-input-json in.json --yes
|
|
38
|
+
|
|
39
|
+
\u30AA\u30D7\u30B7\u30E7\u30F3:
|
|
40
|
+
--method <\u30E1\u30BD\u30C3\u30C9> GET | POST | PUT | PATCH | DELETE\uFF08\u65E2\u5B9A GET\uFF09
|
|
41
|
+
--body-file <\u30D1\u30B9> \u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09
|
|
42
|
+
--cli-input-json <\u30D1\u30B9> \u5168\u5F15\u6570\u3092 JSON \u3067\u6E21\u3059\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09
|
|
43
|
+
\u500B\u5225\u30D5\u30E9\u30B0\u3068\u4F75\u7528\u3057\u305F\u3068\u304D\u306F**\u30D5\u30E9\u30B0\u304C\u52DD\u3061\u307E\u3059**
|
|
44
|
+
--generate-cli-skeleton --cli-input-json \u3078\u6E21\u3059\u5165\u529B\u3072\u306A\u5F62\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3057\u307E\u3059
|
|
45
|
+
\uFF08\u9001\u4FE1\u3082\u30ED\u30B0\u30A4\u30F3\u3082\u884C\u3044\u307E\u305B\u3093\uFF09
|
|
46
|
+
--query-param <k=v> \u30AF\u30A8\u30EA\u5F15\u6570\u3002\u8907\u6570\u6307\u5B9A\u3067\u304D\u307E\u3059
|
|
47
|
+
\u5024\u306E\u4E2D\u306E = \u306F\u5207\u308A\u843D\u3068\u3057\u307E\u305B\u3093\uFF08\u6700\u521D\u306E = \u3067\u5206\u5272\uFF09
|
|
48
|
+
--no-redact \u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u307E\u3059\uFF08\u65E2\u5B9A\u306F\u4F0F\u5B57\u5316\u3059\u308B\uFF09
|
|
49
|
+
\u9375\u306E\u767A\u884C\u306A\u3069\u3001\u4F0F\u305B\u308B\u3068\u5024\u304C\u4F7F\u3048\u306A\u3044\u64CD\u4F5C\u306E\u305F\u3081\u306E\u3082\u306E\u3067\u3059
|
|
50
|
+
|
|
51
|
+
\u51FA\u529B\u306E\u4F0F\u5B57\u5316:
|
|
52
|
+
\u5FDC\u7B54\u306B\u8F09\u308B token / secret / api_key / password \u306A\u3069\u306E\u5024\u306F\u3001\u65E2\u5B9A\u3067 ***\uFF08\u4F0F\u5B57\uFF09\u306B\u3057\u3066\u51FA\u3057\u307E\u3059\u3002
|
|
53
|
+
\u51FA\u529B\u306F\u7AEF\u672B\u3068\u30ED\u30B0\uFF08AI CLI \u306E\u30C8\u30E9\u30F3\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u542B\u3080\uFF09\u306B\u5E73\u6587\u3067\u6B8B\u308B\u305F\u3081\u3067\u3059\u3002
|
|
54
|
+
\u767A\u884C\u3057\u305F\u9375\u3092\u53D7\u3051\u53D6\u308B\u306A\u3069\u5024\u305D\u306E\u3082\u306E\u304C\u8981\u308B\u3068\u304D\u306F --no-redact \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044
|
|
55
|
+
\uFF08\u4ED8\u3051\u305F\u3053\u3068\u306F stderr \u30781\u884C\u51FA\u307E\u3059\uFF09\u3002
|
|
56
|
+
|
|
57
|
+
\u66F8\u304D\u8FBC\u307F\u306E\u6271\u3044:
|
|
58
|
+
GET \u4EE5\u5916\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002\u751F\u30D1\u30B9\u306F\u4EFB\u610F\u306E\u66F8\u304D\u8FBC\u307F\u3078\u5230\u9054\u3067\u304D\u308B\u305F\u3081\u3001
|
|
59
|
+
\u300C\u8AAD\u307F\u53D6\u308A\u4EE5\u5916\u306F\u3059\u3079\u3066\u78BA\u8A8D\u3092\u8981\u3059\u308B\u300D\u306B\u5012\u3057\u3066\u3044\u307E\u3059\u3002
|
|
60
|
+
\u9001\u308B\u5185\u5BB9\u306F --dry-run \u3067\u5148\u306B\u78BA\u8A8D\u3067\u304D\u307E\u3059\uFF08--dry-run \u306F\u9001\u3089\u306A\u3044\u306E\u3067 --yes \u306F\u8981\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
61
|
+
\u5B9F\u884C\u306E\u524D\u306B\u63A5\u7D9A\u5148\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u540D\u3068 URL\uFF09\u3092 stderr \u3078\u51FA\u3057\u307E\u3059\u3002
|
|
62
|
+
|
|
63
|
+
\u9001\u4FE1\u524D\u306E\u691C\u8A3C:
|
|
64
|
+
\u30D1\u30B9\u304C\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\uFF08\u540C\u68B1\u306E API \u5B9A\u7FA9\uFF09\u306B\u8F09\u3063\u3066\u3044\u308C\u3070\u3001\u9001\u308B\u524D\u306B\u30DC\u30C7\u30A3\u3068\u30AF\u30A8\u30EA\u3092\u691C\u8A3C\u3057\u307E\u3059\u3002
|
|
65
|
+
\u5FC5\u9808\u9805\u76EE\u306E\u6B20\u843D\u30FB\u578B\u30FB\u6587\u5B57\u6570\u30FB\u9078\u629E\u80A2\u306E\u9055\u3044\u306F\u3001\u30B5\u30FC\u30D0\u3078\u9001\u3089\u305A\u306B\u7D42\u4E86\u30B3\u30FC\u30C9 2 \u3067\u6B62\u307E\u308A\u307E\u3059\u3002
|
|
66
|
+
\u5B9A\u7FA9\u306F\u30B5\u30FC\u30D0\u306E\u691C\u8A3C\u898F\u5247\u304B\u3089\u63A8\u5B9A\u3057\u305F\u3082\u306E\u306A\u306E\u3067\u3001\u30B5\u30FC\u30D0\u304C\u53D7\u3051\u308B\u306F\u305A\u306E\u5165\u529B\u304C\u62D2\u307E\u308C\u305F\u3068\u304D\u306F
|
|
67
|
+
--no-validate \u3067\u691C\u8A3C\u3092\u5916\u3057\u3066\u9001\u308C\u307E\u3059\uFF08\u5916\u3057\u305F\u3053\u3068\u306F stderr \u30781\u884C\u51FA\u307E\u3059\uFF09\u3002
|
|
68
|
+
--no-validate \u9001\u4FE1\u524D\u306E\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u3092\u884C\u3044\u307E\u305B\u3093
|
|
69
|
+
|
|
70
|
+
\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0:
|
|
71
|
+
\u4E00\u89A7\u306E GET \u306F\u3001\u65E2\u5B9A\u3067\u6700\u5F8C\u306E\u30DA\u30FC\u30B8\u307E\u3067\u8FBF\u3063\u30661\u3064\u306E\u5FDC\u7B54\u306B\u307E\u3068\u3081\u307E\u3059\uFF08\u5224\u5B9A\u306F has_more \u3068
|
|
72
|
+
next_cursor \u3060\u3051\u3067\u3001total \u306F\u8AAD\u307F\u307E\u305B\u3093\uFF09\u3002\u8FBF\u3063\u305F\u30DA\u30FC\u30B8\u6570\u3068\u4EF6\u6570\u306F stderr \u3078\u51FA\u307E\u3059\u3002
|
|
73
|
+
--max-items <\u4EF6\u6570> \u8FBF\u308B\u4E0A\u9650\u4EF6\u6570\uFF08\u65E2\u5B9A ${DEFAULT_MAX_ITEMS}\uFF09\u3002\u4E0A\u9650\u306B\u9054\u3057\u305F\u3089\u3001\u5168\u4EF6\u3067\u306F\u306A\u3044\u3053\u3068\u3092
|
|
74
|
+
\u660E\u793A\u3057\u3066\u6B62\u307E\u308A\u3001\u90E8\u5206\u7684\u306A\u7D50\u679C\u306F\u51FA\u3057\u307E\u305B\u3093\uFF08\u518D\u958B\u7528\u306E\u30AB\u30FC\u30BD\u30EB\u306F stderr \u306B\u51FA\u307E\u3059\uFF09
|
|
75
|
+
--starting-token <\u30AB\u30FC\u30BD\u30EB> \u3053\u306E\u30AB\u30FC\u30BD\u30EB\uFF08\u524D\u56DE\u306E next_cursor\uFF09\u304B\u3089\u53D6\u5F97\u3092\u59CB\u3081\u307E\u3059
|
|
76
|
+
--no-paginate 1\u30DA\u30FC\u30B8\u3060\u3051\u53D6\u5F97\u3057\u307E\u3059\uFF08\u7D9A\u304D\u304C\u3042\u308C\u3070\u3001\u305D\u306E\u53D6\u308A\u65B9\u3092 stderr \u3078\u51FA\u3057\u307E\u3059\uFF09
|
|
77
|
+
|
|
78
|
+
\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306B\u7121\u3044\u30D1\u30B9:
|
|
79
|
+
\u65B0\u3057\u304F\u751F\u3048\u305F\u30EB\u30FC\u30C8\u3067\u3082\u9001\u308C\u307E\u3059\u3002\u305D\u306E\u5834\u5408\u306F\u691C\u8A3C\u3068\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u304C\u52B9\u304B\u306A\u3044\u3053\u3068\u3092 stderr \u3078\u51FA\u3057\u3001
|
|
80
|
+
\u8FD1\u3044\u30D1\u30B9\u304C\u3042\u308C\u3070\u4E26\u3079\u307E\u3059\u3002\u4E00\u89A7\u306E\u7D9A\u304D\u306F\u5FDC\u7B54\u306E next_cursor \u3092 --starting-token \u306B\u6E21\u3057\u3066\u8FBF\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
81
|
+
|
|
82
|
+
${GLOBAL_OPTIONS_HELP}
|
|
83
|
+
`;var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
|
|
84
|
+
`}var API_METHODS=["GET","POST","PUT","PATCH","DELETE"];var API_FLAGS=[{name:"--method",summary:`HTTP \u30E1\u30BD\u30C3\u30C9\uFF08${API_METHODS.join(" / ")}\u30FB\u65E2\u5B9A GET\uFF09`,takesValue:true,placeholder:"<\u30E1\u30BD\u30C3\u30C9>"},{name:"--body-file",summary:"\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"},{name:"--cli-input-json",summary:"\u5168\u5F15\u6570\u3092 JSON \u3067\u6E21\u3059\uFF08-\
|
|
85
|
+
\u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"},{name:"--generate-cli-skeleton",summary:"--cli-input-json \u3078\u6E21\u3059\u5165\u529B\u3072\u306A\u5F62\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B",takesValue:false},{name:"--query-param",summary:"\u30AF\u30A8\u30EA\u5F15\u6570\uFF08k=v\u30FB\u8907\u6570\u6307\u5B9A\u53EF\uFF09",takesValue:true,placeholder:"<k=v>",repeatable:true},{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",
|
|
86
|
+
takesValue:false},{name:"--max-items",summary:`\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u306E\u4E0A\u9650\u4EF6\u6570\uFF08\u65E2\u5B9A ${DEFAULT_MAX_ITEMS}\u30FB\u8D85\u3048\u305F\u3089\u5168\u4EF6\u3067\u306F\u306A\u3044\u3068\u660E\u793A\u3057\u3066\u6B62\u307E\u308B\uFF09`,takesValue:true,placeholder:"<\u4EF6\u6570>"},{name:"--starting-token",summary:"\u3053\u306E\u30AB\u30FC\u30BD\u30EB\uFF08\u524D\u56DE\u306E next_cursor\uFF09\u304B\u3089\u53D6\u5F97\u3092\u59CB\u3081\u308B",takesValue:true,
|
|
87
|
+
placeholder:"<\u30AB\u30FC\u30BD\u30EB>"},{name:"--no-paginate",summary:"\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u3092\u305B\u305A1\u30DA\u30FC\u30B8\u3060\u3051\u53D6\u5F97\u3059\u308B",takesValue:false},{name:"--no-validate",summary:"\u9001\u4FE1\u524D\u306E\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u3092\u884C\u308F\u306A\u3044\uFF08\u691C\u8A3C\u304C\u8AA4\u3063\u3066\u62D2\u3080\u3068\u304D\u7528\uFF09",takesValue:false}];var API_PAGING_VOCABULARY={mode:"\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0",
|
|
88
|
+
resumeFlag:"--starting-token",capAdvice:"--query-param limit=<\u4EF6\u6570> \u30671\u30DA\u30FC\u30B8\u306E\u4EF6\u6570\u3092\u5897\u3084\u3057\u3066\u5F80\u5FA9\u3092\u6E1B\u3089\u3059\u304B\u3001--max-items \u3092\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\u3002"};var ENVELOPE_ITEMS_KEY="items";var CURSOR_PARAM="cursor";var SUGGESTION_LIMIT=5;var MAX_BODY_CHARS=1e6;function normalizeApiPath(raw){const trimmed=raw.trim();if(trimmed==="")throw new UsageError("\u30D1\u30B9\u304C\u7A7A\u3067\u3059",
|
|
89
|
+
"\u4F8B: twp api /v2/projects");if(/^https?:\/\//i.test(trimmed)){throw new UsageError(`\u30D1\u30B9\u306B URL \u306F\u6E21\u305B\u307E\u305B\u3093: ${trimmed}`,"\u63A5\u7D9A\u5148\u306F\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u6C7A\u3081\u307E\u3059\u3002\u30D1\u30B9\u3060\u3051\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: /v2/projects\uFF09\u3002")}const hashIndex=trimmed.indexOf("#");const withoutHash=hashIndex===-1?trimmed:trimmed.slice(0,hashIndex);const queryIndex=withoutHash.
|
|
90
|
+
indexOf("?");const pathPart=queryIndex===-1?withoutHash:withoutHash.slice(0,queryIndex);const queryPart=queryIndex===-1?void 0:withoutHash.slice(queryIndex+1);const withSlash=pathPart.startsWith("/")?pathPart:`/${pathPart}`;const path=withSlash.toLowerCase().startsWith("/api/")?withSlash:`/api${withSlash}`;return{path,query:queryPart===void 0||queryPart===""?void 0:queryPart}}function parseMethod(raw){if(raw===void 0)return"GET";const upper=raw.trim().toUpperCase();if(API_METHODS.includes(upper))
|
|
91
|
+
return upper;throw new UsageError(`--method \u306B\u300C${raw}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${API_METHODS.join(" / ")} \u3067\u3059\u3002`)}function parseQueryParams(values){const out={};for(const raw of values){const index=raw.indexOf("=");if(index<=0){throw new UsageError(`--query-param \u306F k=v \u306E\u5F62\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,"\u4F8B: --query-param limit=10 --query-param keyword=\u4F1A\u8B70")}
|
|
92
|
+
const key=raw.slice(0,index);if(Object.prototype.hasOwnProperty.call(out,key)){throw new UsageError(`--query-param ${key} \u304C\u8907\u6570\u56DE\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`)}out[key]=raw.slice(index+1)}return out}function parseQueryString(raw){if(raw===void 0)return{};const out={};for(const[key,value]of new URLSearchParams(raw))out[key]=value;return out}function buildSkeleton(method,path,query){const skeleton={method,path};const queryEntries=Object.entries(query);skeleton.
|
|
93
|
+
query=queryEntries.length>0?Object.fromEntries(queryEntries.map(([key,value])=>[key,String(value??"")])):{};if(method!=="GET")skeleton.body={};return skeleton}function parseCliInput(text){let parsed;try{parsed=JSON.parse(text)}catch(err){throw new UsageError(`--cli-input-json \u306E JSON \u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}if(parsed===null||typeof parsed!=="object"||Array.isArray(parsed)){throw new UsageError("--cli-input-json \u306B\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
94
|
+
'\u4F8B: {"method":"POST","path":"/v2/...","body":{}}')}const known=new Set(["method","path","query","body"]);const unknown=Object.keys(parsed).filter(key=>!known.has(key));if(unknown.length>0){throw new UsageError(`--cli-input-json \u306B\u77E5\u3089\u306A\u3044\u30AD\u30FC\u304C\u3042\u308A\u307E\u3059: ${unknown.join(" / ")}`,`\u4F7F\u3048\u308B\u306E\u306F ${[...known].join(" / ")} \u3067\u3059\u3002`)}const input=parsed;for(const key of["method","path"]){const value=input[key];if(value!==void 0&&
|
|
95
|
+
typeof value!=="string"){throw new UsageError(`--cli-input-json \u306E ${key} \u306F\u6587\u5B57\u5217\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`)}}if(input.query!==void 0){if(input.query===null||typeof input.query!=="object"||Array.isArray(input.query)){throw new UsageError("--cli-input-json \u306E query \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044")}for(const[key,value]of Object.entries(input.query)){if(typeof value!=="string"&&typeof value!==
|
|
96
|
+
"number"&&typeof value!=="boolean"){throw new UsageError(`--cli-input-json \u306E query.${key} \u306F\u6587\u5B57\u5217\u30FB\u6570\u5024\u30FB\u771F\u507D\u5024\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`)}}}return input}async function runApiCommand(options){const{globals}=options;let format=null;try{const profile=resolveProfile(globals.profile);format=resolveOutputFormat({...globals.output!==void 0?{flag:globals.output}:{},...(()=>{const configured=resolveConfiguredOutput(profile.name);return configured!==
|
|
97
|
+
void 0?{configured}:{}})(),isTty:process.stdout.isTTY===true});if(format===null){throw new UsageError(`--output \u306B\u300C${globals.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${OUTPUT_FORMATS.join(" / ")} \u3067\u3059`)}if(options.help||options.argv[0]===HELP_TOKEN){const extra=options.argv[0]===HELP_TOKEN?options.argv.slice(1):options.argv;if(extra.length>0&&!options.help){throw new UsageError(`twp api help \u306F\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${extra.
|
|
98
|
+
join(" ")}`,"\u30D1\u30B9\u3092\u53E9\u304F\u306A\u3089 help \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: twp api /v2/projects\uFF09\u3002")}writeOut(API_COMMAND_HELP);return EXIT_OK}const input=parseOperationArgs(options.argv,API_FLAGS);const noRedact=input.flags.has("--no-redact");const cliInputText=await readBody(input,{flag:"--cli-input-json-inline",fileFlag:"--cli-input-json",label:"--cli-input-json",maxChars:MAX_BODY_CHARS,usage:"\u4F8B: twp api /v2/projects --method POST --gen\
|
|
99
|
+
erate-cli-skeleton > in.json"});const cliInput=cliInputText===void 0?void 0:parseCliInput(cliInputText);const[pathArg,...extraArgs]=input.args;if(extraArgs.length>0){throw new UsageError(`\u4F59\u5206\u306A\u5F15\u6570\u304C\u3042\u308A\u307E\u3059: ${extraArgs.join(" ")}`,"twp api \u304C\u53D7\u3051\u308B\u4F4D\u7F6E\u5F15\u6570\u306F\u30D1\u30B91\u3064\u3060\u3051\u3067\u3059\u3002\u30AF\u30A8\u30EA\u306F\u30D1\u30B9\u306B\u66F8\u304F\u304B --query-param \u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
100
|
+
const rawPath=pathArg??cliInput?.path;if(rawPath===void 0){throw new UsageError("\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","\u4F8B: twp api /v2/projects?limit=10\uFF08\u4E00\u89A7\u306F twp api help\uFF09")}const{path,query:inlineQuery}=normalizeApiPath(rawPath);const method=parseMethod(input.flags.get("--method")??cliInput?.method);const query={...parseQueryString(inlineQuery),...cliInput?.query??{},...parseQueryParams(repeatedValues(input,"--query-param"))};if(input.flags.
|
|
101
|
+
has("--generate-cli-skeleton")){if(input.flags.has("--body-file")){throw new UsageError("--generate-cli-skeleton \u3068 --body-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","\u3072\u306A\u5F62\u3092\u51FA\u3057\u3066\u304B\u3089\u7DE8\u96C6\u3057\u3001--cli-input-json \u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}writeOut(`${JSON.stringify(buildSkeleton(method,path.replace(/^\/api/,""),query),null,2)}
|
|
102
|
+
`);return EXIT_OK}const bodyText=await readBody(input,{flag:"--body-inline",fileFlag:"--body-file",label:"\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3",maxChars:MAX_BODY_CHARS,usage:"\u4F8B: twp api /v2/projects --method POST --body-file body.json --yes"});let body;if(bodyText!==void 0){try{body=JSON.parse(bodyText)}catch(err){throw new UsageError(`--body-file \u306E JSON \u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}else if(cliInput!==void 0&&"body"in cliInput){body=cliInput.
|
|
103
|
+
body}if(body!==void 0&&method==="GET"){throw new UsageError("GET \u306B\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306F\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093","\u66F8\u304D\u8FBC\u307F\u306A\u3089 --method POST / PUT / PATCH \u3092\u3001\u7D5E\u308A\u8FBC\u307F\u306A\u3089 --query-param \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002")}if(!globals.dryRun&&method!=="GET"&&!globals.yes){throw new UsageError(`twp api \u306F GET \u4EE5\u5916\u306B --yes \u304C\u5FC5\u8981\u3067\u3059\uFF08\u6307\u5B9A: ${method}\
|
|
104
|
+
${path}\uFF09`,"\u9001\u308B\u5185\u5BB9\u306F --dry-run \u3067\u5148\u306B\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002")}const noValidate=input.flags.has("--no-validate");const model=await resolveModel(method,path);const paging=resolveApiPaging(input,model,method,query);if(paging.startingToken!==void 0)query[CURSOR_PARAM]=paging.startingToken;if(model.operation!==null&&!noValidate)assertValid(model.operation,query,body);const plan={method,path,query,...body!==void 0?{body}:{}};const stored=loadCredentials(
|
|
105
|
+
profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);writeErr(`\u63A5\u7D9A\u5148: ${stripTerminalControls(profile.name)} (${stripTerminalControls(apiUrl)})
|
|
106
|
+
`);for(const note of model.notes)writeErr(`${stripTerminalControls(note)}
|
|
107
|
+
`);if(noValidate)writeErr("\u6CE8\u8A18: --no-validate \u306E\u305F\u3081\u9001\u4FE1\u524D\u306E\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u3092\u884C\u3044\u307E\u305B\u3093\u3002\n");if(noRedact){writeErr("\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\n")}if(globals.dryRun){writeOut(line(renderOutput(dryRunValue(apiUrl,plan),format,noRedact)));return EXIT_OK}
|
|
108
|
+
const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);let responseBody;try{responseBody=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(
|
|
109
|
+
`${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}let paged;if(paging.resultPath!==null&&isPageable(responseBody,{...paging,resultPath:paging.resultPath})){paged=await fetchAllPages({client,apiUrl,plan,paging:envelopePaging({label:`${method} ${model.template??path}`,itemsKey:paging.resultPath,cursorParam:CURSOR_PARAM}),maxPages:DEFAULT_MAX_PAGES,maxItems:paging.maxItems,firstPage:responseBody,vocabulary:API_PAGING_VOCABULARY});responseBody=
|
|
110
|
+
paged.body}const source=noRedact?responseBody:redactSecretValues(responseBody);const value=globals.query===void 0?source:await evaluateQuery(globals.query,source);writeOut(line(renderOutput(value,format,noRedact)));if(paged!==void 0&&paged.pages>1){writeErr(`\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.count} \u4EF6\u3092\u53D6\u5F97\u3057\u307E\u3057\u305F\u3002
|
|
111
|
+
`)}if(paged===void 0&&method==="GET"){const note=continuationNote(responseBody,paging);if(note!==null)writeErr(`${stripTerminalControls(note)}
|
|
112
|
+
`)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code);return code}}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;return value}var NOT_APPLIED="\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u3068\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u884C\u3044\u307E\u305B\u3093\u3002";async function resolveModel(method,path){const modelPath=path.replace(/^\/api(?=\/)/i,
|
|
113
|
+
"");try{const routes=await loadCommandModelRoutes();const found=lookupRoute(routes,method,modelPath);if(found.kind==="matched"){const operation=pickOperation((await loadCommandModelDomain(found.domain)).operations,method,found.template);if(operation!==null)return{operation,unmatched:null,template:found.template,notes:[]};return{operation:null,unmatched:"\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306E\u7D22\u5F15\u3068\u5B9A\u7FA9\u304C\u98DF\u3044\u9055\u3063\u3066\u3044\u308B\u305F\u3081",template:null,
|
|
114
|
+
notes:[`\u6CE8\u8A18: \u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306E\u7D22\u5F15\u3068\u5B9A\u7FA9\u304C\u98DF\u3044\u9055\u3063\u3066\u3044\u307E\u3059\uFF08${method} ${found.template}\uFF09\u3002${NOT_APPLIED}`]}}if(found.kind==="method-mismatch"){return{operation:null,unmatched:`\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306B ${method} \u306E\u5B9A\u7FA9\u304C\u7121\u3044\u305F\u3081`,template:null,notes:[`\u6CE8\u8A18: \u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306E ${found.template} \u306B ${method}\
|
|
115
|
+
\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5B9A\u7FA9\u304C\u3042\u308B\u306E\u306F ${found.methods.join(" / ")}\uFF09\u3002${NOT_APPLIED}`]}}const candidates=await suggestRoutes(routes,modelPath,SUGGESTION_LIMIT);return{operation:null,unmatched:"\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306B\u7121\u3044\u30D1\u30B9\u306E\u305F\u3081",template:null,notes:[`\u6CE8\u8A18: \u3053\u306E\u30D1\u30B9\u306F\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306B\u3042\u308A\u307E\u305B\u3093\u3002${NOT_APPLIED}`,
|
|
116
|
+
...candidates.length>0?["\u8FD1\u3044\u30D1\u30B9:",...candidates.map(candidate=>` ${candidate}`)]:[]]}}catch(err){if(!(err instanceof CommandModelMissingError))throw err;const reason=err.message.split("\n")[0]??"";return{operation:null,unmatched:"\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u3092\u8AAD\u3081\u306A\u3044\u305F\u3081",template:null,notes:[`\u6CE8\u8A18: ${reason}\u3002${NOT_APPLIED}`]}}}function unpageableReason(model,method){const{operation}=model;if(method!=="GET")return"GET \u3067\u306F\u306A\
|
|
117
|
+
\u3044\u305F\u3081";if(operation===null)return model.unmatched??"\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u306B\u5B9A\u7FA9\u304C\u7121\u3044\u305F\u3081";if(operation.resultPath==="")return"\u5FDC\u7B54\u304C\u914D\u5217\u305D\u306E\u3082\u306E\u3067\u7D9A\u304D\u3092\u6301\u305F\u306A\u3044\u305F\u3081";return null}function resolveApiPaging(input,model,method,query){const noPaginate=input.flags.has("--no-paginate");const maxItems=positiveInteger(input.flags,"--max-items");const startingToken=input.
|
|
118
|
+
flags.get("--starting-token");const reason=unpageableReason(model,method);if(startingToken!==void 0){if(startingToken.trim()==="")throw new UsageError("--starting-token \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");if(method!=="GET")throw new UsageError("--starting-token \u306F GET \u3067\u3060\u3051\u4F7F\u3048\u307E\u3059");if(query[CURSOR_PARAM]!==void 0){throw new UsageError("--starting-token \u3068\u30AF\u30A8\u30EA\u306E cursor \u304C\u4E21\u65B9\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059",
|
|
119
|
+
"\u3069\u3061\u3089\u304B\u4E00\u65B9\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08--starting-token \u306F\u30AF\u30A8\u30EA\u306E cursor \u306B\u5165\u308A\u307E\u3059\uFF09\u3002")}}if(maxItems!==void 0){if(noPaginate){throw new UsageError("--max-items \u3068 --no-paginate \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","--no-paginate \u306F1\u30DA\u30FC\u30B8\u3060\u3051\u3092\u53D6\u308B\u306E\u3067\u3001\u4E0A\u9650\u4EF6\u6570\u306F\u52B9\u304D\u307E\u305B\u3093\u3002")}
|
|
120
|
+
if(reason!==null){throw new UsageError(`--max-items \u306F\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u3067\u304D\u308B\u4E00\u89A7\u3067\u3060\u3051\u4F7F\u3048\u307E\u3059\uFF08${reason}\uFF09`,"--max-items \u3060\u3051\u3067\u306F\u4F55\u3082\u5909\u308F\u308A\u307E\u305B\u3093\u3002")}}const declared=model.operation?.resultPath??null;const resultPath=noPaginate||reason!==null?null:declared??ENVELOPE_ITEMS_KEY;return{resultPath,inferred:resultPath!==null&&declared===null,maxItems:maxItems??DEFAULT_MAX_ITEMS,
|
|
121
|
+
startingToken,notPagedReason:noPaginate?"--no-paginate \u306E\u305F\u3081":reason}}function assertValid(operation,query,body){const violations=[...validateQuery(operation.queryParams,query),...operation.body!==null&&operation.method!=="GET"?validateBody(operation.body.schema,body??{}):[]];if(violations.length===0)return;const shown=violations.slice(0,MAX_REPORTED_VIOLATIONS).map(violation=>` - ${violation}`);const rest=violations.length-shown.length;throw new UsageError(`\u9001\u4FE1\u524D\u306E\u691C\u8A3C\u3067 ${violations.
|
|
122
|
+
length} \u4EF6\u306E\u554F\u984C\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\uFF08${operation.method} ${operation.path}\uFF09:
|
|
123
|
+
${shown.join("\n")}${rest>0?`
|
|
124
|
+
\u2026\u307B\u304B ${rest} \u4EF6`:""}`,"\u30B9\u30AD\u30FC\u30DE\u306F\u30B5\u30FC\u30D0\u306E\u691C\u8A3C\u898F\u5247\u304B\u3089\u63A8\u5B9A\u3057\u305F\u3082\u306E\u3067\u3059\u3002\u30B5\u30FC\u30D0\u304C\u53D7\u3051\u308B\u306F\u305A\u306E\u5165\u529B\u304C\u62D2\u307E\u308C\u305F\u5834\u5408\u306F --no-validate \u3067\u691C\u8A3C\u3092\u5916\u3057\u3066\u9001\u308C\u307E\u3059\u3002")}function isPageable(body,paging){if(typeof body!=="object"||body===null||Array.isArray(body))return false;
|
|
125
|
+
const hasArray=Array.isArray(body[paging.resultPath]);const{hasMore}=readEnvelopeCursor(body);if(paging.inferred)return hasArray&&hasMore!==void 0;if(hasArray)return true;return hasMore!==void 0&&hasMore!==null&&hasMore!==false}function continuationNote(body,paging){const{hasMore,cursor}=readEnvelopeCursor(body);const why=paging.notPagedReason===null?"":`\uFF08${paging.notPagedReason}1\u30DA\u30FC\u30B8\u3060\u3051\u53D6\u5F97\u3057\u307E\u3057\u305F\uFF09`;if(hasMore===false||hasMore===null||hasMore===
|
|
126
|
+
void 0)return null;if(hasMore!==true){return`\u6CE8\u8A18: \u5FDC\u7B54\u306E has_more \u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${JSON.stringify(hasMore)??"undefined"}\uFF09${why}\u3002\u3053\u308C\u304C\u5168\u4EF6\u304B\u3069\u3046\u304B\u306F\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002`}if(typeof cursor!=="string"||cursor===""){return`\u6CE8\u8A18: \u7D9A\u304D\u304C\u3042\u308B\u3068\u793A\u3055\u308C\u3066\u3044\u307E\u3059\u304C next_cursor \u304C\u3042\u308A\u307E\u305B\u3093${why}\
|
|
127
|
+
\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`}return`\u6CE8\u8A18: \u7D9A\u304D\u304C\u3042\u308A\u307E\u3059${why}\u3002\u7D9A\u304D\u306F --starting-token ${shellQuote(cursor)} \u3067\u53D6\u5F97\u3067\u304D\u307E\u3059\u3002`}export{API_FLAGS,API_METHODS,buildSkeleton,normalizeApiPath,parseCliInput,parseMethod,parseQueryParams,parseQueryString,runApiCommand};
|
|
@@ -13,4 +13,4 @@ if(SHELL_SAFE.test(value))return value;return`'${value.replace(/'/g,"'\\''")}'`}
|
|
|
13
13
|
flags){if(PAGING_CONTROL_FLAGS.has(spec.name))continue;const value=input.flags.get(spec.name);if(value===void 0)continue;flags.push(spec.takesValue?flagSegment(spec.name,value):spec.name)}flags.push(flagSegment("--cursor",cursor));const args=input.args.map(arg=>shellQuote(arg));const separated=input.args.some(arg=>arg.startsWith("-"));return separated?[context.command,...flags,"--",...args].join(" "):[context.command,...args,...flags].join(" ")}function nextPageNotes(body,input,context){const{hasMore,
|
|
14
14
|
cursor}=readEnvelopeCursor(body);if(hasMore!==true){if(hasMore===false||hasMore===null||hasMore===void 0&&cursor===void 0)return[];return[`\u5FDC\u7B54\u306E has_more \u3092\u89E3\u91C8\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u7D9A\u304D\u306E\u6709\u7121\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${JSON.stringify(hasMore)??"undefined"}\uFF09\u3002\u5168\u4EF6\u304C\u8981\u308B\u306A\u3089 --all \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`]}
|
|
15
15
|
if(typeof cursor!=="string"||cursor==="")return["\u7D9A\u304D\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u5FDC\u7B54\u306B next_cursor \u304C\u3042\u308A\u307E\u305B\u3093\u3002"];if(CONTROL_CHARS.test(cursor)){return["\u7D9A\u304D\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u5FDC\u7B54\u306E next_cursor \u306B\u5236\u5FA1\u6587\u5B57\u304C\u542B\u307E\u308C\u308B\u305F\u3081\u6848\u5185\u3092\u51FA\u305B\u307E\u305B\u3093\u3002--all \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002"]}const hint=context.
|
|
16
|
-
flags.some(spec=>spec.name==="--all")?"\uFF08\u5168\u4EF6\u306F --all\uFF09":"";return[`\u7D9A\u304D\u304C\u3042\u308A\u307E\u3059\u3002\u6B21\u306E\u30DA\u30FC\u30B8: ${nextPageCommand(input,cursor,context)}${hint}`]}export{DEFAULT_MAX_PAGES,DEFAULT_MAX_ITEMS,LIST_FLAGS,LIST_PAGING_HELP,positiveInteger,nonEmpty,envelopePaging,shellQuote,nextPageNotes};
|
|
16
|
+
flags.some(spec=>spec.name==="--all")?"\uFF08\u5168\u4EF6\u306F --all\uFF09":"";return[`\u7D9A\u304D\u304C\u3042\u308A\u307E\u3059\u3002\u6B21\u306E\u30DA\u30FC\u30B8: ${nextPageCommand(input,cursor,context)}${hint}`]}export{DEFAULT_MAX_PAGES,DEFAULT_MAX_ITEMS,LIST_FLAGS,LIST_PAGING_HELP,positiveInteger,nonEmpty,readEnvelopeCursor,envelopePaging,shellQuote,nextPageNotes};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
3
|
import{stringWidth}from"./chunk-WVS4W5FY.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-63LDNYGW.js";import{GLOBAL_OPTIONS_HELP,HELP_TOKEN}from"./chunk-FKIZ5ZJU.js";import{parseOperationArgs}from"./chunk-O52CUEDO.js";import{Resolver,requireDefaultProject}from"./chunk-7WEYBZSK.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JKSXUBND.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";
|
|
4
|
-
import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-
|
|
5
|
-
"`).replace(new RegExp(`([?&]${SECRET_KEY_PATTERN}=)[^&\\s"'\`,;)\\]}]+`,"gi"),`$1${REDACTED}`).replace(new RegExp(`(
|
|
6
|
-
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(String(value));return` ${name.toLowerCase()}: ${shown}`})}var BODY_LIMIT=4e3;
|
|
7
|
-
raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
|
|
4
|
+
import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-2VISRLWS.js";import{ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import{ResolveError}from"./chunk-5QCAIKFE.js";import fs from"fs";import path from"path";var SENSITIVE_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-vercel-protection-bypass"]);var REDACTED="***\uFF08\u4F0F\u5B57\uFF09";var SECRET_KEY_PATTERN="[A-Za-z0-9_-]*(?:token|secret|password|passwd|api[_-]?key|credential)[A-Za-z0-9_-]*";var NOT_SECRET_FLAGS="(?:starting-token)";function redactSecrets(text){return text.replace(/\bBearer\s+[^\s"'`,;)\]}]+/gi,`Bearer ${REDACTED}`).replace(new RegExp(`("${SECRET_KEY_PATTERN}"\\s*:\\s*)"(?\
|
|
5
|
+
:[^"\\\\]|\\\\.)*"`,"gi"),`$1"${REDACTED}"`).replace(new RegExp(`([?&]${SECRET_KEY_PATTERN}=)[^&\\s"'\`,;)\\]}]+`,"gi"),`$1${REDACTED}`).replace(new RegExp(`(--(?!${NOT_SECRET_FLAGS}(?:=|\\s))${SECRET_KEY_PATTERN}(?:=|\\s+))('[^']*'|"[^"]*"|[A-Za-z0-9_.~+/=|:%-]+)`,"gi"),`$1${REDACTED}`)}var SECRET_KEY_NAME=new RegExp(`^${SECRET_KEY_PATTERN}$`,"i");function redactSecretValues(value){if(Array.isArray(value))return value.map(item=>redactSecretValues(item));if(value!==null&&typeof value==="object"){
|
|
6
|
+
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(String(value));return` ${name.toLowerCase()}: ${shown}`})}var BODY_LIMIT=4e3;
|
|
7
|
+
function formatBody(raw){const safe=redactSecrets(stripTerminalControls(raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
|
|
8
8
|
\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??
|
|
9
9
|
"GET";const lines=[`[debug] \u2192 ${method} ${redactSecrets(input)}`,...formatHeaders(init?.headers)];if(typeof init?.body==="string")lines.push(` ${formatBody(init.body)}`);write(`${lines.join("\n")}
|
|
10
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)}
|
|
@@ -31,7 +31,7 @@ ${operationSection}${subSection}
|
|
|
31
31
|
${GLOBAL_OPTIONS_HELP}
|
|
32
32
|
`}function renderOperationHelp(op,path2){const sections=[`twp ${path2} ${op.name} \u2014 ${op.summary}`,"","\u4F7F\u3044\u65B9:",` ${op.usage}`];if(op.description!==void 0){sections.push("",...op.description.split("\n"))}if(op.destructive===true){sections.push("","\u26A0 \u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002")}if(op.flags.length>0){sections.push("","\u30AA\u30D7\u30B7\u30E7\u30F3:",alignedList(op.flags.
|
|
33
33
|
map(flag=>[flag.takesValue?`${flag.name} ${flag.placeholder??"<\u5024>"}`:flag.name,flag.summary])))}sections.push("",GLOBAL_OPTIONS_HELP,"");return sections.join("\n")}function renderUnknownOperation(resource,path2,attempted){const names=[...resource.operations.map(op=>op.name),...subresourcesOf(resource).map(sub=>`${sub.name} <\u64CD\u4F5C>`)].join(" / ");return attempted===void 0?`twp ${path2} \u306B\u306F\u64CD\u4F5C\u306E\u6307\u5B9A\u304C\u5FC5\u8981\u3067\u3059\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2}\
|
|
34
|
-
${HELP_TOKEN}`:`twp ${path2} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`}var LOADERS={backlog:async()=>(await import("./backlog-AYEKG575.js")).backlogDomain,project:async()=>(await import("./project-
|
|
34
|
+
${HELP_TOKEN}`:`twp ${path2} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`}var LOADERS={backlog:async()=>(await import("./backlog-AYEKG575.js")).backlogDomain,project:async()=>(await import("./project-OKTJ32JT.js")).projectDomain,task:async()=>(await import("./task-7K54BO5U.js")).taskDomain};async function loadDomain(name){return LOADERS[name]()}var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
|
|
35
35
|
`}function outputValue(operation,format,body){return format==="json"?operation.raw(body):operation.summarize(body)}function requiresYes(operation,yes){return operation.destructive===true&&!yes}function exitCodeForStatus(status){if(status===401)return EXIT_AUTH;if(status===429)return EXIT_API_SERVER;if(status>=400&&status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}function exitCodeFor(err){if(err instanceof UsageError)return EXIT_USAGE;if(err instanceof NotLoggedInError||err instanceof SessionExpiredError)
|
|
36
36
|
return EXIT_AUTH;if(err instanceof ApiError)return exitCodeForStatus(err.status);if(err instanceof ApiResponseError||err instanceof NetworkError)return EXIT_API_SERVER;if(err instanceof ResolveError){return err.status===null?EXIT_API_SERVER:exitCodeForStatus(err.status)}return EXIT_FAILURE}function safeText(text){return redactSecrets(stripTerminalControls(text))}function reportError(err,format,code){const message=safeText(err instanceof Error?err.message:String(err));const rawHint=err instanceof
|
|
37
37
|
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;writeErr(`${JSON.stringify({error:body},null,2)}
|
|
@@ -42,11 +42,11 @@ message}`,{cause:err})}}function resolveDownloadTarget(spec,commandPath,operatio
|
|
|
42
42
|
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.out);if(!fs.
|
|
43
43
|
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;try{received=await args.client.requestBinary(args.plan.method,appendQuery(args.plan.path,args.plan.
|
|
44
44
|
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.
|
|
45
|
-
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})}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType}}
|
|
46
|
-
\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
|
|
47
|
-
const{paging,maxPages,maxItems}=args;const merged=[];const first=args.plan.query?.[paging.cursorParam];let sent=typeof first==="string"?first:"";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=await send(args.client,
|
|
48
|
-
\u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F
|
|
49
|
-
`)}throw err}for(const item of paging.items(body))merged.push(item);const next=paging.nextCursor(body);if(next===null)return{body:paging.withItems(body,merged),pages:page,count:merged.length};if(merged.length>=maxItems)throw capExceeded(
|
|
45
|
+
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})}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType}}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"};
|
|
46
|
+
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 ${vocabulary.resumeFlag} ${shellQuote(cursor)}\
|
|
47
|
+
\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:"";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,
|
|
48
|
+
args.apiUrl,plan)}catch(err){if(page>1){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 ${vocabulary.resumeFlag} ${shellQuote(stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
|
|
49
|
+
`)}throw err}for(const item of paging.items(body))merged.push(item);const next=paging.nextCursor(body);if(next===null)return{body:paging.withItems(body,merged),pages:page,count:merged.length};if(merged.length>=maxItems)throw capExceeded(vocabulary,`\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}\
|
|
50
50
|
\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`)}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")??
|
|
51
51
|
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&&input.flags.has(name)){throw new UsageError(`${name} \u306F --all \u3068\u4F75\u305B\u3066\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,`${name} \u3060\u3051\u3067\u306F\u4F55\u3082\u5909\u308F\u308A\u307E\u305B\u3093`)}}return{
|
|
52
52
|
all,maxPages,maxItems}}function profileAliases(profileName){const aliases=loadUserConfig().profiles?.[profileName]?.aliases;return aliases!==void 0?{aliases}:{}}function buildPrepareContext(args){const cache=new Map;return{resolver:args.resolver,projectId(explicit){if(explicit!==void 0&&explicit.trim()===""){throw new UsageError("--project \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","--project <\u30B3\u30FC\u30C9|ID> \u3092\u6307\u5B9A\u3059\u308B\u304B\u3001--project \u3054\u3068\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
@@ -61,4 +61,4 @@ for(const note of operation.plannedNotes?.(prepared)??[])writeErr(`${safeText(no
|
|
|
61
61
|
`);if(globals.dryRun){writeOut(line(renderOutput(dryRunValue(apiUrl,plan),format)));return EXIT_OK}let body;let paged;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);body=await download({client,apiUrl,plan,target:downloadTarget})}else if(paging.all&&operation.paging!==void 0){paged=await fetchAllPages({client,apiUrl,plan,paging:operation.
|
|
62
62
|
paging,maxPages:paging.maxPages,maxItems:paging.maxItems});body=paged.body}else{body=await send(client,apiUrl,plan)}const value=globals.query!==void 0?await evaluateQuery(globals.query,operation.raw(body)):outputValue(operation,format,body);writeOut(line(renderOutput(value,format)));if(paged!==void 0){writeErr(`--all: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.count} \u4EF6\u3092\u53D6\u5F97\u3057\u307E\u3057\u305F\u3002
|
|
63
63
|
`)}const pagingNotes=operation.paging===void 0?[]:nextPageNotes(body,prepared,{command:`twp ${path2} ${operation.name}`,flags:operation.flags,profile:globals.profile});for(const note of[...pagingNotes,...operation.notes?.(body,prepared)??[]]){writeErr(`${safeText(note)}
|
|
64
|
-
`)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code);return code}}export{redactSecretValues,withDebug,OUTPUT_FORMATS,resolveOutputFormat,evaluateQuery,renderOutput,outputValue,requiresYes,exitCodeFor,reportError,fetchAllPages,resolvePaging,buildPrepareContext,runDomain};
|
|
64
|
+
`)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code);return code}}export{redactSecretValues,withDebug,OUTPUT_FORMATS,resolveOutputFormat,evaluateQuery,renderOutput,outputValue,requiresYes,exitCodeFor,reportError,CURATED_PAGING_VOCABULARY,fetchAllPages,resolvePaging,buildPrepareContext,runDomain};
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ if(out.output!==void 0)out.unknown.push("--output");if(out.query!==void 0)out.un
|
|
|
24
24
|
void 0)out.unknown.push("--counts");if(out.scheduleGate!==void 0)out.unknown.push("--gate")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopForce){out.unknown.push("--force")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopDrain){out.unknown.push("--drain")}if(out.command==="task-loop"&&out.taskLoopAction==="stop"&&out.stopForce&&out.stopDrain){out.unknown.push("--force \u3068 --drain \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");out.stopForce=
|
|
25
25
|
false;out.stopDrain=false}if(out.command==="task-loop"&&out.taskLoopAction!=="setup"){if(out.yes)out.unknown.push("--yes");if(out.ais!==void 0)out.unknown.push("--ai");if(out.workspace!==void 0)out.unknown.push("--workspace");if(out.aiConfigFile!==void 0)out.unknown.push("--ai-config-file");if(out.noAiConfigFile)out.unknown.push("--no-ai-config-file")}if(out.command==="task-loop"&&(out.taskLoopAction==="stop"||out.taskLoopAction==="status")){if(out.safe)out.unknown.push("--safe");if(out.daemon)out.
|
|
26
26
|
unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}if(out.command==="task-loop"&&out.taskLoopAction==="setup"){if(out.engine!==void 0)out.unknown.push("--engine");if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.
|
|
27
|
-
interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}return out}var VERSION=true?"0.
|
|
27
|
+
interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}return out}var VERSION=true?"0.17.0":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
|
|
28
28
|
|
|
29
29
|
\u4F7F\u3044\u65B9:
|
|
30
30
|
twp \u5BFE\u8A71 TUI \u3092\u8D77\u52D5
|
|
@@ -149,8 +149,8 @@ TUI \u5185:
|
|
|
149
149
|
`);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);const args=parseArgv(process.argv.slice(2));if(args.command==="version"){process.stdout.write(`${VERSION}
|
|
150
150
|
`);return}if(args.command==="help"){process.stdout.write(HELP);return}if(args.unknown.length>0){process.stderr.write(`\u4E0D\u660E\u306A\u5F15\u6570: ${args.unknown.join(" ")}
|
|
151
151
|
|
|
152
|
-
${HELP}`);process.exitCode=2;return}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-
|
|
153
|
-
refresh},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-
|
|
152
|
+
${HELP}`);process.exitCode=2;return}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-DWQEHR6I.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:{},argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,refresh:args.
|
|
153
|
+
refresh},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-UIL4WGMG.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-WDWUECN7.js");
|
|
154
154
|
process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-VUWI4ERO.js");const options={profile:args.profile,method:args.loginMethod,tenant:args.tenant,noBrowser:args.loginNoBrowser,cliVersion:VERSION};const runner=args.command==="login"?runLogin:args.command==="logout"?runLogout:runWhoami;process.exitCode=
|
|
155
155
|
await runner(options);return}if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-UGGBVOYU.js");process.exitCode=await runTaskLoop({action:args.taskLoopAction??"run",project:args.project,profile:args.profile,safe:args.safe,daemon:args.daemon,interval:args.interval,maxCycles:args.maxCycles,forceRunner:args.forceRunner,force:args.stopForce,drain:args.stopDrain,engine:args.engine,version:VERSION,verbose:args.verbose,scheduleNow:args.scheduleNow,scheduleCounts:args.scheduleCounts,
|
|
156
156
|
scheduleGate:args.scheduleGate,yes:args.yes,ais:args.ais,workspace:args.workspace,aiConfigFile:args.aiConfigFile,noAiConfigFile:args.noAiConfigFile});return}if(args.command==="print"){const{runOneShot}=await import("./oneshot-HQJEXZHJ.js");process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{isRecord,pick,requireResolved,withResolved}from"./chunk-GFC2ASHE.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-
|
|
3
|
+
import{isRecord,pick,requireResolved,withResolved}from"./chunk-GFC2ASHE.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-2VISRLWS.js";import{ApiResponseError,UsageError}from"./chunk-M3GWY6NT.js";import{collapsesInUrlPath,safeProjectIdPolicy}from"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";var LIST_COLUMNS=["id","code","name","status","effective_status"];var GET_COLUMNS=["id","code","name","status","effective_status","display_flg","closed_flg","task_enabled_flg","start_date","end_date","created_at","updated_at"];var MEMBER_COLUMNS=["user_id","user_name","user_email","role","alias","department_name"];function memberItems(body){const list=isRecord(body)?body["list"]:void 0;if(!Array.isArray(list)){throw new ApiResponseError("\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7\u306E\u5FDC\u7B54\u306B list \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
4
4
|
return list}var listPaging=envelopePaging({label:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7"});function listItems(body){return listPaging.items(body)}function projectObject(body){const project=isRecord(body)?body["project"]:void 0;if(!isRecord(project)){throw new ApiResponseError("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u8A73\u7D30\u306E\u5FDC\u7B54\u306B project \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return project}
|
|
5
5
|
var projectDomain={name:"project",summary:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4E00\u89A7\u30FB\u8A73\u7D30",operations:[{name:"list",summary:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u4E00\u89A7\u3059\u308B",usage:"twp project list [--all] [--limit <\u4EF6\u6570>] [--cursor <\u30AB\u30FC\u30BD\u30EB>] [--keyword <\u8A9E>] [--status <\u72B6\u614B>]",description:"--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002\n--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08id / code / name / status / effective_status\uFF09\u3067\u3059\u3002\n\u6B32\u3057\u3044\u5217\u3060\u3051\u3092\
|
|
6
6
|
\u6A5F\u68B0\u51E6\u7406\u3057\u305F\u3044\u3068\u304D\u306F --query \u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08--query \u306F\u751F\u30C7\u30FC\u30BF\u306B\u5BFE\u3057\u3066\u8A55\u4FA1\u3055\u308C\u307E\u3059\uFF09\u3002\n\n"+LIST_PAGING_HELP,flags:[...LIST_FLAGS,{name:"--keyword",summary:"\u30B3\u30FC\u30C9\u30FB\u540D\u79F0\u306E\u90E8\u5206\u4E00\u81F4\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u8A9E>"},{name:"--status",summary:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u4F8B: active\uFF09",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-KXFT226N.js";import"./chunk-WVS4W5FY.js";import"./chunk-63LDNYGW.js";import"./chunk-FKIZ5ZJU.js";import"./chunk-O52CUEDO.js";import"./chunk-QQRJLH6B.js";import"./chunk-7WEYBZSK.js";import"./chunk-JKSXUBND.js";import"./chunk-II5RVJQN.js";import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";
|
|
4
|
+
import"./chunk-J7QYPKVK.js";import"./chunk-NHYMHCAT.js";import"./chunk-2VISRLWS.js";import"./chunk-M3GWY6NT.js";import"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
3
|
import{PRIVATE_PROJECT_REF,isPrivateProjectRef}from"./chunk-GY7KI5E5.js";import{acknowledgement,isRecord,pick,requireResolved,singleRef,withResolved}from"./chunk-GFC2ASHE.js";import{charCount,readBody}from"./chunk-QVXZEUKN.js";import{repeatedValues}from"./chunk-O52CUEDO.js";import"./chunk-QQRJLH6B.js";import{PRIVATE_TASKS_PATH,TASK_MASTERS}from"./chunk-7WEYBZSK.js";import"./chunk-JKSXUBND.js";import{PRIVATE_TASK_KEY_PREFIX,isPrivateTaskKey,isTaskKey}from"./chunk-II5RVJQN.js";
|
|
4
|
-
import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import"./chunk-J7QYPKVK.js";import"./chunk-NHYMHCAT.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-
|
|
4
|
+
import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import"./chunk-J7QYPKVK.js";import"./chunk-NHYMHCAT.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-2VISRLWS.js";import{ApiResponseError,UsageError}from"./chunk-M3GWY6NT.js";import{isSafePathSegment,safeProjectIdPolicy}from"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";function classifyTaskRef(ref){const value=ref.trim();if(safeProjectIdPolicy.isDirectId(value))return{kind:"id",value};if(isTaskKey(value))return{kind:"key",value};return{kind:"unknown",value}}function wantsPrivateSurface(input){const project=input.flags.get("--project");return project!==void 0&&isPrivateProjectRef(project)}function taskSurface(input,ref){const project=input.flags.get("--project");const{kind,value}=classifyTaskRef(ref);if(project!==void 0&&isPrivateProjectRef(project)){if(kind===
|
|
5
5
|
"key"&&!isPrivateTaskKey(value)){throw new UsageError(`--project ${PRIVATE_PROJECT_REF}\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\uFF09\u306B ${value} \u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306F ${PRIVATE_TASK_KEY_PREFIX}-<\u756A\u53F7> \u306E\u5F62\u3067\u3059\u3002ID\uFF08UUID / ULID\uFF09\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
6
6
|
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u3092\u6307\u3059\u306A\u3089 --project ${PRIVATE_PROJECT_REF} \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return"private"}if(kind==="key"&&isPrivateTaskKey(value)&&project===void 0){throw new UsageError(`${value} \u306F\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306B\u3082\u3001\u30B3\u30FC\u30C9 ${PRIVATE_TASK_KEY_PREFIX} \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u30AD\u30FC\u306B\u3082\u8AAD\u3081\u307E\u3059`,
|
|
7
7
|
`\u3069\u3061\u3089\u3092\u6307\u3059\u304B --project \u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002
|
package/package.json
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
-
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{readBody}from"./chunk-QVXZEUKN.js";import{OUTPUT_FORMATS,evaluateQuery,exitCodeFor,redactSecretValues,renderOutput,reportError,resolveOutputFormat,withDebug}from"./chunk-BPMSIIOU.js";import"./chunk-WVS4W5FY.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-63LDNYGW.js";import{GLOBAL_OPTIONS_HELP,HELP_TOKEN}from"./chunk-FKIZ5ZJU.js";import{parseOperationArgs,repeatedValues}from"./chunk-O52CUEDO.js";import"./chunk-QQRJLH6B.js";
|
|
4
|
-
import"./chunk-7WEYBZSK.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JKSXUBND.js";import"./chunk-II5RVJQN.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-2SGDY6YP.js";import{EXIT_OK,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import"./chunk-5QCAIKFE.js";
|
|
5
|
-
import"./chunk-VSJBJXZO.js";var API_COMMAND_HELP=`twp api \u2014 API \u306E\u30D1\u30B9\u3092\u76F4\u63A5\u53E9\u304F\uFF08\u30A8\u30B9\u30B1\u30FC\u30D7\u30CF\u30C3\u30C1\uFF09
|
|
6
|
-
|
|
7
|
-
\u4F7F\u3044\u65B9:
|
|
8
|
-
twp api <\u30D1\u30B9> [\u30AA\u30D7\u30B7\u30E7\u30F3]
|
|
9
|
-
|
|
10
|
-
\u753B\u9762\u3067\u3067\u304D\u308B\u64CD\u4F5C\u306F\u3059\u3079\u3066 API \u306E\u30D1\u30B9\u3092\u6301\u3064\u306E\u3067\u3001\u30AD\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\u5C64\uFF08twp task / twp project \u2026\uFF09\u306B
|
|
11
|
-
\u51FA\u3066\u3044\u306A\u3044\u64CD\u4F5C\u3078\u306F\u3053\u3053\u304B\u3089\u5230\u9054\u3067\u304D\u307E\u3059\u3002\u30D1\u30B9\u306F API \u306E\u5951\u7D04\u305D\u306E\u3082\u306E\u306A\u306E\u3067\u3001
|
|
12
|
-
\u3053\u306E CLI \u306F\u30D1\u30B9\u306B\u3064\u3044\u3066\u5F8C\u65B9\u4E92\u63DB\u3092\u7D04\u675F\u3057\u307E\u305B\u3093\u3002
|
|
13
|
-
|
|
14
|
-
\u4F8B:
|
|
15
|
-
twp api /v2/projects?limit=10
|
|
16
|
-
twp api /v2/projects --query-param limit=10
|
|
17
|
-
twp api /v2/tasks/{taskId} --method PUT --body-file body.json --yes
|
|
18
|
-
twp api /v2/attendance/records --method POST --generate-cli-skeleton > in.json
|
|
19
|
-
twp api /v2/attendance/records --method POST --cli-input-json in.json --yes
|
|
20
|
-
|
|
21
|
-
\u30AA\u30D7\u30B7\u30E7\u30F3:
|
|
22
|
-
--method <\u30E1\u30BD\u30C3\u30C9> GET | POST | PUT | PATCH | DELETE\uFF08\u65E2\u5B9A GET\uFF09
|
|
23
|
-
--body-file <\u30D1\u30B9> \u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09
|
|
24
|
-
--cli-input-json <\u30D1\u30B9> \u5168\u5F15\u6570\u3092 JSON \u3067\u6E21\u3059\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09
|
|
25
|
-
\u500B\u5225\u30D5\u30E9\u30B0\u3068\u4F75\u7528\u3057\u305F\u3068\u304D\u306F**\u30D5\u30E9\u30B0\u304C\u52DD\u3061\u307E\u3059**
|
|
26
|
-
--generate-cli-skeleton --cli-input-json \u3078\u6E21\u3059\u5165\u529B\u3072\u306A\u5F62\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3057\u307E\u3059
|
|
27
|
-
\uFF08\u9001\u4FE1\u3082\u30ED\u30B0\u30A4\u30F3\u3082\u884C\u3044\u307E\u305B\u3093\uFF09
|
|
28
|
-
--query-param <k=v> \u30AF\u30A8\u30EA\u5F15\u6570\u3002\u8907\u6570\u6307\u5B9A\u3067\u304D\u307E\u3059
|
|
29
|
-
\u5024\u306E\u4E2D\u306E = \u306F\u5207\u308A\u843D\u3068\u3057\u307E\u305B\u3093\uFF08\u6700\u521D\u306E = \u3067\u5206\u5272\uFF09
|
|
30
|
-
--no-redact \u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u307E\u3059\uFF08\u65E2\u5B9A\u306F\u4F0F\u5B57\u5316\u3059\u308B\uFF09
|
|
31
|
-
\u9375\u306E\u767A\u884C\u306A\u3069\u3001\u4F0F\u305B\u308B\u3068\u5024\u304C\u4F7F\u3048\u306A\u3044\u64CD\u4F5C\u306E\u305F\u3081\u306E\u3082\u306E\u3067\u3059
|
|
32
|
-
|
|
33
|
-
\u51FA\u529B\u306E\u4F0F\u5B57\u5316:
|
|
34
|
-
\u5FDC\u7B54\u306B\u8F09\u308B token / secret / api_key / password \u306A\u3069\u306E\u5024\u306F\u3001\u65E2\u5B9A\u3067 ***\uFF08\u4F0F\u5B57\uFF09\u306B\u3057\u3066\u51FA\u3057\u307E\u3059\u3002
|
|
35
|
-
\u51FA\u529B\u306F\u7AEF\u672B\u3068\u30ED\u30B0\uFF08AI CLI \u306E\u30C8\u30E9\u30F3\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u542B\u3080\uFF09\u306B\u5E73\u6587\u3067\u6B8B\u308B\u305F\u3081\u3067\u3059\u3002
|
|
36
|
-
\u767A\u884C\u3057\u305F\u9375\u3092\u53D7\u3051\u53D6\u308B\u306A\u3069\u5024\u305D\u306E\u3082\u306E\u304C\u8981\u308B\u3068\u304D\u306F --no-redact \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044
|
|
37
|
-
\uFF08\u4ED8\u3051\u305F\u3053\u3068\u306F stderr \u30781\u884C\u51FA\u307E\u3059\uFF09\u3002
|
|
38
|
-
|
|
39
|
-
\u66F8\u304D\u8FBC\u307F\u306E\u6271\u3044:
|
|
40
|
-
GET \u4EE5\u5916\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002\u751F\u30D1\u30B9\u306F\u4EFB\u610F\u306E\u66F8\u304D\u8FBC\u307F\u3078\u5230\u9054\u3067\u304D\u308B\u305F\u3081\u3001
|
|
41
|
-
\u300C\u8AAD\u307F\u53D6\u308A\u4EE5\u5916\u306F\u3059\u3079\u3066\u78BA\u8A8D\u3092\u8981\u3059\u308B\u300D\u306B\u5012\u3057\u3066\u3044\u307E\u3059\u3002
|
|
42
|
-
\u9001\u308B\u5185\u5BB9\u306F --dry-run \u3067\u5148\u306B\u78BA\u8A8D\u3067\u304D\u307E\u3059\uFF08--dry-run \u306F\u9001\u3089\u306A\u3044\u306E\u3067 --yes \u306F\u8981\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
43
|
-
\u5B9F\u884C\u306E\u524D\u306B\u63A5\u7D9A\u5148\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u540D\u3068 URL\uFF09\u3092 stderr \u3078\u51FA\u3057\u307E\u3059\u3002
|
|
44
|
-
|
|
45
|
-
\u3044\u307E\u306F\u5165\u3063\u3066\u3044\u306A\u3044\u3082\u306E\uFF08\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u5BFE\u5FDC\u3057\u307E\u3059\uFF09:
|
|
46
|
-
\u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u304C\u672A\u540C\u68B1\u306E\u305F\u3081\u3001\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u30FB\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u30FB\u30D1\u30B9\u5019\u88DC\u306E\u63D0\u793A\u306F\u884C\u3044\u307E\u305B\u3093\u3002
|
|
47
|
-
\u4E00\u89A7\u306E\u7D9A\u304D\u306F\u5FDC\u7B54\u306E next_cursor \u3092 --query-param cursor=\u2026 \u306B\u6E21\u3057\u3066\u8FBF\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
48
|
-
|
|
49
|
-
${GLOBAL_OPTIONS_HELP}
|
|
50
|
-
`;var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
|
|
51
|
-
`}var API_METHODS=["GET","POST","PUT","PATCH","DELETE"];var API_FLAGS=[{name:"--method",summary:`HTTP \u30E1\u30BD\u30C3\u30C9\uFF08${API_METHODS.join(" / ")}\u30FB\u65E2\u5B9A GET\uFF09`,takesValue:true,placeholder:"<\u30E1\u30BD\u30C3\u30C9>"},{name:"--body-file",summary:"\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"},{name:"--cli-input-json",summary:"\u5168\u5F15\u6570\u3092 JSON \u3067\u6E21\u3059\uFF08-\
|
|
52
|
-
\u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"},{name:"--generate-cli-skeleton",summary:"--cli-input-json \u3078\u6E21\u3059\u5165\u529B\u3072\u306A\u5F62\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B",takesValue:false},{name:"--query-param",summary:"\u30AF\u30A8\u30EA\u5F15\u6570\uFF08k=v\u30FB\u8907\u6570\u6307\u5B9A\u53EF\uFF09",takesValue:true,placeholder:"<k=v>",repeatable:true},{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",
|
|
53
|
-
takesValue:false}];var MAX_BODY_CHARS=1e6;function normalizeApiPath(raw){const trimmed=raw.trim();if(trimmed==="")throw new UsageError("\u30D1\u30B9\u304C\u7A7A\u3067\u3059","\u4F8B: twp api /v2/projects");if(/^https?:\/\//i.test(trimmed)){throw new UsageError(`\u30D1\u30B9\u306B URL \u306F\u6E21\u305B\u307E\u305B\u3093: ${trimmed}`,"\u63A5\u7D9A\u5148\u306F\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u6C7A\u3081\u307E\u3059\u3002\u30D1\u30B9\u3060\u3051\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: /v2/projects\uFF09\u3002")}
|
|
54
|
-
const hashIndex=trimmed.indexOf("#");const withoutHash=hashIndex===-1?trimmed:trimmed.slice(0,hashIndex);const queryIndex=withoutHash.indexOf("?");const pathPart=queryIndex===-1?withoutHash:withoutHash.slice(0,queryIndex);const queryPart=queryIndex===-1?void 0:withoutHash.slice(queryIndex+1);const withSlash=pathPart.startsWith("/")?pathPart:`/${pathPart}`;const path=withSlash.toLowerCase().startsWith("/api/")?withSlash:`/api${withSlash}`;return{path,query:queryPart===void 0||queryPart===""?void 0:
|
|
55
|
-
queryPart}}function parseMethod(raw){if(raw===void 0)return"GET";const upper=raw.trim().toUpperCase();if(API_METHODS.includes(upper))return upper;throw new UsageError(`--method \u306B\u300C${raw}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${API_METHODS.join(" / ")} \u3067\u3059\u3002`)}function parseQueryParams(values){const out={};for(const raw of values){const index=raw.indexOf("=");if(index<=0){throw new UsageError(`--query-param \u306F k=v \u306E\
|
|
56
|
-
\u5F62\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,"\u4F8B: --query-param limit=10 --query-param keyword=\u4F1A\u8B70")}const key=raw.slice(0,index);if(Object.prototype.hasOwnProperty.call(out,key)){throw new UsageError(`--query-param ${key} \u304C\u8907\u6570\u56DE\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`)}out[key]=raw.slice(index+1)}return out}function parseQueryString(raw){if(raw===void 0)return{};const out={};for(const[key,value]of new URLSearchParams(raw))out[key]=
|
|
57
|
-
value;return out}function buildSkeleton(method,path,query){const skeleton={method,path};const queryEntries=Object.entries(query);skeleton.query=queryEntries.length>0?Object.fromEntries(queryEntries.map(([key,value])=>[key,String(value??"")])):{};if(method!=="GET")skeleton.body={};return skeleton}function parseCliInput(text){let parsed;try{parsed=JSON.parse(text)}catch(err){throw new UsageError(`--cli-input-json \u306E JSON \u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}if(parsed===
|
|
58
|
-
null||typeof parsed!=="object"||Array.isArray(parsed)){throw new UsageError("--cli-input-json \u306B\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044",'\u4F8B: {"method":"POST","path":"/v2/...","body":{}}')}const known=new Set(["method","path","query","body"]);const unknown=Object.keys(parsed).filter(key=>!known.has(key));if(unknown.length>0){throw new UsageError(`--cli-input-json \u306B\u77E5\u3089\u306A\u3044\u30AD\u30FC\u304C\u3042\u308A\u307E\u3059: ${unknown.
|
|
59
|
-
join(" / ")}`,`\u4F7F\u3048\u308B\u306E\u306F ${[...known].join(" / ")} \u3067\u3059\u3002`)}const input=parsed;for(const key of["method","path"]){const value=input[key];if(value!==void 0&&typeof value!=="string"){throw new UsageError(`--cli-input-json \u306E ${key} \u306F\u6587\u5B57\u5217\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`)}}if(input.query!==void 0){if(input.query===null||typeof input.query!=="object"||Array.isArray(input.query)){throw new UsageError("--cli-input-json \u306E query \u306F\u30AA\u30D6\
|
|
60
|
-
\u30B8\u30A7\u30AF\u30C8\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044")}for(const[key,value]of Object.entries(input.query)){if(typeof value!=="string"&&typeof value!=="number"&&typeof value!=="boolean"){throw new UsageError(`--cli-input-json \u306E query.${key} \u306F\u6587\u5B57\u5217\u30FB\u6570\u5024\u30FB\u771F\u507D\u5024\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`)}}}return input}async function runApiCommand(options){const{globals}=options;let format=null;try{const profile=resolveProfile(
|
|
61
|
-
globals.profile);format=resolveOutputFormat({...globals.output!==void 0?{flag:globals.output}:{},...(()=>{const configured=resolveConfiguredOutput(profile.name);return configured!==void 0?{configured}:{}})(),isTty:process.stdout.isTTY===true});if(format===null){throw new UsageError(`--output \u306B\u300C${globals.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${OUTPUT_FORMATS.join(" / ")} \u3067\u3059`)}if(options.help||options.argv[0]===
|
|
62
|
-
HELP_TOKEN){const extra=options.argv[0]===HELP_TOKEN?options.argv.slice(1):options.argv;if(extra.length>0&&!options.help){throw new UsageError(`twp api help \u306F\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${extra.join(" ")}`,"\u30D1\u30B9\u3092\u53E9\u304F\u306A\u3089 help \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: twp api /v2/projects\uFF09\u3002")}writeOut(API_COMMAND_HELP);return EXIT_OK}const input=parseOperationArgs(options.argv,API_FLAGS);const noRedact=input.flags.
|
|
63
|
-
has("--no-redact");const cliInputText=await readBody(input,{flag:"--cli-input-json-inline",fileFlag:"--cli-input-json",label:"--cli-input-json",maxChars:MAX_BODY_CHARS,usage:"\u4F8B: twp api /v2/projects --method POST --generate-cli-skeleton > in.json"});const cliInput=cliInputText===void 0?void 0:parseCliInput(cliInputText);const[pathArg,...extraArgs]=input.args;if(extraArgs.length>0){throw new UsageError(`\u4F59\u5206\u306A\u5F15\u6570\u304C\u3042\u308A\u307E\u3059: ${extraArgs.join(" ")}`,"tw\
|
|
64
|
-
p api \u304C\u53D7\u3051\u308B\u4F4D\u7F6E\u5F15\u6570\u306F\u30D1\u30B91\u3064\u3060\u3051\u3067\u3059\u3002\u30AF\u30A8\u30EA\u306F\u30D1\u30B9\u306B\u66F8\u304F\u304B --query-param \u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}const rawPath=pathArg??cliInput?.path;if(rawPath===void 0){throw new UsageError("\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","\u4F8B: twp api /v2/projects?limit=10\uFF08\u4E00\u89A7\u306F twp api help\uFF09")}const{path,query:inlineQuery}=normalizeApiPath(
|
|
65
|
-
rawPath);const method=parseMethod(input.flags.get("--method")??cliInput?.method);const query={...parseQueryString(inlineQuery),...cliInput?.query??{},...parseQueryParams(repeatedValues(input,"--query-param"))};if(input.flags.has("--generate-cli-skeleton")){if(input.flags.has("--body-file")){throw new UsageError("--generate-cli-skeleton \u3068 --body-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","\u3072\u306A\u5F62\u3092\u51FA\u3057\u3066\u304B\u3089\u7DE8\u96C6\u3057\u3001--cli-input-json \u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
66
|
-
writeOut(`${JSON.stringify(buildSkeleton(method,path.replace(/^\/api/,""),query),null,2)}
|
|
67
|
-
`);return EXIT_OK}const bodyText=await readBody(input,{flag:"--body-inline",fileFlag:"--body-file",label:"\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3",maxChars:MAX_BODY_CHARS,usage:"\u4F8B: twp api /v2/projects --method POST --body-file body.json --yes"});let body;if(bodyText!==void 0){try{body=JSON.parse(bodyText)}catch(err){throw new UsageError(`--body-file \u306E JSON \u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}else if(cliInput!==void 0&&"body"in cliInput){body=cliInput.
|
|
68
|
-
body}if(body!==void 0&&method==="GET"){throw new UsageError("GET \u306B\u30EA\u30AF\u30A8\u30B9\u30C8\u30DC\u30C7\u30A3\u306F\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093","\u66F8\u304D\u8FBC\u307F\u306A\u3089 --method POST / PUT / PATCH \u3092\u3001\u7D5E\u308A\u8FBC\u307F\u306A\u3089 --query-param \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002")}if(!globals.dryRun&&method!=="GET"&&!globals.yes){throw new UsageError(`twp api \u306F GET \u4EE5\u5916\u306B --yes \u304C\u5FC5\u8981\u3067\u3059\uFF08\u6307\u5B9A: ${method}\
|
|
69
|
-
${path}\uFF09`,"\u9001\u308B\u5185\u5BB9\u306F --dry-run \u3067\u5148\u306B\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002")}const plan={method,path,query,...body!==void 0?{body}:{}};const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);writeErr(`\u63A5\u7D9A\u5148: ${stripTerminalControls(profile.name)} (${stripTerminalControls(apiUrl)})
|
|
70
|
-
`);writeErr("\u6CE8\u8A18: \u30B3\u30DE\u30F3\u30C9\u30E2\u30C7\u30EB\u672A\u540C\u68B1\u306E\u305F\u3081\u3001\u30B9\u30AD\u30FC\u30DE\u691C\u8A3C\u3068\u81EA\u52D5\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u884C\u3044\u307E\u305B\u3093\u3002\n");if(noRedact){writeErr("\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\n")}if(globals.dryRun){writeOut(line(
|
|
71
|
-
renderOutput(dryRunValue(apiUrl,plan),format,noRedact)));return EXIT_OK}const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);let responseBody;try{responseBody=await client.request(plan.method,appendQuery(plan.path,plan.query),plan.body)}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||
|
|
72
|
-
err instanceof SessionExpiredError)throw err;throw new NetworkError(`${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}const source=noRedact?responseBody:redactSecretValues(responseBody);const value=globals.query===void 0?source:await evaluateQuery(globals.query,source);writeOut(line(renderOutput(value,format,noRedact)));return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code);return code}}function dryRunValue(apiUrl,plan){
|
|
73
|
-
const value={method:plan.method,url:`${apiUrl}${appendQuery(plan.path,plan.query)}`};if(plan.body!==void 0)value["body"]=plan.body;return value}export{API_FLAGS,API_METHODS,buildSkeleton,normalizeApiPath,parseCliInput,parseMethod,parseQueryParams,parseQueryString,runApiCommand};
|
package/dist/run-BJQLIPWN.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
-
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-BPMSIIOU.js";import"./chunk-WVS4W5FY.js";import"./chunk-63LDNYGW.js";import"./chunk-FKIZ5ZJU.js";import"./chunk-O52CUEDO.js";import"./chunk-QQRJLH6B.js";import"./chunk-7WEYBZSK.js";import"./chunk-JKSXUBND.js";import"./chunk-II5RVJQN.js";import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import"./chunk-J7QYPKVK.js";
|
|
4
|
-
import"./chunk-NHYMHCAT.js";import"./chunk-2SGDY6YP.js";import"./chunk-M3GWY6NT.js";import"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";export{buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};
|