@tocca-systems/twp-cli 0.112.0 → 0.113.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/CHANGELOG.public.md +4 -0
- package/README.md +1 -1
- package/dist/{api-command-5N3RMVHG.js → api-command-FUZMN2UG.js} +1 -1
- package/dist/{app-VVGTHBTP.js → app-53I4JR7T.js} +1 -1
- package/dist/{chunk-RIMZ26XK.js → chunk-HBX6AOAD.js} +1 -1
- package/dist/{chunk-HPORE33X.js → chunk-RESKTLOO.js} +2 -2
- package/dist/cli.js +11 -5
- package/dist/content-EJARXH6K.js +129 -0
- package/dist/{media-ZOLX3RTZ.js → media-KYJJ4BYG.js} +1 -1
- package/dist/{registry-DQZRZNFP.js → registry-JDY2ICUY.js} +1 -1
- package/dist/{run-KRBLCZRW.js → run-4DK6MYLO.js} +1 -1
- package/package.json +1 -1
- package/dist/content-T6VIKIOW.js +0 -66
package/CHANGELOG.public.md
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
`CHANGELOG.md` に残してあります。顧客向けの履歴は public 公開以降を対象とします。
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
|
+
## 0.113.0
|
|
15
|
+
|
|
16
|
+
`twp content create` / `update` / `delete` で、コンテンツ管理のコンテンツをコマンドから作成・更新・削除できるようになりました。
|
|
17
|
+
|
|
14
18
|
## 0.112.0
|
|
15
19
|
|
|
16
20
|
`twp content` で、コンテンツ管理のコンテンツ・カテゴリ・タグの一覧と内容、変更履歴・差分・公開申請の状況をコマンドから確認できるようになりました。
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ TWP(Tocca Working Platform)を、ターミナルから使うための CLI
|
|
|
38
38
|
| **できる** | `twp search` による TWP 内のコンテンツ(タスク・Wiki・ノート・議事録・FAQ・サポート・ワークフロー等)の横断検索(通常検索と `--ai` の AI検索・種類/プロジェクト/タグ/状態/カテゴリで絞り込み)と、検索できる種類の一覧。閲覧権限の無いものは出ません |
|
|
39
39
|
| **できる** | `twp announcement` による自分に届いているお知らせ(運営・組織)の一覧(未読・確認待ち・語で絞り込み)・本文と返信の表示・未読件数、既読化(1件ずつ・まとめて)・「確認しました」の記録・返信の一覧と投稿 |
|
|
40
40
|
| **できる** | `twp faq` による社内FAQの一覧(語・カテゴリで絞り込み)・質問と回答の表示・質問文からの検索(根拠のFAQまで。回答文は作りません)・カテゴリの一覧と、登録・更新・削除・添付(添付ファイル欄・本文へ差し込む画像/PDF)・Notion データベースからの取り込み(`twp faq notion-import`)。公開対象に含まれるFAQだけが見え、書き込みは「社内FAQ管理」の管理者の権限が要ります |
|
|
41
|
-
| **できる** | `twp content` によるコンテンツ管理(CMS)の読み取り: コンテンツの一覧(語・カテゴリ・状態・公開状態で絞り込み・列の並べ替え)・本文の表示(カテゴリのフォーム定義の項目名で並べる)・変更履歴・下書きと公開中の版の差分・公開申請(ワークフロー)の状況と、`twp content category` / `tag`
|
|
41
|
+
| **できる** | `twp content` によるコンテンツ管理(CMS)の読み取り: コンテンツの一覧(語・カテゴリ・状態・公開状態で絞り込み・列の並べ替え)・本文の表示(カテゴリのフォーム定義の項目名で並べる)・変更履歴・下書きと公開中の版の差分・公開申請(ワークフロー)の状況と、`twp content category` / `tag` によるカテゴリ(フォーム定義)とタグの参照。`twp content create` / `update` / `delete` によるコンテンツの作成(カテゴリのフォーム定義から `--generate-cli-skeleton` でひな形を出し、必須・選択肢・型を送る前に検査。タグ・ファイル参照は名前/ID で指定)・書いた項目だけの更新(送る直前に版を読み直し、他の更新が先に入っていたら送らない)・削除。コンテンツ管理の権限が要ります。公開・カテゴリ/タグの管理はまだありません |
|
|
42
42
|
| **できる** | `twp agent session` によるコンテナエージェント(リポジトリで作業する AI セッション)の起動・追加の指示・再開・停止・削除と、状態・作業ブランチ・PR・会話・実行ログ・変更ファイル(差分)の参照、`twp agent repository` による起動できるリポジトリとブランチの一覧、`twp agent schedule` による定期実行の定義の作成・更新・有効化/無効化・削除・今すぐ実行と実行履歴の参照。`--wait` で作業が止まるまで待ち、最後のアシスタント発言・作業ブランチ・PR URL を出します。起動・指示・再開は AI クレジットを消費します |
|
|
43
43
|
| **できる** | `twp estimate` / `twp invoice` による販売管理の見積・請求の一覧(語・ステータス・取引先・プロジェクト・担当者・日付・回収状況で絞り込み)と詳細。販売管理・顧客管理の権限が要ります |
|
|
44
44
|
| **できる** | `twp estimate` による見積の作成・更新・削除・社内共有メモ・既存の請求の紐づけ・関連入金・部署按分・案件書類(注文書・個別契約書など)の登録・版の差替え・ダウンロードと、注文書からの注文書番号の読み取り・見積書/注文書/注文請書の PDF の書き出し。販売管理・顧客管理の権限が要ります |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-CDAU3M7F.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-
|
|
3
|
+
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-CDAU3M7F.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-HBX6AOAD.js";import"./chunk-RESKTLOO.js";import"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderOutput}from"./chunk-P4QSPSOQ.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";
|
|
4
4
|
import{readBody}from"./chunk-HEH3PUW2.js";import{ALLOW_REDACTED_FLAG,NO_REDACT_FLAG,NO_REDACT_NOTICE}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs,repeatedValues}from"./chunk-VGT2EGH6.js";import"./chunk-MSQ4ZGMA.js";import"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";
|
|
5
5
|
import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,isPageNumberEnvelope,pageRangeNotes,positiveInteger,readEnvelopeCursor,readPageNumberCursor,shellQuote}from"./chunk-MI6HVYR2.js";import"./chunk-3ZRMMBP5.js";import{ApiResponseError,EXIT_OK,EXIT_WAIT_TIMEOUT,NetworkError,UsageError}from"./chunk-VFPY2A23.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{
|
|
6
6
|
httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{HELP_TOKEN}from"./chunk-AAABT3AX.js";import"./chunk-OKATZ4SN.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";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=>/^\{[^/{}]+\}$/.
|
|
@@ -1212,7 +1212,7 @@ cwd()){const listed=await gitListFiles(cwd2);const raw=listed??await walkFiles(c
|
|
|
1212
1212
|
1;const after=/^[^\s]*/.exec(text.slice(cursor))?.[0]??"";return{query,start,end:cursor+after.length}}var TWP_SLASH_ROUTES={"/tasks":{domain:"task",operation:"list"},"/task":{domain:"task",operation:"get"},"/projects":{domain:"project",operation:"list"}};function isTwpSlashCommand(name){return Object.hasOwn(TWP_SLASH_ROUTES,name)}async function runTwpSlashCommand(name,args,deps){const route=TWP_SLASH_ROUTES[name];if(!Object.hasOwn(TWP_SLASH_ROUTES,name)||route===void 0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u30B3\u30DE\u30F3\u30C9: ${name}
|
|
1213
1213
|
`}}const parsed=parseArgv([route.domain,route.operation,...args]);if(parsed.command!=="domain"||parsed.domain!==route.domain){return{code:2,out:"",err:`${name}: \u3053\u306E\u5F15\u6570\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08${args.join(" ")}\uFF09
|
|
1214
1214
|
`}}if(parsed.unknown.length>0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(parsed.unknown)}
|
|
1215
|
-
`}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-
|
|
1215
|
+
`}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-4DK6MYLO.js");try{const code=await runDomain({domain:route.domain,...parsed.operation!==void 0?{operation:parsed.operation}:
|
|
1216
1216
|
{},argv:parsed.domainArgv,help:parsed.domainHelp,globals,version:deps.version,io,...deps.fetchImpl!==void 0?{fetchImpl:deps.fetchImpl}:{}});return{code,out,err}}catch(e){return{code:1,out,err:`${err}${e.message}
|
|
1217
1217
|
`}}}var GIT_LOG_OUTPUT=["9f3c1a2 feat(ui): \u4E00\u89A7\u306E\u30D5\u30A3\u30EB\u30BF\u3092 URL \u30AF\u30A8\u30EA\u3068\u540C\u671F\u3059\u308B","4b8e0d7 fix(ui): \u4EEE\u60F3\u30B9\u30AF\u30ED\u30FC\u30EB\u306E\u884C\u9AD8\u3055\u3092\u5B9F\u6E2C\u5024\u306B\u5408\u308F\u305B\u308B","c15a99e refactor(api): \u4E00\u89A7\u53D6\u5F97\u306E\u30DA\u30FC\u30B8\u30F3\u30B0\u51E6\u7406\u3092\u5171\u901A\u5316\u3059\u308B","2d70f4b test: \u4E00\u89A7\u30D5\u30A3\u30EB\u30BF\u306E\u56DE\u5E30\u30C6\u30B9\u30C8\u3092\u8FFD\u52A0\u3059\u308B",
|
|
1218
1218
|
"a6e2b38 fix(api): \u7A7A\u306E\u691C\u7D22\u6761\u4EF6\u3067\u5168\u4EF6\u8FD4\u3089\u306A\u3044\u3088\u3046\u306B\u3059\u308B","7c40d51 chore(deps): \u958B\u767A\u4F9D\u5B58\u3092\u6700\u65B0\u3078\u66F4\u65B0\u3059\u308B","e83b1c6 docs: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u624B\u9806\u306B Node 22 \u306E\u524D\u63D0\u3092\u8FFD\u8A18\u3059\u308B","b91f7a4 fix(ui): \u30E2\u30FC\u30C0\u30EB\u306E\u91CD\u306A\u308A\u9806\u3092\u6307\u5B9A\u3059\u308B","5a2c8e0 perf(api): \u4E00\u89A7\u306E N+1 \u3092\u89E3\u6D88\u3059\u308B",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{loadDomain}from"./chunk-
|
|
3
|
+
import{loadDomain}from"./chunk-RESKTLOO.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderDocument,renderOutput}from"./chunk-P4QSPSOQ.js";import{NO_REDACT_NOTICE,withCommonFlags}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs}from"./chunk-VGT2EGH6.js";import{Resolver,requireDefaultProject}from"./chunk-MSQ4ZGMA.js";
|
|
4
4
|
import{ResolveError}from"./chunk-HVZUXLQ4.js";import{ApiError,MultipartBody,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-MI6HVYR2.js";import{isRecord}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,EXIT_WAIT_TIMEOUT,NetworkError,UsageError,WaitTimeoutError}from"./chunk-VFPY2A23.js";
|
|
5
5
|
import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredBacklogSpace,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import{HELP_TOKEN}from"./chunk-AAABT3AX.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";import{stringWidth}from"./chunk-UREA4ZIG.js";
|
|
6
6
|
import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs from"fs";import path from"path";function alignedList(entries,indent=" "){const width=entries.reduce((max,[left])=>Math.max(max,stringWidth(left)),0);return entries.map(([left,right])=>`${indent}${left}${" ".repeat(Math.max(0,width-stringWidth(left)))} ${right}`).join("\n")}function subresourcesOf(resource){return resource.subresources??[]}function renderResourceHelp(resource,path2){const subresources=subresourcesOf(resource);const operationSection=resource.operations.length===0?"":`
|
|
@@ -2,9 +2,9 @@ import { createRequire as __twpCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
3
|
var LOADERS={agent:async()=>(await import("./agent-AYLGY3BB.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-PCSEEC5I.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-LZFRA6U4.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-2537EFLH.js")).analysisDomain,announcement:async()=>(await import("./announcement-MIJPGHPT.js")).announcementDomain,"api-key":async()=>(await import("./api-key-43ZSXW62.js")).apiKeyDomain,attendance:async()=>(await import("./attendance-correct-65ABGMLE.js")).
|
|
4
4
|
attendanceDomainWithRecords,"audit-log":async()=>(await import("./audit-log-ZGK7IVLD.js")).auditLogDomain,backlog:async()=>(await import("./backlog-2RACUD5K.js")).backlogDomain,budget:async()=>(await import("./budget-WZXVQWDV.js")).budgetDomain,"business-hours":async()=>(await import("./business-hours-37MRL53C.js")).businessHoursDomain,"business-place":async()=>(await import("./sales-master-DUR6YYIP.js")).businessPlaceDomain,company:async()=>(await import("./company-YI4OVANT.js")).companyDomain,
|
|
5
|
-
content:async()=>(await import("./content-
|
|
5
|
+
content:async()=>(await import("./content-EJARXH6K.js")).contentDomain,contract:async()=>(await import("./contract-RXVHSZJG.js")).contractDomain,corporate:async()=>(await import("./corporate-AQ2LPSBG.js")).corporateDomain,customer:async()=>(await import("./company-YI4OVANT.js")).customerDomain,department:async()=>(await import("./department-65REBZMP.js")).departmentDomain,deposit:async()=>(await import("./deposit-RLIULDRQ.js")).depositDomain,estimate:async()=>(await import("./estimate-7KT5IXH3.js")).
|
|
6
6
|
estimateDomain,evaluation:async()=>(await import("./evaluation-44QSBVVH.js")).evaluationDomain,expense:async()=>(await import("./expense-23HWGLWY.js")).expenseDomain,faq:async()=>(await import("./faq-CTOJOO6T.js")).faqDomain,"fiscal-year":async()=>(await import("./fiscal-year-IUWEC5AA.js")).fiscalYearDomain,holiday:async()=>(await import("./holiday-VWMRG4AH.js")).holidayDomain,"goal-sheet":async()=>(await import("./evaluation-44QSBVVH.js")).goalSheetDomain,inquiry:async()=>(await import("./inquiry-UG2E5ITT.js")).
|
|
7
|
-
inquiryDomain,invoice:async()=>(await import("./invoice-LV2MJK4U.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-4B35R6ZE.js")).jobTitleDomain,knowledge:async()=>(await import("./domain-knowledge-OYT7POYP.js")).knowledgeDomain,leave:async()=>(await import("./leave-KA3SGHYU.js")).leaveDomain,license:async()=>(await import("./license-Q4RQ57DH.js")).licenseDomain,"login-history":async()=>(await import("./login-history-S6NKWDLL.js")).loginHistoryDomain,media:async()=>(await import("./media-
|
|
7
|
+
inquiryDomain,invoice:async()=>(await import("./invoice-LV2MJK4U.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-4B35R6ZE.js")).jobTitleDomain,knowledge:async()=>(await import("./domain-knowledge-OYT7POYP.js")).knowledgeDomain,leave:async()=>(await import("./leave-KA3SGHYU.js")).leaveDomain,license:async()=>(await import("./license-Q4RQ57DH.js")).licenseDomain,"login-history":async()=>(await import("./login-history-S6NKWDLL.js")).loginHistoryDomain,media:async()=>(await import("./media-KYJJ4BYG.js")).
|
|
8
8
|
mediaDomain,meeting:async()=>(await import("./knowledge-7VWTWBER.js")).meetingDomain,note:async()=>(await import("./knowledge-7VWTWBER.js")).noteDomain,notification:async()=>(await import("./notification-5UFR4FQN.js")).notificationDomain,onedrive:async()=>(await import("./onedrive-Z43D26SJ.js")).onedriveDomain,outlook:async()=>(await import("./outlook-DLEA27PZ.js")).outlookDomain,payee:async()=>(await import("./sales-master-DUR6YYIP.js")).payeeDomain,position:async()=>(await import("./position-XXLZAXVO.js")).
|
|
9
9
|
positionDomain,project:async()=>(await import("./project-GSHZGWIF.js")).projectDomain,prospect:async()=>(await import("./prospect-7EBYOBRL.js")).prospectDomain,purchase:async()=>(await import("./purchase-FRJHJY4H.js")).purchaseDomain,qualification:async()=>(await import("./skill-JMK4VX3I.js")).qualificationDomain,receivable:async()=>(await import("./receivable-SVRIFJVZ.js")).receivableDomain,redmine:async()=>(await import("./redmine-RC7KMVWT.js")).redmineDomain,report:async()=>(await import("./report-EY3KIRFT.js")).
|
|
10
10
|
reportDomain,"role-template":async()=>(await import("./evaluation-44QSBVVH.js")).roleTemplateDomain,"rounding-setting":async()=>(await import("./sales-numbering-HVMZBCNG.js")).roundingSettingDomain,"seal-impression":async()=>(await import("./sales-master-DUR6YYIP.js")).sealImpressionDomain,search:async()=>(await import("./search-CNOLTZTG.js")).searchDomain,secret:async()=>(await import("./secret-P42JCOI4.js")).secretDomain,segment:async()=>(await import("./segment-OSPMFLLA.js")).segmentDomain,
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
3
3
|
const require = __twpCreateRequire(import.meta.url);
|
|
4
|
-
import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{parseArgv,quietFromEnv}from"./chunk-YNZZRPI3.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-AAABT3AX.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.
|
|
4
|
+
import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{parseArgv,quietFromEnv}from"./chunk-YNZZRPI3.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-AAABT3AX.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.113.0":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
|
|
5
5
|
|
|
6
6
|
\u4F7F\u3044\u65B9:
|
|
7
7
|
twp \u5BFE\u8A71 TUI \u3092\u8D77\u52D5
|
|
@@ -1061,6 +1061,12 @@ import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{parseArgv,quietFromE
|
|
|
1061
1061
|
twp content list \u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\uFF08CMS\uFF09\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4E00\u89A7\u3059\u308B\uFF08--keyword / --category / --status / --sort\uFF09
|
|
1062
1062
|
twp content get <\u30B3\u30F3\u30C6\u30F3\u30C4ID>
|
|
1063
1063
|
\u30B3\u30F3\u30C6\u30F3\u30C41\u4EF6\u3092\u8868\u793A\u3059\u308B\uFF08--output text \u3067\u672C\u6587\u3092\u9805\u76EE\u540D\u3064\u304D\u3067\u8AAD\u3081\u308B\u5F62\uFF09
|
|
1064
|
+
twp content create --category <\u30AB\u30C6\u30B4\u30EA> --content-file <\u30D1\u30B9>
|
|
1065
|
+
\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4F5C\u6210\u3059\u308B\uFF08--generate-cli-skeleton \u3067\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u304B\u3089\u3072\u306A\u5F62\uFF09
|
|
1066
|
+
twp content update <\u30B3\u30F3\u30C6\u30F3\u30C4ID> --content-file <\u30D1\u30B9>
|
|
1067
|
+
\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u66F8\u304D\u63DB\u3048\u308B\uFF08\u66F8\u3044\u305F\u9805\u76EE\u3060\u3051\u30FB\u7AF6\u5408\u306F\u4E0A\u66F8\u304D\u3057\u306A\u3044\uFF09
|
|
1068
|
+
twp content delete <\u30B3\u30F3\u30C6\u30F3\u30C4ID> --yes
|
|
1069
|
+
\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u524A\u9664\u3059\u308B
|
|
1064
1070
|
twp content history <\u30B3\u30F3\u30C6\u30F3\u30C4ID>
|
|
1065
1071
|
\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5909\u66F4\u5C65\u6B74\u3092\u4E00\u89A7\u3059\u308B
|
|
1066
1072
|
twp content diff <\u30B3\u30F3\u30C6\u30F3\u30C4ID>
|
|
@@ -1648,16 +1654,16 @@ TUI \u5185:
|
|
|
1648
1654
|
\u4F1A\u8A71\u30FB\u30ED\u30FC\u30AB\u30EB\u30C4\u30FC\u30EB\uFF08\u30D5\u30A1\u30A4\u30EB\u30FB\u30B3\u30DE\u30F3\u30C9\u30FBgit\uFF09\u306F\u30C6\u30CA\u30F3\u30C8\u306E\u30AF\u30EC\u30B8\u30C3\u30C8\u3067\u5B9F\u969B\u306B\u52D5\u304D\u307E\u3059\u3002
|
|
1649
1655
|
`;function ignoreEpipe(stream){stream.on("error",err=>{if(err.code==="EPIPE")process.exit(0);throw err})}async function main(){const nodeMajor=Number(process.versions.node.split(".")[0]);if(nodeMajor<22){process.stderr.write(`twp-cli \u306B\u306F Node.js 22 \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728: ${process.versions.node}\uFF09
|
|
1650
1656
|
`);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);if(process.env["TWP_AUTO_UPDATE_WORKER"]==="1"){const{runAutoUpdateWorker}=await import("./auto-update-worker-26OZDLQ7.js");await runAutoUpdateWorker().catch(()=>void 0);return}const[first,...rest]=process.argv.slice(2);if(first==="__complete"||first==="completion"){const completion=await import("./completion-RLEEOJMU.js");if(first==="completion"){process.exitCode=completion.runCompletion(rest,process.stdout,process.stderr);return}
|
|
1651
|
-
const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-
|
|
1657
|
+
const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-JDY2ICUY.js"),import("./config-XYWRBIC6.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);const{runConfigure}=await import("./configure-BJGPASNG.js");process.exitCode=
|
|
1652
1658
|
await runConfigure(rest);return}const args=parseArgv(process.argv.slice(2));if(args.command==="version"){process.stdout.write(`${VERSION}
|
|
1653
1659
|
`);return}if(args.command==="help"){process.stdout.write(HELP);return}if(args.movedCommand!==void 0){const{MOVED_QUEUE_COMMAND_MESSAGE}=await import("./dispatch-ZWCEVLKZ.js");process.stderr.write(MOVED_QUEUE_COMMAND_MESSAGE);process.exitCode=2;return}if(args.unknown.length>0){process.stderr.write(`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(args.unknown)}
|
|
1654
1660
|
|
|
1655
|
-
${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-
|
|
1656
|
-
{},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.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-
|
|
1661
|
+
${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-4DK6MYLO.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
|
|
1662
|
+
{},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.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-FUZMN2UG.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
|
|
1657
1663
|
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,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-QGM225Q7.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.
|
|
1658
1664
|
command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-F665OECQ.js");const options={profile:args.profile,method:args.loginMethod,tenant:args.tenant,noBrowser:args.loginNoBrowser,cliVersion:VERSION,force:args.logoutForce,...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{}};const runner=args.command==="login"?runLogin:args.command==="logout"?runLogout:runWhoami;process.exitCode=await runner(options);return}
|
|
1659
1665
|
if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-FYBNM5KV.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,scheduleGate:args.scheduleGate,
|
|
1660
1666
|
scheduleOp:args.scheduleOp,scheduleConfigOp:args.scheduleConfigOp,scheduleId:args.scheduleId,charterOp:args.charterOp,charterInput:args.charterFile,charterOutput:args.charterOut,charterRevision:args.charterRevision,settingsOp:args.settingsOp,orientationOp:args.orientationOp,orientationArgs:args.orientationArgs,skillOp:args.skillOp,skillName:args.skillName,skillAll:args.skillAll,skillDir:args.skillDir,skillConfig:args.skillConfig,output:args.output,query:args.query,revisionFrom:args.revisionFrom,
|
|
1661
1667
|
revisionTo:args.revisionTo,planOp:args.planOp,capacityOp:args.capacityOp,includeStopped:args.includeStopped,runnerOp:args.runnerOp,runnerId:args.runnerTargetId,triggerOp:args.triggerOp,triggerId:args.triggerId,triggerKey:args.triggerKey,triggerLimit:args.triggerLimit,planEmpty:args.planEmpty,planCheck:args.planCheck,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-SXDITFOC.js");
|
|
1662
|
-
process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-
|
|
1668
|
+
process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-53I4JR7T.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
|
|
1663
1669
|
allowedTools,disallowedTools:args.disallowedTools,model:args.model,profile:args.profile,noTui:args.noTui||!process.stdout.isTTY,doctor:args.doctor,version:VERSION})}await main();
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{composeDocument,htmlToText,metaLine}from"./chunk-62GRAKUD.js";import{boundedText}from"./chunk-JJSBBWJ5.js";import{readBody}from"./chunk-HEH3PUW2.js";import"./chunk-W4NLJ2YK.js";import{REDACTED}from"./chunk-BD7O73GK.js";import{CMS_PATH}from"./chunk-MSQ4ZGMA.js";import{UUID_RE,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,
|
|
4
|
+
LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-MI6HVYR2.js";import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";import{isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,UsageError}from"./chunk-VFPY2A23.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";var CONTENTS_PATH=`${CMS_PATH}/contents`;var CATEGORIES_PATH=`${CMS_PATH}/categories`;var TAGS_PATH=`${CMS_PATH}/tags`;var MEDIA_FILES_PATH="/api/v2/media/files";var WRITABLE_KEYS=["title","slug","content","tag_ids","publish_start_date","publish_end_date"];var CONTENT_MAX_CHARS=2e6;var TITLE_MAX=500;var SLUG_RE=/^[a-z0-9_-]+$/;var OPTION_TYPES=new Set(["select","radio"]);var STRING_FORMATS={date:{re:/^\d{4}-\d{2}-\d{2}$/,example:"2026-10-29"},ym:{re:/^\d{4}-\d{2}$/,example:"2026-10"},time:{re:/^\d{2}:\d{2}$/,
|
|
5
|
+
example:"09:30"},datetime:{re:/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,example:"2026-10-29T09:30"}};var FORBIDDEN="\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u3092\u4F7F\u3046\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u306E\u30E9\u30A4\u30BB\u30F3\u30B9\u3068\u3001\u3042\u306A\u305F\u306E\u300C\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u300D\u306E\u6A5F\u80FD\u6A29\u9650\u3092\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
6
|
+
var CONFLICT="\u4ED6\u306E\u4EBA\u306E\u66F4\u65B0\u304B\u516C\u958B\u7533\u8ACB\u304C\u5148\u306B\u5165\u3063\u305F\u305F\u3081\u3001\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\u3067\u3057\u305F\uFF08409\uFF09\u3002twp content get <\u30B3\u30F3\u30C6\u30F3\u30C4ID> \u3067\u4ECA\u306E\u5185\u5BB9\u3092\u8AAD\u307F\u76F4\u3057\u3066\u304B\u3089\u3001\u3082\u3046\u4E00\u5EA6 update \u3057\u3066\u304F\u3060\u3055\u3044\u3002";var CONTENT_FILE_FLAG={name:"--content-file",summary:"\u66F8\u304D\u8FBC\u3080\u5185\u5BB9\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \
|
|
7
|
+
\u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"};var SKELETON_FLAG={name:"--generate-cli-skeleton",summary:"--category \u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u304B\u3089 --content-file \u306E\u3072\u306A\u5F62\u3092\u51FA\u3057\u3066\u7D42\u4E86\u3059\u308B\uFF08\u4F5C\u6210\u3057\u306A\u3044\uFF09",takesValue:false};var CATEGORY_FLAG={name:"--category",summary:"\u4F5C\u6210\u5148\u306E\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09",
|
|
8
|
+
takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"};var CONTENT_REF_FLAG={name:"--content",summary:"\u5BFE\u8C61\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30B3\u30F3\u30C6\u30F3\u30C4ID>"};var VALUE_HELP="--content-file \u306F\u6B21\u306E\u30AD\u30FC\u3092\u6301\u3064 JSON \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3059\uFF08\u66F8\u304B\u306A\u3044\u30AD\u30FC\u306F\u9001\u308A\u307E\u305B\u3093\uFF09\u3002\n title\uFF08\u5FC5\u9808\u30FB500\u5B57\u307E\u3067\uFF09/ slug\uFF08\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB-\u30FB_\uFF09/ content\uFF08\u9805\u76EE\u540D \u2192 \u5024\uFF09/ tag_ids\uFF08\u81EA\u7531\u30BF\u30B0\u306E ID\u30FB\u5024\u30FB\u8868\u793A\u540D\u306E\u914D\u5217\uFF09\n publish_start_date / publish_e\
|
|
9
|
+
nd_date\uFF08\u516C\u958B\u671F\u9593\uFF09\ncontent \u306E\u5024\u306F\u9805\u76EE\u306E\u578B\u3054\u3068\u306B\u6B21\u306E\u5F62\u3067\u66F8\u304D\u307E\u3059\uFF08\u9805\u76EE\u540D\u306F twp content category get <\u30AB\u30C6\u30B4\u30EA> \u306E name \u5217\uFF09\u3002\n text / textarea / url: \u6587\u5B57\u5217 \uFF0F number: \u6570\u5024 \uFF0F boolean: true / false\n date: 2026-10-29 \uFF0F datetime: 2026-10-29T09:30 \uFF0F time: 09:30 \uFF0F ym: 2026-10\n select / radio: \u9078\u629E\u80A2\u306E key\uFF08\u8868\u793A\u540D\u3067\u3082\u53EF\uFF09\uFF0F checkbox: \u9078\u629E\u80A2\u306E key \u306E\u914D\u5217\uFF08\u9078\u629E\u80A2\u306E\u7121\u3044\u9805\u76EE\u306F true / false\uFF09\n richtext: HTML \u306E\u6587\u5B57\u5217\uFF08Markdown \u306F\u5909\u63DB\u3057\u307E\u305B\u3093\u3002<p>\u2026</p> \u306E\u5F62\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\n tag: \u81EA\u7531\u30BF\u30B0\uFF08twp content tag free\uFF09\u306E ID\u30FB\u5024\u30FB\u8868\u793A\u540D\u306E\u914D\u5217\uFF08\u8868\u793A\u540D\u304C\u91CD\u306A\u308B\u3068\u304D\u306F ID \u304B\u5024\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\n file_reference: \u30D5\u30A1\u30A4\u30EB\u7BA1\u7406\u306E\u30D5\u30A1\u30A4\u30EB ID \u306E\u914D\u5217\uFF08ID \u3060\u3051\u66F8\u3051\u3070\u3001\u30D5\u30A1\u30A4\u30EB\u540D\u306A\
|
|
10
|
+
\u3069\u306F\u8AAD\u307F\u306B\u884C\u3063\u3066\u57CB\u3081\u307E\u3059\uFF09\n \u4E0A\u8A18\u4EE5\u5916\u306E\u578B\uFF08attachment_file / user / project / customer \u7B49\uFF09\u306F\u753B\u9762\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30AB\u30C6\u30B4\u30EA\u3067\u306F\u4F5C\u308C\u306A\u3044\u305F\u3081\u3001\n \u540D\u524D\u306E\u89E3\u6C7A\u3084\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306F\u305B\u305A\u3001\u66F8\u3044\u305F\u5024\uFF08ID \u7B49\uFF09\u3092\u305D\u306E\u307E\u307E\u9001\u308A\u307E\u3059\u3002\n\u5FC5\u9808\u9805\u76EE\u306E\u6B20\u843D\u30FB\u9078\u629E\u80A2\u306B\u7121\u3044\u5024\u30FB\u578B\u306E\u9055\u3044\u30FB\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306B\u7121\u3044\u9805\u76EE\u540D\u306F\u3001\u9001\u308B\u524D\u306B\u6B62\u3081\u307E\u3059\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 2\uFF09\u3002";
|
|
11
|
+
function dataRecord(body,what){const row=isRecord(body)?body["data"]:void 0;if(!isRecord(row))throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return row}function formFields(category){const schema=category["schema"];const fields=isRecord(schema)?schema["form_fields"]:void 0;return Array.isArray(fields)?fields.filter(isRecord).filter(f=>typeof f["name"]==="str\
|
|
12
|
+
ing"&&f["name"]!==""):[]}function optionsOf(field){const options=field["options"];if(!Array.isArray(options))return[];return options.filter(isRecord).filter(o=>o["is_legacy"]!==true).map(o=>({key:String(o["key"]),value:String(o["value"]??o["key"])}))}var labelOf=field=>{const name=String(field["name"]);const display=field["display_name"];return typeof display==="string"&&display!==""&&display!==name?`${display}\uFF08${name}\uFF09`:name};function isEmpty(value){return value===null||value===void 0||
|
|
13
|
+
typeof value==="string"&&value.trim()===""||Array.isArray(value)&&value.length===0}function normalizeFieldValue(field,value){const type=String(field["type"]);const label=labelOf(field);if(value===null)return{value:null};if(OPTION_TYPES.has(type)){const options=optionsOf(field);if(typeof value!=="string"&&typeof value!=="number")return{error:`${label} \u306F\u9078\u629E\u80A2\u306E key \u30921\u3064\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`};const raw=String(value);if(raw==="")return{value:""};const hit=options.
|
|
14
|
+
find(o=>o.key===raw)??options.find(o=>o.value===raw);if(hit===void 0)return{error:`${label} \u306B\u9078\u629E\u80A2\u306B\u7121\u3044\u5024\u3067\u3059: ${raw}\uFF08\u9078\u3079\u308B\u306E\u306F ${options.map(o=>`${o.key}=${o.value}`).join(" / ")}\uFF09`};return{value:hit.key}}if(type==="checkbox"){const options=optionsOf(field);if(options.length===0){return typeof value==="boolean"?{value}:{error:`${label} \u306F true \u304B false \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`}}if(!Array.isArray(
|
|
15
|
+
value))return{error:`${label} \u306F\u9078\u629E\u80A2\u306E key \u306E\u914D\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: ["${options[0]?.key??"a"}"]\uFF09`};const keys=[];for(const v of value){const raw=String(v);const hit=options.find(o=>o.key===raw)??options.find(o=>o.value===raw);if(hit===void 0)return{error:`${label} \u306B\u9078\u629E\u80A2\u306B\u7121\u3044\u5024\u3067\u3059: ${raw}\uFF08\u9078\u3079\u308B\u306E\u306F ${options.map(o=>`${o.key}=${o.value}`).join(" /\
|
|
16
|
+
")}\uFF09`};if(!keys.includes(hit.key))keys.push(hit.key)}return{value:keys}}if(type==="boolean")return typeof value==="boolean"?{value}:{error:`${label} \u306F true \u304B false \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`};if(type==="number"){if(value==="")return{value:""};const n=typeof value==="number"?value:typeof value==="string"&&value.trim()!==""?Number(value):Number.NaN;if(!Number.isFinite(n))return{error:`${label} \u306F\u6570\u5024\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: ${JSON.
|
|
17
|
+
stringify(value)}`};const min=field["min_value"];const max=field["max_value"];if(typeof min==="number"&&n<min)return{error:`${label} \u306F ${min} \u4EE5\u4E0A\u3067\u3059: ${n}`};if(typeof max==="number"&&n>max)return{error:`${label} \u306F ${max} \u4EE5\u4E0B\u3067\u3059: ${n}`};return{value:n}}const format=STRING_FORMATS[type];if(format!==void 0){if(typeof value!=="string")return{error:`${label} \u306F\u6587\u5B57\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: ${format.example}\
|
|
18
|
+
\uFF09`};if(value!==""&&!format.re.test(value))return{error:`${label} \u306E\u5F62\u304C\u9055\u3044\u307E\u3059: ${value}\uFF08\u4F8B: ${format.example}\uFF09`};return{value}}if(type==="text"||type==="textarea"||type==="url"||type==="richtext"){if(typeof value!=="string")return{error:`${label} \u306F\u6587\u5B57\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`};const maxLength=field["max_length"];if(typeof maxLength==="number"&&type!=="richtext"&&[...value].length>maxLength)return{error:`${label}\
|
|
19
|
+
\u306F ${maxLength} \u6587\u5B57\u307E\u3067\u3067\u3059\uFF08${[...value].length} \u6587\u5B57\uFF09`};return{value}}if(type==="tag"||type==="file_reference"){if(!Array.isArray(value))return{error:`${label} \u306F\u914D\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: ["<ID>"]\uFF09`};return{value}}return{value}}function parseContentFile(text,source,mode,fields){const parsed=contentObject(text,source);const errors=[];const unknownKeys=Object.keys(parsed).filter(k=>!WRITABLE_KEYS.
|
|
20
|
+
includes(k));if(unknownKeys.length>0){errors.push(`\u66F8\u3051\u306A\u3044\u30AD\u30FC\u304C\u3042\u308A\u307E\u3059: ${unknownKeys.join(", ")}\uFF08\u66F8\u3051\u308B\u306E\u306F ${WRITABLE_KEYS.join(" / ")}\u3002\u30AB\u30C6\u30B4\u30EA\u306F --category \u3067\u6307\u5B9A\u3057\u3001\u4F5C\u6210\u5F8C\u306F\u5909\u3048\u3089\u308C\u307E\u305B\u3093\uFF09`)}const out={};if("title"in parsed||mode==="create"){const title=parsed["title"];if(typeof title!=="string"||title.trim()==="")errors.push("\
|
|
21
|
+
title\uFF08\u30BF\u30A4\u30C8\u30EB\uFF09\u306F\u5FC5\u9808\u3067\u3059");else if([...title].length>TITLE_MAX)errors.push(`title \u306F ${TITLE_MAX} \u6587\u5B57\u307E\u3067\u3067\u3059`);else out["title"]=title}if("slug"in parsed){const slug=parsed["slug"];if(slug===null||slug==="")out["slug"]=null;else if(typeof slug!=="string"||!SLUG_RE.test(slug)||slug.length>255)errors.push(`slug \u306F\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB-\u30FB_ \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: ${JSON.
|
|
22
|
+
stringify(slug)}`);else out["slug"]=slug}for(const key of["publish_start_date","publish_end_date"]){if(!(key in parsed))continue;const value=parsed[key]===""?null:parsed[key];if(value!==null&&(typeof value!=="string"||Number.isNaN(Date.parse(value))))errors.push(`${key} \u306F\u65E5\u6642\u306E\u6587\u5B57\u5217\u304B null \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: ${JSON.stringify(value)}`);else out[key]=value}if("tag_ids"in parsed){const tags=parsed["tag_ids"];if(tags!==null&&(!Array.isArray(
|
|
23
|
+
tags)||tags.some(t=>typeof t!=="string"||t.trim()==="")))errors.push("tag_ids \u306F\u30BF\u30B0\u306E ID\u30FB\u5024\u30FB\u8868\u793A\u540D\u306E\u914D\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044");else out["tag_ids"]=tags??[]}if("content"in parsed){const values=parsed["content"];if(!isRecord(values)){errors.push("content \u306F\u300C\u9805\u76EE\u540D \u2192 \u5024\u300D\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044")}else{const byName=new Map(
|
|
24
|
+
fields.map(f=>[String(f["name"]),f]));const content={};for(const[name,value]of Object.entries(values)){const field=byName.get(name);if(field===void 0){errors.push(`content.${name} \u306F\u3053\u306E\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306B\u3042\u308A\u307E\u305B\u3093\uFF08\u9805\u76EE\u540D\u306F ${[...byName.keys()].join(" / ")||"\uFF08\u9805\u76EE\u306A\u3057\uFF09"}\uFF09`);continue}const result=normalizeFieldValue(field,value);if("error"in result)errors.push(
|
|
25
|
+
result.error);else content[name]=result.value}out["content"]=content}}else if(mode==="create"){out["content"]={}}if(errors.length>0)throw new UsageError(`${source} \u306B\u9001\u308C\u306A\u3044\u5024\u304C\u3042\u308A\u307E\u3059:
|
|
26
|
+
${errors.map(e=>` - ${e}`).join("\n")}`,"--generate-cli-skeleton \u3067\u3072\u306A\u5F62\u3068\u5404\u9805\u76EE\u306E\u578B\u3092\u51FA\u305B\u307E\u3059\u3002");return out}function missingRequired(fields,content){return fields.filter(f=>f["required"]===true&&isEmpty(content[String(f["name"])])).map(labelOf)}async function tagRows(ctx,cache){if(cache.rows!==void 0)return cache.rows;const body=await ctx.send({method:"GET",path:`${TAGS_PATH}/free`});const list=isRecord(body)?body["data"]:void 0;
|
|
27
|
+
if(!Array.isArray(list))throw new ApiResponseError("\u81EA\u7531\u30BF\u30B0\u4E00\u89A7\u306E\u5FDC\u7B54\u306B data \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");cache.rows=list.filter(isRecord);return cache.rows}async function tagIdOf(ref,where,ctx,cache){const value=ref.trim();const rows=await tagRows(ctx,cache);if(UUID_RE.test(value)){if(rows.some(r=>r["id"]===value))return value;throw new UsageError(`${where}\
|
|
28
|
+
\u306E\u30BF\u30B0 ${value} \u306F\u81EA\u7531\u30BF\u30B0\u306E\u4E00\u89A7\u306B\u3042\u308A\u307E\u305B\u3093\uFF08\u753B\u9762\u306E\u30BF\u30B0\u6B04\u3067\u8868\u793A\u3067\u304D\u306A\u3044\u305F\u3081\u4ED8\u3051\u307E\u305B\u3093\uFF09`,"\u4ED8\u3051\u3089\u308C\u308B\u30BF\u30B0\u306F twp content tag free \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002")}const byValue=rows.filter(r=>r["value"]===value);const hits=byValue.length>0?byValue:rows.filter(r=>r["display_name"]===value);if(hits.
|
|
29
|
+
length===1&&typeof hits[0]?.["id"]==="string")return hits[0]["id"];if(hits.length===0)throw new UsageError(`${where} \u306E\u30BF\u30B0\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${value}`,"\u4ED8\u3051\u3089\u308C\u308B\u30BF\u30B0\u306F twp content tag free \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\uFF08ID\u30FB\u5024\u30FB\u8868\u793A\u540D\u3067\u6307\u5B9A\u3067\u304D\u307E\u3059\uFF09\u3002");throw new UsageError(`${where} \u306E\u30BF\u30B0\u300C${value}\u300D\u306B\u5F53\u305F\u308B\u30BF\u30B0\u304C ${hits.
|
|
30
|
+
length} \u4EF6\u3042\u308A\u307E\u3059: ${hits.map(h=>`${String(h["id"])}\uFF08${String(h["scope"]??"")}\uFF09`).join(" / ")}`,"ID \u304B\u5024\uFF08value\uFF09\u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}async function fileReferenceOf(ref,where,ctx){if(isRecord(ref)&&typeof ref["id"]==="string"&&typeof ref["file_name"]==="string"&&typeof ref["content_type"]==="string")return ref;const id=isRecord(ref)?ref["id"]:ref;if(typeof id!=="string"||id.trim()===""||!isSafePathSegment(
|
|
31
|
+
id.trim())){throw new UsageError(`${where} \u306F\u30D5\u30A1\u30A4\u30EB\u7BA1\u7406\u306E\u30D5\u30A1\u30A4\u30EB ID \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: ${JSON.stringify(ref)}`,"\u30D5\u30A1\u30A4\u30EB\u306E ID \u306F twp media list \u306E id \u5217\u3067\u3059\u3002")}try{const file=dataRecord(await ctx.send({method:"GET",path:`${MEDIA_FILES_PATH}/${encodeURIComponent(id.trim())}`}),"\u30D5\u30A1\u30A4\u30EB");return pick(file,["id","file_name","content_type","file_size","thumb\
|
|
32
|
+
nail_url","public_url"])}catch(error){if(error instanceof ApiError&&error.status===404)throw new UsageError(`${where} \u306E\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${id}`,"\u30D5\u30A1\u30A4\u30EB\u306E ID \u306F twp media list \u306E id \u5217\u3067\u3059\u3002");throw error}}async function resolveReferences(body,fields,ctx){const cache={};const out={...body};if(Array.isArray(body["tag_ids"])){const ids=[];for(const t of body["tag_ids"])ids.push(await tagIdOf(t,
|
|
33
|
+
"tag_ids",ctx,cache));out["tag_ids"]=ids}if(isRecord(body["content"])){const content={...body["content"]};for(const field of fields){const name=String(field["name"]);const value=content[name];if(!Array.isArray(value))continue;if(field["type"]==="tag"){const ids=[];for(const v of value)ids.push(await tagIdOf(String(v),`content.${name}`,ctx,cache));content[name]=ids}else if(field["type"]==="file_reference"){const files=[];for(const v of value)files.push(await fileReferenceOf(v,`content.${name}`,ctx));
|
|
34
|
+
content[name]=files}}out["content"]=content}return out}function contentIdArg(input,usage){const id=singleRef(input,{flag:CONTENT_REF_FLAG.name,label:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID",usage});if(!isSafePathSegment(id))throw new UsageError(`\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${id}`,"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u306F twp content list \u306E id \u5217\u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002");return id}var contentPath=id=>`${CONTENTS_PATH}\
|
|
35
|
+
/${encodeURIComponent(id)}`;var categoryPath=id=>`${CATEGORIES_PATH}/${encodeURIComponent(id)}`;async function categoryIdOf(ref,ctx){const value=ref.trim();if(UUID_RE.test(value))return value;const id=(await ctx.resolver.cmsCategory(value,CATEGORY_FLAG.name)).id;if(!isSafePathSegment(id))throw new ApiResponseError(`\u30B5\u30FC\u30D0\u304C\u8FD4\u3057\u305F\u30AB\u30C6\u30B4\u30EA\u306E ID \u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${id}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
36
|
+
return id}function contentObject(text,source){let parsed;try{parsed=JSON.parse(text)}catch(error){throw new UsageError(`${source} \u3092 JSON \u3068\u3057\u3066\u8AAD\u3081\u307E\u305B\u3093: ${error.message}`,"--generate-cli-skeleton \u3067\u3072\u306A\u5F62\u3092\u51FA\u305B\u307E\u3059\u3002")}if(!isRecord(parsed))throw new UsageError(`${source} \u306F JSON \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`);return parsed}async function readContentFile(input,usage){
|
|
37
|
+
const text=await readBody(input,{flag:"--content-json",fileFlag:CONTENT_FILE_FLAG.name,label:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5185\u5BB9",maxChars:CONTENT_MAX_CHARS,usage});if(text===void 0)throw new UsageError("\u66F8\u304D\u8FBC\u3080\u5185\u5BB9\u3092 --content-file <\u30D1\u30B9> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","\u3072\u306A\u5F62\u306F twp content create --category <\u30AB\u30C6\u30B4\u30EA> --generate-cli-skeleton \u3067\u51FA\u305B\u307E\u3059\u3002");contentObject(
|
|
38
|
+
text,`--content-file ${input.flags.get(CONTENT_FILE_FLAG.name)??""}`);return text}async function sendGuarded(ctx,plan){try{return await ctx.send(plan)}catch(error){if(error instanceof ApiError&&error.status===409)throw new ApiRejectedError(CONFLICT);throw error}}function serverMessage(body){return isRecord(body)&&typeof body["message"]==="string"?[body["message"]]:[]}var RESULT_COLUMNS=["id","title","slug","category_id","status","publish_status","version","updated_at"];function placeholderOf(field){
|
|
39
|
+
const type=String(field["type"]);const def=field["default_value"];if(def!==void 0&&def!==null&&def!==""){if(type==="number")return Number(def);if(type==="boolean"||type==="checkbox"&&optionsOf(field).length===0)return def==="true"||def===true;return def}if(type==="checkbox")return optionsOf(field).length>0?[]:false;if(type==="boolean")return false;if(type==="number")return null;if(type==="tag"||type==="file_reference")return[];return""}function contentSkeleton(category){return{title:"",slug:null,
|
|
40
|
+
content:Object.fromEntries(formFields(category).map(f=>[String(f["name"]),placeholderOf(f)])),tag_ids:[],publish_start_date:null,publish_end_date:null}}function skeletonNotes(category){const fields=formFields(category);return[`\u30AB\u30C6\u30B4\u30EA\u300C${String(category["name"]??"")}\u300D\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u304B\u3089\u3072\u306A\u5F62\u3092\u4F5C\u308A\u307E\u3057\u305F\u3002\u57CB\u3081\u3066\u304B\u3089 twp content create --category ${String(category["code"]??category["\
|
|
41
|
+
id"])} --content-file <\u30D1\u30B9> \u3067\u9001\u3063\u3066\u304F\u3060\u3055\u3044\u3002`,...fields.map(f=>{const options=optionsOf(f);return` ${labelOf(f)}: ${String(f["type"])}${f["required"]===true?"\u30FB\u5FC5\u9808":""}${options.length>0?`\u30FB\u9078\u629E\u80A2 ${options.map(o=>`${o.key}=${o.value}`).join(" / ")}`:""}`})]}function writeResult(value){if(!isRecord(value)||typeof value["skeleton"]!=="boolean")throw new Error("\u5185\u90E8\u30A8\u30E9\u30FC: content \u306E\u5FDC\u7B54\u306B\u5370\u304C\u3042\u308A\u307E\u305B\u3093\uFF08execute \u306E\u914D\u7DDA\u6F0F\u308C\uFF09");
|
|
42
|
+
return value}var CREATE_USAGE="twp content create --category <\u30AB\u30C6\u30B4\u30EA> (--content-file <\u30D1\u30B9> | --generate-cli-skeleton)";var contentCreateOperation={name:"create",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4F5C\u6210\u3059\u308B\uFF08\u5185\u5BB9\u306F --content-file \u306E JSON\u30FB\u3072\u306A\u5F62\u306F --generate-cli-skeleton\uFF09",usage:CREATE_USAGE,description:`POST /api/v2/cms/contents \u3067\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4E0B\u66F8\u304D\u3068\u3057\u3066\u4F5C\u308A\u307E\u3059\uFF08\u516C\u958B\u306F\u3057\u307E\u305B\u3093\uFF09\u3002
|
|
43
|
+
\u9001\u308B\u524D\u306B\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08GET /api/v2/cms/categories/{id}\uFF09\u3092\u8AAD\u307F\u3001\u9805\u76EE\u3092\u691C\u67FB\u3057\u3001\u30BF\u30B0\u30FB\u30D5\u30A1\u30A4\u30EB\u53C2\u7167\u306E\u540D\u524D\u3092 ID \u306B\u76F4\u3057\u307E\u3059\u3002
|
|
44
|
+
|
|
45
|
+
${VALUE_HELP}
|
|
46
|
+
|
|
47
|
+
--generate-cli-skeleton \u306F --category \u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u304B\u3089\u3001\u5404\u9805\u76EE\u3092\u7A7A\u306B\u3057\u305F\u3072\u306A\u5F62\u3092\u6A19\u6E96\u51FA\u529B\u3078\u51FA\u3057\u3066\u7D42\u4E86\u3057\u307E\u3059\uFF08\u4F5C\u6210\u3057\u307E\u305B\u3093\uFF09\u3002
|
|
48
|
+
\u5404\u9805\u76EE\u306E\u578B\u30FB\u5FC5\u9808\u30FB\u9078\u629E\u80A2\u306F stderr \u306B\u51FA\u307E\u3059\u3002
|
|
49
|
+
\u4F8B: twp content create --category news --generate-cli-skeleton --output json > news.json
|
|
50
|
+
twp content create --category news --content-file news.json`,flags:[CATEGORY_FLAG,CONTENT_FILE_FLAG,SKELETON_FLAG],async prepare(input,ctx){if(input.args.length>0)throw new UsageError(`\u4F4D\u7F6E\u5F15\u6570\u306F\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,CREATE_USAGE);const category=nonEmpty(input.flags,CATEGORY_FLAG.name);if(category===void 0)throw new UsageError("\u4F5C\u6210\u5148\u306E\u30AB\u30C6\u30B4\u30EA\u3092 --category \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
51
|
+
"\u30AB\u30C6\u30B4\u30EA\u306F twp content category list \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002");const skeleton=input.flags.has(SKELETON_FLAG.name);if(skeleton&&input.flags.has(CONTENT_FILE_FLAG.name))throw new UsageError("--generate-cli-skeleton \u3068 --content-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093",CREATE_USAGE);const resolved={category_id:await categoryIdOf(category,ctx)};if(!skeleton)resolved["text"]=await readContentFile(input,CREATE_USAGE);return withResolved(
|
|
52
|
+
input,resolved)},plan(input){if(input.flags.has(SKELETON_FLAG.name))return{method:"GET",path:categoryPath(requireResolved(input,"category_id"))};return{method:"POST",path:CONTENTS_PATH,body:{category_id:requireResolved(input,"category_id"),...JSON.parse(requireResolved(input,"text"))}}},plannedNotes:input=>input.flags.has(SKELETON_FLAG.name)?["\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u8AAD\u3080\u3060\u3051\u3067\u3001\u4F5C\u6210\u3057\u307E\u305B\u3093\u3002"]:[
|
|
53
|
+
"\u3053\u306E\u524D\u306B\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08GET /api/v2/cms/categories/{id}\uFF09\u3092\u8AAD\u3093\u3067\u9805\u76EE\u3092\u691C\u67FB\u3057\u3001\u30BF\u30B0\u30FB\u30D5\u30A1\u30A4\u30EB\u53C2\u7167\u306E\u540D\u524D\u3092 ID \u306B\u76F4\u3057\u307E\u3059\uFF08GET /api/v2/cms/tags/free\u30FBGET /api/v2/media/files/{id}\uFF09\u3002"],async execute(input,ctx){const categoryId=requireResolved(input,"category_id");const category=dataRecord(await ctx.
|
|
54
|
+
send({method:"GET",path:categoryPath(categoryId)}),"\u30AB\u30C6\u30B4\u30EA");if(input.flags.has(SKELETON_FLAG.name))return{skeleton:true,body:category};const fields=formFields(category);const parsed=parseContentFile(requireResolved(input,"text"),`--content-file ${input.flags.get(CONTENT_FILE_FLAG.name)??""}`,"create",fields);const missing=missingRequired(fields,parsed["content"]);if(missing.length>0)throw new UsageError(`\u5FC5\u9808\u9805\u76EE\u304C\u7A7A\u3067\u3059: ${missing.join(", ")}`,
|
|
55
|
+
"--generate-cli-skeleton \u3067\u3072\u306A\u5F62\u3068\u5FC5\u9808\u9805\u76EE\u3092\u51FA\u305B\u307E\u3059\u3002");const body=await resolveReferences(parsed,fields,ctx);return{skeleton:false,body:await ctx.send({method:"POST",path:CONTENTS_PATH,body:{category_id:categoryId,...body}})}},summarize(value){const result=writeResult(value);return result.skeleton?contentSkeleton(result.body):pick(dataRecord(result.body,"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u4F5C\u6210"),RESULT_COLUMNS)},raw(value){const result=writeResult(
|
|
56
|
+
value);return result.skeleton?contentSkeleton(result.body):dataRecord(result.body,"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u4F5C\u6210")},notes(value){const result=writeResult(value);return result.skeleton?skeletonNotes(result.body):serverMessage(result.body)}};var UPDATE_USAGE="twp content update <\u30B3\u30F3\u30C6\u30F3\u30C4ID> --content-file <\u30D1\u30B9>";var contentUpdateOperation={name:"update",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u66F8\u304D\u63DB\u3048\u308B\uFF08\u30D5\u30A1\u30A4\u30EB\u306B\u66F8\u3044\u305F\u9805\u76EE\u3060\u3051\u3092\u5909\u3048\u308B\uFF09",
|
|
57
|
+
usage:UPDATE_USAGE,description:'PUT /api/v2/cms/contents/{id} \u3067\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u4E0B\u66F8\u304D\u3092\u66F8\u304D\u63DB\u3048\u307E\u3059\u3002\n\u30B5\u30FC\u30D0\u306F\u672C\u6587\uFF08content\uFF09\u3092\u4E38\u3054\u3068\u7F6E\u304D\u63DB\u3048\u308B\u306E\u3067\u3001\u4ECA\u306E\u672C\u6587\u3092\u8AAD\u307F\uFF08GET /api/v2/cms/contents/{id}\uFF09\u3001\u30D5\u30A1\u30A4\u30EB\u306B\u66F8\u3044\u305F\u9805\u76EE\u3060\u3051\u3092\u91CD\u306D\u3066\u9001\u308A\u307E\u3059\u3002\n\u66F8\u304B\u306A\u304B\u3063\u305F\u30AD\u30FC\u30FB\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\u3002\u9805\u76EE\u3092\u7A7A\u306B\u3059\u308B\u306B\u306F null \u304B "" \u3092\u66F8\u304D\u307E\u3059\uFF08\u5FC5\u9808\u9805\u76EE\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093\u3002slug \u3092\u7A7A\u306B\u3059\u308B\u3068\u30BF\u30A4\u30C8\u30EB\u304B\u3089\u63A1\u756A\u3057\u76F4\u3055\u308C\u307E\u3059\uFF09\u3002\ntag_ids \u306F\u66F8\u304F\u3068\u4E38\u3054\u3068\u7F6E\u304D\u63DB\u308F\u308A\u307E\u3059\u3002\u30AB\u30C6\u30B4\u30EA\u306F\u5909\u3048\u3089\u308C\u307E\u305B\u3093\u3002\u516C\u958B\u4E2D\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306F\u300C\u672A\u516C\u958B\u306E\u5909\u66F4\u3042\u308A\u300D\u306B\u306A\u308A\u307E\u3059\uFF08\u516C\u958B\u306F\u5225\u306E\u64CD\u4F5C\uFF09\u3002\n\u627F\u8A8D\u5F85\u3061\uFF08pending_review\uFF09\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306F\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093\u3002\n\u9001\u308B\u76F4\u524D\u306B\u7248\u3092\u8AAD\u307F\u76F4\u3057\u3001\u8AAD\u3093\u3060\u5F8C\u306B\u4ED6\u306E\u66F4\u65B0\u304C\u5165\u3063\u3066\u3044\u308C\u3070\u9001\u3089\u305A\u306B\u7D42\u4E86\u30B3\u30FC\u30C9 3 \u3067\u7D42\u308F\u308A\u307E\u3059\uFF08\u30B5\u30FC\u30D0\u306E 409 \u3082\u540C\u3058\u6271\u3044\uFF09\u3002\u8AAD\u307F\u76F4\u3057\u3066\u3084\u308A\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n\u305F\u3060\u3057\u30B5\u30FC\u30D0\u306F\u3053\u3061\u3089\u304C\u8AAD\u3093\u3060\u7248\u3092\u7167\u5408\u3057\u306A\u3044\u305F\u3081\u3001\u8AAD\u307F\u76F4\u3057\u304B\u3089\u9001\u4FE1\u307E\u3067\u306E\u3054\u304F\u77ED\u3044\u9593\u306B\u5165\u3063\u305F\u66F4\u65B0\u306F\u691C\u51FA\u3067\u304D\u307E\u305B\u3093\u3002\n\n'+
|
|
58
|
+
VALUE_HELP,flags:[CONTENT_REF_FLAG,CONTENT_FILE_FLAG],async prepare(input){const id=contentIdArg(input,UPDATE_USAGE);return withResolved(input,{id,text:await readContentFile(input,UPDATE_USAGE)})},plan:input=>({method:"PUT",path:contentPath(requireResolved(input,"id")),body:JSON.parse(requireResolved(input,"text"))}),plannedNotes:()=>["\u3053\u306E\u524D\u306B\u4ECA\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u3068\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u8AAD\u307F\u3001\u30D5\u30A1\u30A4\u30EB\u306B\u66F8\u3044\u305F\u9805\u76EE\u3092\u4ECA\u306E\u672C\u6587\u306B\u91CD\u306D\u3066\u304B\u3089\u9001\u308A\u307E\u3059\uFF08--dry-run \u306E\u672C\u6587\u306F\u30D5\u30A1\u30A4\u30EB\u306E\u5024\u306E\u307E\u307E\u3067\u3059\uFF09\u3002"],
|
|
59
|
+
async execute(input,ctx){const id=requireResolved(input,"id");const current=dataRecord(await ctx.send({method:"GET",path:contentPath(id)}),"\u30B3\u30F3\u30C6\u30F3\u30C4");if(current["is_editable"]===false){throw new ApiRejectedError(`\u3053\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306F\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093: ${typeof current["not_editable_reason"]==="string"?current["not_editable_reason"]:"\uFF08\u7406\u7531\u4E0D\u660E\uFF09"}`)}const categoryId=current["category_id"];if(typeof categoryId!==
|
|
60
|
+
"string"||!isSafePathSegment(categoryId))throw new ApiResponseError("\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5FDC\u7B54\u306B category_id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");const fields=formFields(dataRecord(await ctx.send({method:"GET",path:categoryPath(categoryId)}),"\u30AB\u30C6\u30B4\u30EA"));const parsed=parseContentFile(requireResolved(input,"text"),`--content-file ${input.flags.get(CONTENT_FILE_FLAG.name)??
|
|
61
|
+
""}`,"update",fields);if(Object.keys(parsed).length===0)throw new UsageError("--content-file \u306B\u66F8\u304D\u63DB\u3048\u308B\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093",`\u66F8\u3051\u308B\u30AD\u30FC\u306F ${WRITABLE_KEYS.join(" / ")} \u3067\u3059\u3002`);const body=await resolveReferences(parsed,fields,ctx);if(isRecord(body["content"])){const merged={...isRecord(current["content"])?current["content"]:{},...body["content"]};const missing=missingRequired(fields,merged);const cleared=missing.
|
|
62
|
+
filter(label=>fields.some(f=>labelOf(f)===label&&Object.hasOwn(parsed["content"],String(f["name"]))));if(cleared.length>0)throw new UsageError(`\u5FC5\u9808\u9805\u76EE\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093: ${cleared.join(", ")}`);body["content"]=merged}const latest=dataRecord(await ctx.send({method:"GET",path:contentPath(id)}),"\u30B3\u30F3\u30C6\u30F3\u30C4");if(latest["version"]!==current["version"])throw new ApiRejectedError(CONFLICT.replace("\uFF08409\uFF09",`\uFF08\u8AAD\u3093\u3060\u7248 ${String(
|
|
63
|
+
current["version"])} \u2192 \u4ECA\u306E\u7248 ${String(latest["version"])}\uFF09`));return{skeleton:false,body:await sendGuarded(ctx,{method:"PUT",path:contentPath(id),body})}},summarize:value=>pick(dataRecord(writeResult(value).body,"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u66F4\u65B0"),RESULT_COLUMNS),raw:value=>dataRecord(writeResult(value).body,"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u66F4\u65B0"),notes:value=>serverMessage(writeResult(value).body)};var DELETE_USAGE="twp content delete <\u30B3\u30F3\u30C6\u30F3\u30C4ID>\
|
|
64
|
+
--yes";var contentDeleteOperation={name:"delete",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u524A\u9664\u3059\u308B\uFF08--yes \u304C\u8981\u308B\uFF09",usage:DELETE_USAGE,description:"DELETE /api/v2/cms/contents/{id} \u3067\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u524A\u9664\u3057\u307E\u3059\uFF08\u4E0B\u66F8\u304D\u30FB\u516C\u958B\u7248\u3068\u3082\u6D88\u3048\u3001\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\uFF09\u3002\n\u9001\u308B\u524D\u306B\u5BFE\u8C61\u3092\u8AAD\u307F\u3001\u30BF\u30A4\u30C8\u30EB\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\u3002\u7BA1\u7406\u8005\u304B\u4F5C\u6210\u8005\u3060\u3051\u304C\u524A\u9664\u3067\u304D\u307E\u3059\u3002\n\u8AAD\u3093\u3067\u304B\u3089\u9001\u308B\u307E\u3067\u306E\u9593\u306B\u516C\u958B\u7533\u8ACB\u30FB\u516C\u958B\u304C\u5165\u308B\u3068\u30B5\u30FC\u30D0\u304C 409 \u3067\u65AD\u308A\u307E\u3059\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 3\uFF09\u3002",
|
|
65
|
+
destructive:true,flags:[CONTENT_REF_FLAG],async prepare(input){return withResolved(input,{id:contentIdArg(input,DELETE_USAGE)})},plan:input=>({method:"DELETE",path:contentPath(requireResolved(input,"id"))}),plannedNotes:()=>["\u3053\u306E\u524D\u306B\u5BFE\u8C61\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u8AAD\u307F\u3001\u30BF\u30A4\u30C8\u30EB\u3092\u8868\u793A\u3057\u307E\u3059\u3002"],async execute(input,ctx){const id=requireResolved(input,"id");const current=dataRecord(await ctx.send({method:"\
|
|
66
|
+
GET",path:contentPath(id)}),"\u30B3\u30F3\u30C6\u30F3\u30C4");ctx.warn(`\u524A\u9664\u3059\u308B\u30B3\u30F3\u30C6\u30F3\u30C4: ${String(current["title"]??"")}\uFF08${id}\u30FB${String(current["category_name"]??current["category_id"]??"")}\uFF09`);return sendGuarded(ctx,{method:"DELETE",path:contentPath(id)})},summarize:body=>({deleted:true,message:isRecord(body)?body["message"]??null:null}),raw:body=>body,forbidden:FORBIDDEN};var LABEL="\u30B3\u30F3\u30C6\u30F3\u30C4";var CONTENTS_PATH2=`${CMS_PATH}/contents`;var CATEGORIES_PATH2=`${CMS_PATH}/categories`;var TAGS_PATH2=`${CMS_PATH}/tags`;var LIST_COLUMNS=["id","title","category_name","status","publish_status","version","updated_at"];var GET_COLUMNS=["id","title","slug","category_id","category_name","status","publish_status","version","author_name","editor_name","published_at","scheduled_publish_at","has_unpublished_changes","tag_ids","updated_at"];var HISTORY_COLUMNS=[
|
|
67
|
+
"version","action","comment","created_by","created_at"];var CATEGORY_COLUMNS=["id","code","name","is_active","workflow_enabled","sort","updated_at"];var FIELD_COLUMNS=["name","display_name","type","required","options"];var TAG_COLUMNS=["id","value","display_name","scope","is_active"];var STATUSES={draft:"\u4E0B\u66F8\u304D",pending_review:"\u627F\u8A8D\u5F85\u3061",approved:"\u627F\u8A8D\u6E08\u307F",rejected:"\u5374\u4E0B",archived:"\u30A2\u30FC\u30AB\u30A4\u30D6",published:"\u516C\u958B\u6E08\u307F"};
|
|
68
|
+
var PUBLISH_STATUSES={unpublished:"\u672A\u516C\u958B",published:"\u516C\u958B\u4E2D",scheduled:"\u516C\u958B\u4E88\u7D04"};var SORTABLE_COLUMNS=["title","category_name","publish_status","published_at","created_at","updated_at"];var MAX_SORT_COLUMNS=3;var LIST_LIMIT_MAX=100;var FORBIDDEN2="\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u3092\u4F7F\u3046\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u306E\u30E9\u30A4\u30BB\u30F3\u30B9\u3068\u3001\u3042\u306A\u305F\u306E\u300C\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u300D\u306E\u6A5F\u80FD\u6A29\u9650\u3092\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
69
|
+
var ID_HELP="\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u306F twp content list \u306E id \u5217\u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002";function dataRecord2(body,what){const row=isRecord(body)?body["data"]:void 0;if(!isRecord(row))throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return row}function dataList(body,what){const list=isRecord(body)?body["da\
|
|
70
|
+
ta"]:void 0;if(!Array.isArray(list))throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return list}function formFields2(category){const schema=category["schema"];const fields=isRecord(schema)?schema["form_fields"]:void 0;return Array.isArray(fields)?fields.filter(isRecord):[]}function optionLabel(field,key){const options=field?.["options"];if(!Array.
|
|
71
|
+
isArray(options))return key;const hit=options.filter(isRecord).find(o=>String(o["key"])===String(key));return hit!==void 0&&typeof hit["value"]==="string"?`${hit["value"]}\uFF08${String(key)}\uFF09`:key}function fieldText(value,field){if(value===null||value===void 0||value==="")return void 0;if(Array.isArray(value)){if(value.length===0)return void 0;return value.map(v=>typeof v==="string"||typeof v==="number"?String(optionLabel(field,v)):JSON.stringify(v)).join(", ")}if(typeof value==="boolean")
|
|
72
|
+
return value?"\u306F\u3044":"\u3044\u3044\u3048";if(typeof value==="number")return String(value);if(typeof value==="string"){if(field!==void 0?field["type"]==="richtext":/<\/?[a-z][^>]*>/i.test(value))return htmlToText(value);return String(optionLabel(field,value)).trim()}return JSON.stringify(value,null,2)}function contentDocument(body){const row=dataRecord2(isRecord(body)?body["content"]:void 0,LABEL);const category=isRecord(body)&&isRecord(body["category"])?body["category"]:void 0;const values=isRecord(
|
|
73
|
+
row["content"])?row["content"]:{};const fields=category===void 0?[]:formFields2(category);const known=new Set(fields.map(f=>f["name"]));const sections=[];for(const field of fields){const name=field["name"];if(typeof name!=="string")continue;const text=fieldText(values[name],field);if(text===void 0)continue;sections.push({heading:typeof field["display_name"]==="string"&&field["display_name"]!==""?field["display_name"]:name,body:text})}for(const[name,value]of Object.entries(values)){if(known.has(name))
|
|
74
|
+
continue;const text=fieldText(value);if(text!==void 0)sections.push({heading:name,body:text})}const tags=Array.isArray(row["tags"])?row["tags"].filter(isRecord):[];if(tags.length>0)sections.push({heading:"\u30BF\u30B0",body:tags.map(t=>`- ${String(t["display_name"]??t["value"]??"")}\uFF08${String(t["id"]??"")}\uFF09`).join("\n")});return composeDocument(row["title"],[...metaLine("ID",row["id"]),...metaLine("\u30AB\u30C6\u30B4\u30EA",row["category_name"]??row["category_code"]),...metaLine("\u72B6\u614B",
|
|
75
|
+
labelOf2(STATUSES,row["status"])),...metaLine("\u516C\u958B",labelOf2(PUBLISH_STATUSES,row["publish_status"])),...metaLine("\u7248",row["version"]),...metaLine("\u4F5C\u6210\u8005",row["author_name"]),...metaLine("\u66F4\u65B0",row["updated_at"])],sections)}function labelOf2(table,value){return typeof value==="string"&&table[value]!==void 0?`${table[value]}\uFF08${value}\uFF09`:value}function categoryDocument(body){const row=dataRecord2(body,"\u30AB\u30C6\u30B4\u30EA");const fields=formFields2(row);
|
|
76
|
+
const lines=fields.map(f=>{const options=Array.isArray(f["options"])&&f["options"].length>0?` \u9078\u629E\u80A2: ${f["options"].filter(isRecord).map(o=>`${String(o["value"])}\uFF08${String(o["key"])}\uFF09`).join(" / ")}`:"";return`- ${String(f["display_name"]??f["name"])}\uFF08${String(f["name"])}\u30FB${String(f["type"])}${f["required"]===true?"\u30FB\u5FC5\u9808":""}\uFF09${options}`});return composeDocument(row["name"],[...metaLine("ID",row["id"]),...metaLine("\u30B3\u30FC\u30C9",row["code"]),
|
|
77
|
+
...metaLine("\u8AAC\u660E",row["description"]),...metaLine("\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",row["workflow_enabled"]===true?"\u3042\u308A":"\u306A\u3057")],[{heading:`\u30D5\u30A9\u30FC\u30E0\u9805\u76EE\uFF08${fields.length} \u4EF6\uFF09`,body:lines.join("\n")}])}function noArgs(input,usage){if(input.args.length>0)throw new UsageError(`\u4F4D\u7F6E\u5F15\u6570\u306F\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,usage)}var CONTENT_REF_FLAG2={name:"--content",summary:"\u5BFE\u8C61\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID\uFF08\
|
|
78
|
+
\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30B3\u30F3\u30C6\u30F3\u30C4ID>"};function contentId(input,usage){const id=singleRef(input,{flag:CONTENT_REF_FLAG2.name,label:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID",usage});if(!isSafePathSegment(id))throw new UsageError(`\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${id}`,ID_HELP);return id}var contentPath2=(id,suffix="")=>`${CONTENTS_PATH2}\
|
|
79
|
+
/${encodeURIComponent(id)}${suffix}`;function serverId(id,what){if(!isSafePathSegment(id))throw new ApiResponseError(`\u30B5\u30FC\u30D0\u304C\u8FD4\u3057\u305F${what}\u306E ID \u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${id}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return id}async function categoryIdOf2(ref,ctx,flag){const value=ref.trim();if(UUID_RE.test(value))return value;return serverId((await ctx.resolver.cmsCategory(value,flag)).id,
|
|
80
|
+
"\u30AB\u30C6\u30B4\u30EA")}function enumValue(input,flag,table){const raw=nonEmpty(input.flags,flag)?.trim();if(raw===void 0)return void 0;if(Object.hasOwn(table,raw))return raw;const byLabel=Object.entries(table).find(([,label])=>label===raw);if(byLabel!==void 0)return byLabel[0];throw new UsageError(`${flag} \u306B\u6307\u5B9A\u3067\u304D\u306A\u3044\u5024\u3067\u3059: ${raw}`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${Object.entries(table).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")}\
|
|
81
|
+
\u3067\u3059\u3002`)}function sortQuery(raw){if(raw===void 0)return{};const usage=`--sort \u306F\u300C\u5217[:asc|desc]\u300D\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6700\u5927 ${MAX_SORT_COLUMNS} \u3064\uFF08\u5217\u306F ${SORTABLE_COLUMNS.join(" / ")}\uFF09\u3002\u4F8B: --sort updated_at:desc,title`;const parts=raw.split(",").map(p=>p.trim());if(parts.some(p=>p===""))throw new UsageError(`--sort \u306B\u7A7A\u306E\u5217\u304C\u3042\u308A\u307E\u3059: ${raw}`,usage);if(parts.length>MAX_SORT_COLUMNS)
|
|
82
|
+
throw new UsageError(`--sort \u306B\u6307\u5B9A\u3067\u304D\u308B\u5217\u306F ${MAX_SORT_COLUMNS} \u3064\u307E\u3067\u3067\u3059: ${raw}`,usage);const columns=[];const directions=[];for(const part of parts){const[column="",direction="",...rest]=part.split(":").map(s=>s.trim());if(rest.length>0||!SORTABLE_COLUMNS.includes(column))throw new UsageError(`--sort \u306B\u6307\u5B9A\u3067\u304D\u306A\u3044\u5217\u3067\u3059: ${part}`,usage);if(direction!==""&&direction!=="asc"&&direction!=="desc")throw new UsageError(
|
|
83
|
+
`--sort \u306E\u5411\u304D\u306F asc \u304B desc \u3067\u3059: ${part}`,usage);columns.push(column);directions.push(direction)}return{sort_column:columns.join(","),...directions.some(d=>d!=="")?{sort_direction:directions.join(",")}:{}}}var LIST_USAGE="twp content list [--keyword <\u8A9E>] [--category <\u30AB\u30C6\u30B4\u30EA>] [--status <\u72B6\u614B>] [--publish-status <\u516C\u958B\u72B6\u614B>] [--sort <\u5217[:asc|desc]>,\u2026] [--limit <\u4EF6\u6570>] [--all]";var listOperation={name:"lis\
|
|
84
|
+
t",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4E00\u89A7\u3059\u308B\uFF08--keyword / --category / --status / --publish-status / --sort\uFF09",usage:LIST_USAGE,description:`--category \u306F\u30AB\u30C6\u30B4\u30EA\u306E ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\uFF08twp content category list \u3067\u78BA\u8A8D\uFF09\u3002
|
|
85
|
+
--status \u306F ${Object.entries(STATUSES).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")}\u3001--publish-status \u306F ${Object.entries(PUBLISH_STATUSES).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")} \u3067\u3059\uFF08\u8868\u793A\u540D\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\uFF09\u3002
|
|
86
|
+
--sort \u306F\u753B\u9762\u306E\u5217\u898B\u51FA\u3057\u306E\u4E26\u3079\u66FF\u3048\u3068\u540C\u3058\u3067\u3001${SORTABLE_COLUMNS.join(" / ")} \u3092\u6700\u5927 ${MAX_SORT_COLUMNS} \u5217\u307E\u3067\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
87
|
+
--limit \u306E\u4E0A\u9650\u306F\u30B5\u30FC\u30D0\u5074\u3067 ${LIST_LIMIT_MAX} \u4EF6\u3067\u3059\uFF08\u65E2\u5B9A 20 \u4EF6\uFF09\u3002
|
|
88
|
+
|
|
89
|
+
--output json \u306F\u672C\u6587\uFF08content\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
90
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${LIST_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002
|
|
91
|
+
|
|
92
|
+
`+LIST_PAGING_HELP,flags:[{name:"--keyword",summary:"\u30BF\u30A4\u30C8\u30EB\u30FB\u672C\u6587\u306E\u8A9E\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u8A9E>"},{name:"--category",summary:"\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"},{name:"--status",summary:"\u72B6\u614B\uFF08draft / pending_review / approved / rejected / archived / published\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",
|
|
93
|
+
takesValue:true,placeholder:"<\u72B6\u614B>"},{name:"--publish-status",summary:"\u516C\u958B\u72B6\u614B\uFF08unpublished / published / scheduled\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u516C\u958B\u72B6\u614B>"},{name:"--sort",summary:`\u4E26\u3079\u66FF\u3048\uFF08\u5217[:asc|desc] \u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u30FB\u6700\u5927 ${MAX_SORT_COLUMNS} \u5217\uFF09`,takesValue:true,placeholder:"<\u5217[:asc|desc]>,\u2026"},...LIST_FLAGS],async prepare(input,ctx){
|
|
94
|
+
noArgs(input,LIST_USAGE);listQuery(input);const category=nonEmpty(input.flags,"--category");if(category===void 0)return input;return withResolved(input,{category_id:await categoryIdOf2(category,ctx,"--category")})},plan:input=>({method:"GET",path:CONTENTS_PATH2,query:{...listQuery(input),category_id:input.resolved?.["category_id"]}}),paging:envelopePaging({label:`${LABEL}\u4E00\u89A7`}),summarize:body=>itemsOf(body).map(row=>pick(row,LIST_COLUMNS)),raw:body=>itemsOf(body),notes:body=>isRecord(body)&&
|
|
95
|
+
body["sort_truncated"]===true?["\u26A0 \u30B5\u30FC\u30D0\u304C\u4E26\u3079\u66FF\u3048\u306E\u5BFE\u8C61\u3092\u4E0A\u9650\u3067\u6253\u3061\u5207\u308A\u307E\u3057\u305F\u3002\u7D50\u679C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08--keyword / --category \u3067\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044\uFF09\u3002"]:[]};function listQuery(input){const limit=positiveInteger(input.flags,"--limit");return{keyword:boundedText(input,"--keyword",{maxChars:255,label:"\u691C\u7D22\u8A9E"})?.
|
|
96
|
+
trim(),status:enumValue(input,"--status",STATUSES),publish_status:enumValue(input,"--publish-status",PUBLISH_STATUSES),...sortQuery(nonEmpty(input.flags,"--sort")),limit:limit===void 0?void 0:String(limit),cursor:nonEmpty(input.flags,"--cursor")}}function itemsOf(body){const items=isRecord(body)?body["items"]:void 0;if(!Array.isArray(items))throw new ApiResponseError(`${LABEL}\u4E00\u89A7\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
97
|
+
return items}var GET_USAGE="twp content get <\u30B3\u30F3\u30C6\u30F3\u30C4ID> [--output text]";var getOperation={name:"get",summary:"\u30B3\u30F3\u30C6\u30F3\u30C41\u4EF6\u3092\u8868\u793A\u3059\u308B\uFF08--output text \u3067\u672C\u6587\u3092\u9805\u76EE\u540D\u3064\u304D\u3067\u8AAD\u3081\u308B\u5F62\u306B\uFF09",usage:GET_USAGE,description:"\u7D9A\u3051\u3066\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3082\u53D6\u5F97\u3057\u3001--output text \u3067\u306F\u672C\u6587\u306E\u5404\u9805\u76EE\u3092\u753B\u9762\u3068\u540C\u3058\u9805\u76EE\u540D\uFF08display_name\uFF09\u30FB\u9806\u5E8F\u3067\u4E26\u3079\u307E\u3059\u3002\n\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306B\u7121\u3044\u5024\uFF08\u5B9A\u7FA9\u304B\u3089\u5916\u3057\u305F\u9805\u76EE\uFF09\u3082\u3001\u9805\u76EE\u306E\u5185\u90E8\u540D\u306E\u307E\u307E\u672B\u5C3E\u306B\u51FA\u3057\u307E\u3059\u3002\n\n--output json \u306F\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u30BF\u30B0\u30FB\u7DE8\u96C6\u53EF\u5426\u3092\
|
|
98
|
+
\u542B\u3080\uFF09\u3067\u3059\u3002",flags:[CONTENT_REF_FLAG2],plan:input=>({method:"GET",path:contentPath2(contentId(input,GET_USAGE))}),plannedNotes:()=>["\u7D9A\u3051\u3066\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08GET /api/v2/cms/categories/{\u30AB\u30C6\u30B4\u30EAID}\uFF09\u3082\u53D6\u5F97\u3057\u307E\u3059\u3002"],async execute(input,ctx){const content=await ctx.send({method:"GET",path:contentPath2(contentId(input,GET_USAGE))});const categoryId=dataRecord2(content,
|
|
99
|
+
LABEL)["category_id"];if(typeof categoryId!=="string"||categoryId==="")return{content,category:null};try{return{content,category:dataRecord2(await ctx.send({method:"GET",path:`${CATEGORIES_PATH2}/${encodeURIComponent(serverId(categoryId,"\u30AB\u30C6\u30B4\u30EA"))}`}),"\u30AB\u30C6\u30B4\u30EA")}}catch(error){if(!(error instanceof ApiError&&error.status===404))throw error;ctx.warn(`\u30AB\u30C6\u30B4\u30EA\uFF08${categoryId}\uFF09\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\u305F\u3081\u3001\u672C\u6587\u306E\u9805\u76EE\u306F\u5185\u90E8\u540D\u3067\u51FA\u3057\u307E\u3059\uFF08${error.
|
|
100
|
+
message}\uFF09`);return{content,category:null}}},summarize:body=>pick(contentRow(body),GET_COLUMNS),raw:body=>contentRow(body),document:contentDocument};function contentRow(body){return dataRecord2(isRecord(body)?body["content"]:void 0,LABEL)}var HISTORY_USAGE="twp content history <\u30B3\u30F3\u30C6\u30F3\u30C4ID> [--limit <\u4EF6\u6570>]";var historyOperation={name:"history",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5909\u66F4\u5C65\u6B74\uFF08\u7248\u30FB\u64CD\u4F5C\u30FB\u30B3\u30E1\u30F3\u30C8\uFF09\u3092\u4E00\u89A7\u3059\u308B",
|
|
101
|
+
usage:HISTORY_USAGE,description:`--output json \u306F\u5404\u7248\u306E\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8\uFF08snapshot\uFF09\u3068\u5909\u66F4\u70B9\uFF08changes\uFF09\u3092\u542B\u307F\u307E\u3059\u3002
|
|
102
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${HISTORY_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002`,flags:[CONTENT_REF_FLAG2,{name:"--limit",summary:"\u53D6\u5F97\u4EF6\u6570",takesValue:true,placeholder:"<\u4EF6\u6570>"}],plan(input){const limit=positiveInteger(input.flags,"--limit");return{method:"GET",path:contentPath2(contentId(input,HISTORY_USAGE),"/history"),query:{limit:limit===void 0?void 0:String(limit)}}},summarize:body=>dataList(body,`${LABEL}\u306E\u5909\u66F4\u5C65\u6B74`).
|
|
103
|
+
map(row=>pick(row,HISTORY_COLUMNS)),raw:body=>dataList(body,`${LABEL}\u306E\u5909\u66F4\u5C65\u6B74`)};var DIFF_USAGE="twp content diff <\u30B3\u30F3\u30C6\u30F3\u30C4ID>";var diffOperation={name:"diff",summary:"\u4E0B\u66F8\u304D\u3068\u516C\u958B\u4E2D\u306E\u7248\u3092\u4E26\u3079\u3001\u672A\u516C\u958B\u306E\u5909\u66F4\u304C\u3042\u308B\u304B\u3092\u8868\u793A\u3059\u308B",usage:DIFF_USAGE,description:"--output json \u306F\u4E0B\u66F8\u304D\uFF08draft\uFF09\u3068\u516C\u958B\u4E2D\uFF08published\u30FB\u672A\u516C\u958B\u306A\u3089 null\uFF09\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\ntable / text / tsv \u306F\u3001\u5024\u304C\u9055\u3046\u9805\
|
|
104
|
+
\u76EE\uFF08\u30BF\u30A4\u30C8\u30EB\u30FB\u672C\u6587\u306E\u5404\u9805\u76EE\uFF09\u3060\u3051\u3092\u300C\u9805\u76EE / \u4E0B\u66F8\u304D / \u516C\u958B\u4E2D\u300D\u3067\u4E26\u3079\u307E\u3059\u3002",flags:[CONTENT_REF_FLAG2],plan:input=>({method:"GET",path:contentPath2(contentId(input,DIFF_USAGE),"/diff")}),summarize:body=>diffRows(dataRecord2(body,`${LABEL}\u306E\u5DEE\u5206`)),raw:body=>dataRecord2(body,`${LABEL}\u306E\u5DEE\u5206`),notes(body){const diff=dataRecord2(body,`${LABEL}\u306E\u5DEE\u5206`);
|
|
105
|
+
if(diff["published"]===null||diff["published"]===void 0)return["\u307E\u3060\u516C\u958B\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08\u516C\u958B\u4E2D\u306E\u7248\u304C\u3042\u308A\u307E\u305B\u3093\uFF09\u3002"];if(diff["has_changes"]!==true)return["\u4E0B\u66F8\u304D\u306F\u516C\u958B\u4E2D\u306E\u7248\u3068\u540C\u3058\u3067\u3059\u3002"];return[diffRows(diff).length>0?"\u672A\u516C\u958B\u306E\u5909\u66F4\u304C\u3042\u308A\u307E\u3059\u3002":"\u672A\u516C\u958B\u306E\u7248\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u30BF\u30A4\u30C8\u30EB\u30FB\u30B9\u30E9\u30C3\u30B0\u30FB\u672C\u6587\u306E\u5024\u306F\u516C\u958B\u4E2D\u306E\u7248\u3068\u540C\u3058\u3067\u3059\uFF08\u629C\u7C8B\u30FBSEO \
|
|
106
|
+
\u7B49\u306E\u5DEE\u306F --output json \u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002"]}};function diffRows(diff){const draft=isRecord(diff["draft"])?diff["draft"]:{};const published=isRecord(diff["published"])?diff["published"]:{};const rows=[];const compare=(field,a2,b2)=>{if(fieldText(a2)===void 0&&fieldText(b2)===void 0)return;if(JSON.stringify(a2??null)!==JSON.stringify(b2??null))rows.push({field,draft:fieldText(a2)??null,published:fieldText(b2)??null})};compare("title",
|
|
107
|
+
draft["title"],published["title"]);compare("slug",draft["slug"],published["slug"]);const a=isRecord(draft["content"])?draft["content"]:{};const b=isRecord(published["content"])?published["content"]:{};for(const key of[...new Set([...Object.keys(a),...Object.keys(b)])])compare(`content.${key}`,a[key],b[key]);return rows}var WORKFLOW_USAGE="twp content workflow <\u30B3\u30F3\u30C6\u30F3\u30C4ID>";var workflowOperation={name:"workflow",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u516C\u958B\u7533\u8ACB\uFF08\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\uFF09\u306E\u72B6\u6CC1\u3092\u8868\u793A\u3059\u308B",
|
|
108
|
+
usage:WORKFLOW_USAGE,description:"\u516C\u958B\u7533\u8ACB\u3092\u3057\u3066\u3044\u306A\u3044\u30B3\u30F3\u30C6\u30F3\u30C4\u306F\u30B5\u30FC\u30D0\u304C 404\uFF08\u300C\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u60C5\u5831\u304C\u3042\u308A\u307E\u305B\u3093\u300D\uFF09\u3092\u8FD4\u3057\u307E\u3059\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 3\uFF09\u3002\n--output json \u306F\u7533\u8ACB\uFF08instance\uFF09\u30FB\u6BB5\u306E\u5C65\u6B74\uFF08step_history\uFF09\u30FB\u7D4C\u8DEF\uFF08workflow_steps\uFF09\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002",
|
|
109
|
+
flags:[CONTENT_REF_FLAG2],plan:input=>({method:"GET",path:contentPath2(contentId(input,WORKFLOW_USAGE),"/workflow")}),summarize(body){const data=dataRecord2(body,"\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC");const instance=isRecord(data["instance"])?data["instance"]:{};const state=isRecord(data["workflow_state"])?data["workflow_state"]:{};return{workflow_status:state["status"]??null,instance_id:instance["id"]??null,workflow_name:instance["workflow_name"]??null,applicant_name:instance["applicant_name"]??
|
|
110
|
+
null,status:instance["status"]??null,current_step_no:instance["current_step_no"]??null,applied_at:state["applied_at"]??null}},raw:body=>dataRecord2(body,"\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC")};function withoutHookSecrets(category){if(!isRecord(category))return category;const hook=category["publish_hook_settings"];if(!isRecord(hook)||!Array.isArray(hook["headers"]))return category;const headers=hook["headers"].map(h=>isRecord(h)&&h["value"]!==void 0&&h["value"]!==null&&h["value"]!==""?{...h,value:REDACTED}:
|
|
111
|
+
h);return{...category,publish_hook_settings:{...hook,headers}}}var CATEGORY_LIST_USAGE="twp content category list [--active | --inactive]";var categoryListOperation={name:"list",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30AB\u30C6\u30B4\u30EA\u3092\u4E00\u89A7\u3059\u308B",usage:CATEGORY_LIST_USAGE,description:`--output json \u306F\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08schema.form_fields\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002
|
|
112
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${CATEGORY_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002`,flags:activeFlags("\u30AB\u30C6\u30B4\u30EA"),plan(input){noArgs(input,CATEGORY_LIST_USAGE);return{method:"GET",path:CATEGORIES_PATH2,query:{is_active:activeQuery(input)}}},summarize:body=>dataList(body,"\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7").map(row=>pick(row,CATEGORY_COLUMNS)),raw:body=>dataList(body,"\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7").map(withoutHookSecrets)};var CATEGORY_REF_FLAG={
|
|
113
|
+
name:"--category",summary:"\u5BFE\u8C61\u306E\u30AB\u30C6\u30B4\u30EA\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"};var CATEGORY_GET_USAGE="twp content category get <\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09> [--output text]";var categoryGetOperation={name:"get",summary:"\u30AB\u30C6\u30B4\u30EA1\u4EF6\u3068\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08\u9805\u76EE\u540D\u30FB\u578B\u30FB\u5FC5\u9808\u30FB\u9078\u629E\u80A2\uFF09\u3092\u8868\u793A\u3059\u308B",
|
|
114
|
+
usage:CATEGORY_GET_USAGE,description:"\u30AB\u30C6\u30B4\u30EA\u306F ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n--output table / tsv \u306F\u30D5\u30A9\u30FC\u30E0\u9805\u76EE\u30921\u884C\u305A\u3064\uFF08name / display_name / type / required / options\uFF09\u3001--output text \u306F\u8AAD\u3081\u308B\u5F62\u3067\u51FA\u3057\u307E\u3059\u3002\n--output json \u306F\u30AB\u30C6\u30B4\u30EA\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002",
|
|
115
|
+
flags:[CATEGORY_REF_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:CATEGORY_REF_FLAG.name,label:"\u30AB\u30C6\u30B4\u30EA",usage:CATEGORY_GET_USAGE});return withResolved(input,{id:await categoryIdOf2(ref,ctx,"<\u30AB\u30C6\u30B4\u30EA>")})},plan:input=>({method:"GET",path:`${CATEGORIES_PATH2}/${encodeURIComponent(requireResolved(input,"id"))}`}),summarize:body=>formFields2(dataRecord2(body,"\u30AB\u30C6\u30B4\u30EA")).map(f=>({...pick(f,FIELD_COLUMNS),options:Array.isArray(f["opt\
|
|
116
|
+
ions"])?f["options"].filter(isRecord).map(o=>`${String(o["key"])}=${String(o["value"])}`).join(" / "):null})),raw:body=>withoutHookSecrets(dataRecord2(body,"\u30AB\u30C6\u30B4\u30EA")),document:categoryDocument};function activeFlags(what){return[{name:"--active",summary:`\u6709\u52B9\u306A${what}\u3060\u3051`,takesValue:false},{name:"--inactive",summary:`\u7121\u52B9\u306A${what}\u3060\u3051`,takesValue:false}]}function activeQuery(input){if(input.flags.has("--active")&&input.flags.has("--inacti\
|
|
117
|
+
ve"))throw new UsageError("--active \u3068 --inactive \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");if(input.flags.has("--active"))return"true";if(input.flags.has("--inactive"))return"false";return void 0}var TAG_DESCRIPTION=`--output json \u306F\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${TAG_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u3042\u308A\u307E\u305B\u3093\u3002`;
|
|
118
|
+
function tagListOperation(name,summary,usage,path,extra=[]){return{name,summary,usage,description:TAG_DESCRIPTION,flags:[...extra,...activeFlags("\u30BF\u30B0")],plan(input){noArgs(input,usage);return{method:"GET",path,query:{is_active:activeQuery(input),scope:nonEmpty(input.flags,"--scope")?.trim()}}},summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")}}var TAG_SCOPE_FLAG={name:"--scope",summary:"\u30B9\u30B3\u30FC\u30D7\uFF08free\
|
|
119
|
+
=\u81EA\u7531\u30BF\u30B0 / field:<\u30AB\u30C6\u30B4\u30EAID>:<\u9805\u76EE\u540D>\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u30B9\u30B3\u30FC\u30D7>"};var tagList=tagListOperation("list","\u30BF\u30B0\u3092\u4E00\u89A7\u3059\u308B\uFF08\u81EA\u7531\u30BF\u30B0\u3068\u30D5\u30A3\u30FC\u30EB\u30C9\u30BF\u30B0\u306E\u4E21\u65B9\uFF09","twp content tag list [--scope <\u30B9\u30B3\u30FC\u30D7>] [--active | --inactive]",TAGS_PATH2,[TAG_SCOPE_FLAG]);var tagFree=tagListOperation(
|
|
120
|
+
"free","\u81EA\u7531\u30BF\u30B0\uFF08\u3069\u306E\u9805\u76EE\u306B\u3082\u5C5E\u3055\u306A\u3044\u30BF\u30B0\uFF09\u3092\u4E00\u89A7\u3059\u308B","twp content tag free [--active | --inactive]",`${TAGS_PATH2}/free`);var TAG_FIELD_USAGE="twp content tag field <\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09> <\u9805\u76EE\u540D>";var tagField={name:"field",summary:"\u30AB\u30C6\u30B4\u30EA\u306E\u30BF\u30B0\u578B\u306E\u9805\u76EE\u306B\u4ED8\u3044\u305F\u30BF\u30B0\u3092\u4E00\u89A7\u3059\u308B",
|
|
121
|
+
usage:TAG_FIELD_USAGE,description:`\u9805\u76EE\u540D\u306F\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E name\uFF08twp content category get \u3067\u78BA\u8A8D\uFF09\u3067\u3059\u3002
|
|
122
|
+
${TAG_DESCRIPTION}`,flags:activeFlags("\u30BF\u30B0"),async prepare(input,ctx){const[category,field,...rest]=input.args;if(category===void 0||field===void 0||rest.length>0||field.trim()===""){throw new UsageError("\u30AB\u30C6\u30B4\u30EA\u3068\u9805\u76EE\u540D\u30921\u3064\u305A\u3064\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",TAG_FIELD_USAGE)}if(!isSafePathSegment(field.trim()))throw new UsageError(`\u9805\u76EE\u540D\u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${field}`,
|
|
123
|
+
TAG_FIELD_USAGE);return withResolved(input,{category_id:await categoryIdOf2(category,ctx,"<\u30AB\u30C6\u30B4\u30EA>"),field:field.trim()})},plan:input=>({method:"GET",path:`${TAGS_PATH2}/field/${encodeURIComponent(requireResolved(input,"category_id"))}/${encodeURIComponent(requireResolved(input,"field"))}`,query:{is_active:activeQuery(input)}}),summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")};var TAG_SEARCH_USAGE="\
|
|
124
|
+
twp content tag search <\u8A9E> [--scope <\u30B9\u30B3\u30FC\u30D7>]";var tagSearch={name:"search",summary:"\u5024\u30FB\u8868\u793A\u540D\u306E\u8A9E\u3067\u30BF\u30B0\u3092\u63A2\u3059",usage:TAG_SEARCH_USAGE,description:TAG_DESCRIPTION,flags:[TAG_SCOPE_FLAG,...activeFlags("\u30BF\u30B0")],plan(input){const q=singleRef(input,{flag:"--query",label:"\u691C\u7D22\u8A9E",usage:TAG_SEARCH_USAGE});return{method:"GET",path:`${TAGS_PATH2}/search`,query:{q,scope:nonEmpty(input.flags,"--scope")?.trim(),
|
|
125
|
+
is_active:activeQuery(input)}}},summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")};var TAG_GET_USAGE="twp content tag get <\u30BF\u30B0\uFF08ID\u30FB\u5024\u30FB\u8868\u793A\u540D\uFF09>";var tagGet={name:"get",summary:"\u30BF\u30B01\u4EF6\u3092\u8868\u793A\u3059\u308B",usage:TAG_GET_USAGE,description:"\u30BF\u30B0\u306F ID\u30FB\u5024\uFF08value\uFF09\u30FB\u8868\u793A\u540D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\u8868\u793A\u540D\u304C\u91CD\u306A\u308B\u3068\u304D\u306F\u5019\u88DC\u3092\u51FA\u3057\u3066\u6B62\u3081\u307E\u3059\uFF08ID \u304B\u5024\u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",
|
|
126
|
+
flags:[{name:"--tag",summary:"\u5BFE\u8C61\u306E\u30BF\u30B0\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30BF\u30B0>"}],async prepare(input,ctx){const ref=singleRef(input,{flag:"--tag",label:"\u30BF\u30B0",usage:TAG_GET_USAGE});const id=UUID_RE.test(ref)?ref:serverId((await ctx.resolver.cmsTag(ref)).id,"\u30BF\u30B0");return withResolved(input,{id})},plan:input=>({method:"GET",path:`${TAGS_PATH2}/${encodeURIComponent(requireResolved(
|
|
127
|
+
input,"id"))}`}),summarize:body=>pick(dataRecord2(body,"\u30BF\u30B0"),[...TAG_COLUMNS,"color","sort","is_system","updated_at"]),raw:body=>dataRecord2(body,"\u30BF\u30B0")};function withForbidden(operations){return operations.map(op=>({...op,forbidden:FORBIDDEN2}))}var categoryResource={name:"category",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30AB\u30C6\u30B4\u30EA\uFF08\u4E00\u89A7\u30FB\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E\u8868\u793A\uFF09",operations:withForbidden([categoryListOperation,
|
|
128
|
+
categoryGetOperation])};var tagResource={name:"tag",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30BF\u30B0\uFF08\u4E00\u89A7\u30FB\u81EA\u7531\u30BF\u30B0\u30FB\u9805\u76EE\u306E\u30BF\u30B0\u30FB\u691C\u7D22\u30FB\u8868\u793A\uFF09",operations:withForbidden([tagList,tagFree,tagField,tagSearch,tagGet])};var contentDomain={name:"content",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\uFF08CMS\uFF09\uFF08\u4E00\u89A7\u30FB\u672C\u6587\u30FB\u4F5C\u6210\u30FB\u66F4\u65B0\u30FB\u524A\u9664\u30FB\u5909\u66F4\u5C65\u6B74\u30FB\u5DEE\u5206\u30FB\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u30FB\u30AB\u30C6\u30B4\u30EA\u30FB\u30BF\u30B0\uFF09",
|
|
129
|
+
operations:withForbidden([listOperation,getOperation,contentCreateOperation,contentUpdateOperation,contentDeleteOperation,historyOperation,diffOperation,workflowOperation]),subresources:[categoryResource,tagResource]};export{contentDomain,diffRows,fieldText,sortQuery,withoutHookSecrets};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{checkOutTarget}from"./chunk-
|
|
3
|
+
import{checkOutTarget}from"./chunk-HBX6AOAD.js";import"./chunk-RESKTLOO.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import{contentTypeFor,inspectLocalFile}from"./chunk-ODW2QKMP.js";import{checkUploadQuota}from"./chunk-V64CGX7V.js";import{parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";import"./chunk-RMFLTSOV.js";import{readBody}from"./chunk-HEH3PUW2.js";import"./chunk-W4NLJ2YK.js";
|
|
4
4
|
import"./chunk-BD7O73GK.js";import{repeatedValues}from"./chunk-VGT2EGH6.js";import"./chunk-MSQ4ZGMA.js";import{collapsesInUrlPath,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger,readEnvelopeCursor,shellQuote}from"./chunk-MI6HVYR2.js";import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";
|
|
5
5
|
import{acknowledgement,isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,NetworkError,UsageError,WaitTimeoutError}from"./chunk-VFPY2A23.js";import"./chunk-KIZIRVW6.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-AAABT3AX.js";import"./chunk-OKATZ4SN.js";import"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";
|
|
6
6
|
import"./chunk-VSJBJXZO.js";import crypto2 from"crypto";import fs2 from"fs";import path from"path";var SCOPE_PERSONAL="personal";var SCOPE_PROJECT="project";var UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var FORBIDDEN_NAME=/[/\\:*?"<>|]/;var NAME_MAX=255;var ROW_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","updated_at"];var TRASH_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","deleted_at"];function folderRows(raw){return raw.map(row=>{const id=row["id"];const name=row["name"];const parentId=row["parent_id"];if(typeof id!==
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{loadDomain}from"./chunk-
|
|
3
|
+
import{loadDomain}from"./chunk-RESKTLOO.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-
|
|
3
|
+
import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-HBX6AOAD.js";import"./chunk-RESKTLOO.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-VGT2EGH6.js";import"./chunk-MSQ4ZGMA.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";
|
|
4
4
|
import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-MI6HVYR2.js";import"./chunk-3ZRMMBP5.js";import"./chunk-VFPY2A23.js";import"./chunk-KIZIRVW6.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-AAABT3AX.js";import"./chunk-OKATZ4SN.js";import"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";
|
|
5
5
|
import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};
|
package/package.json
CHANGED
package/dist/content-T6VIKIOW.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
-
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{composeDocument,htmlToText,metaLine}from"./chunk-62GRAKUD.js";import{boundedText}from"./chunk-JJSBBWJ5.js";import{REDACTED}from"./chunk-BD7O73GK.js";import{CMS_PATH}from"./chunk-MSQ4ZGMA.js";import{UUID_RE,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-MI6HVYR2.js";
|
|
4
|
-
import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";import{isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiResponseError,UsageError}from"./chunk-VFPY2A23.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";var LABEL="\u30B3\u30F3\u30C6\u30F3\u30C4";var CONTENTS_PATH=`${CMS_PATH}/contents`;var CATEGORIES_PATH=`${CMS_PATH}/categories`;var TAGS_PATH=`${CMS_PATH}/tags`;var LIST_COLUMNS=["id","title","category_name","status","publish_status","version","updated_at"];var GET_COLUMNS=["id","title","slug","category_id","category_name","status","publish_status","version","author_name","editor_name","published_at","scheduled_publish_at","has_unpublished_changes","tag_ids","updated_at"];var HISTORY_COLUMNS=["\
|
|
5
|
-
version","action","comment","created_by","created_at"];var CATEGORY_COLUMNS=["id","code","name","is_active","workflow_enabled","sort","updated_at"];var FIELD_COLUMNS=["name","display_name","type","required","options"];var TAG_COLUMNS=["id","value","display_name","scope","is_active"];var STATUSES={draft:"\u4E0B\u66F8\u304D",pending_review:"\u627F\u8A8D\u5F85\u3061",approved:"\u627F\u8A8D\u6E08\u307F",rejected:"\u5374\u4E0B",archived:"\u30A2\u30FC\u30AB\u30A4\u30D6",published:"\u516C\u958B\u6E08\u307F"};
|
|
6
|
-
var PUBLISH_STATUSES={unpublished:"\u672A\u516C\u958B",published:"\u516C\u958B\u4E2D",scheduled:"\u516C\u958B\u4E88\u7D04"};var SORTABLE_COLUMNS=["title","category_name","publish_status","published_at","created_at","updated_at"];var MAX_SORT_COLUMNS=3;var LIST_LIMIT_MAX=100;var FORBIDDEN="\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u3092\u4F7F\u3046\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u306E\u30E9\u30A4\u30BB\u30F3\u30B9\u3068\u3001\u3042\u306A\u305F\u306E\u300C\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\u300D\u306E\u6A5F\u80FD\u6A29\u9650\u3092\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
7
|
-
var ID_HELP="\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u306F twp content list \u306E id \u5217\u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002";function dataRecord(body,what){const row=isRecord(body)?body["data"]:void 0;if(!isRecord(row))throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return row}function dataList(body,what){const list=isRecord(body)?body["dat\
|
|
8
|
-
a"]:void 0;if(!Array.isArray(list))throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return list}function formFields(category){const schema=category["schema"];const fields=isRecord(schema)?schema["form_fields"]:void 0;return Array.isArray(fields)?fields.filter(isRecord):[]}function optionLabel(field,key){const options=field?.["options"];if(!Array.isArray(
|
|
9
|
-
options))return key;const hit=options.filter(isRecord).find(o=>String(o["key"])===String(key));return hit!==void 0&&typeof hit["value"]==="string"?`${hit["value"]}\uFF08${String(key)}\uFF09`:key}function fieldText(value,field){if(value===null||value===void 0||value==="")return void 0;if(Array.isArray(value)){if(value.length===0)return void 0;return value.map(v=>typeof v==="string"||typeof v==="number"?String(optionLabel(field,v)):JSON.stringify(v)).join(", ")}if(typeof value==="boolean")return value?
|
|
10
|
-
"\u306F\u3044":"\u3044\u3044\u3048";if(typeof value==="number")return String(value);if(typeof value==="string"){if(field!==void 0?field["type"]==="richtext":/<\/?[a-z][^>]*>/i.test(value))return htmlToText(value);return String(optionLabel(field,value)).trim()}return JSON.stringify(value,null,2)}function contentDocument(body){const row=dataRecord(isRecord(body)?body["content"]:void 0,LABEL);const category=isRecord(body)&&isRecord(body["category"])?body["category"]:void 0;const values=isRecord(row["\
|
|
11
|
-
content"])?row["content"]:{};const fields=category===void 0?[]:formFields(category);const known=new Set(fields.map(f=>f["name"]));const sections=[];for(const field of fields){const name=field["name"];if(typeof name!=="string")continue;const text=fieldText(values[name],field);if(text===void 0)continue;sections.push({heading:typeof field["display_name"]==="string"&&field["display_name"]!==""?field["display_name"]:name,body:text})}for(const[name,value]of Object.entries(values)){if(known.has(name))continue;
|
|
12
|
-
const text=fieldText(value);if(text!==void 0)sections.push({heading:name,body:text})}const tags=Array.isArray(row["tags"])?row["tags"].filter(isRecord):[];if(tags.length>0)sections.push({heading:"\u30BF\u30B0",body:tags.map(t=>`- ${String(t["display_name"]??t["value"]??"")}\uFF08${String(t["id"]??"")}\uFF09`).join("\n")});return composeDocument(row["title"],[...metaLine("ID",row["id"]),...metaLine("\u30AB\u30C6\u30B4\u30EA",row["category_name"]??row["category_code"]),...metaLine("\u72B6\u614B",labelOf(
|
|
13
|
-
STATUSES,row["status"])),...metaLine("\u516C\u958B",labelOf(PUBLISH_STATUSES,row["publish_status"])),...metaLine("\u7248",row["version"]),...metaLine("\u4F5C\u6210\u8005",row["author_name"]),...metaLine("\u66F4\u65B0",row["updated_at"])],sections)}function labelOf(table,value){return typeof value==="string"&&table[value]!==void 0?`${table[value]}\uFF08${value}\uFF09`:value}function categoryDocument(body){const row=dataRecord(body,"\u30AB\u30C6\u30B4\u30EA");const fields=formFields(row);const lines=fields.
|
|
14
|
-
map(f=>{const options=Array.isArray(f["options"])&&f["options"].length>0?` \u9078\u629E\u80A2: ${f["options"].filter(isRecord).map(o=>`${String(o["value"])}\uFF08${String(o["key"])}\uFF09`).join(" / ")}`:"";return`- ${String(f["display_name"]??f["name"])}\uFF08${String(f["name"])}\u30FB${String(f["type"])}${f["required"]===true?"\u30FB\u5FC5\u9808":""}\uFF09${options}`});return composeDocument(row["name"],[...metaLine("ID",row["id"]),...metaLine("\u30B3\u30FC\u30C9",row["code"]),...metaLine("\u8AAC\u660E",
|
|
15
|
-
row["description"]),...metaLine("\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",row["workflow_enabled"]===true?"\u3042\u308A":"\u306A\u3057")],[{heading:`\u30D5\u30A9\u30FC\u30E0\u9805\u76EE\uFF08${fields.length} \u4EF6\uFF09`,body:lines.join("\n")}])}function noArgs(input,usage){if(input.args.length>0)throw new UsageError(`\u4F4D\u7F6E\u5F15\u6570\u306F\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,usage)}var CONTENT_REF_FLAG={name:"--content",summary:"\u5BFE\u8C61\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",
|
|
16
|
-
takesValue:true,placeholder:"<\u30B3\u30F3\u30C6\u30F3\u30C4ID>"};function contentId(input,usage){const id=singleRef(input,{flag:CONTENT_REF_FLAG.name,label:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID",usage});if(!isSafePathSegment(id))throw new UsageError(`\u30B3\u30F3\u30C6\u30F3\u30C4\u306E ID \u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${id}`,ID_HELP);return id}var contentPath=(id,suffix="")=>`${CONTENTS_PATH}/${encodeURIComponent(id)}${suffix}`;function serverId(id,what){if(!isSafePathSegment(
|
|
17
|
-
id))throw new ApiResponseError(`\u30B5\u30FC\u30D0\u304C\u8FD4\u3057\u305F${what}\u306E ID \u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${id}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return id}async function categoryIdOf(ref,ctx,flag){const value=ref.trim();if(UUID_RE.test(value))return value;return serverId((await ctx.resolver.cmsCategory(value,flag)).id,"\u30AB\u30C6\u30B4\u30EA")}function enumValue(input,flag,table){const raw=nonEmpty(input.
|
|
18
|
-
flags,flag)?.trim();if(raw===void 0)return void 0;if(Object.hasOwn(table,raw))return raw;const byLabel=Object.entries(table).find(([,label])=>label===raw);if(byLabel!==void 0)return byLabel[0];throw new UsageError(`${flag} \u306B\u6307\u5B9A\u3067\u304D\u306A\u3044\u5024\u3067\u3059: ${raw}`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${Object.entries(table).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")} \u3067\u3059\u3002`)}function sortQuery(raw){if(raw===void 0)return{};const usage=`--sort\
|
|
19
|
-
\u306F\u300C\u5217[:asc|desc]\u300D\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u6700\u5927 ${MAX_SORT_COLUMNS} \u3064\uFF08\u5217\u306F ${SORTABLE_COLUMNS.join(" / ")}\uFF09\u3002\u4F8B: --sort updated_at:desc,title`;const parts=raw.split(",").map(p=>p.trim());if(parts.some(p=>p===""))throw new UsageError(`--sort \u306B\u7A7A\u306E\u5217\u304C\u3042\u308A\u307E\u3059: ${raw}`,usage);if(parts.length>MAX_SORT_COLUMNS)throw new UsageError(`--sort \u306B\u6307\u5B9A\u3067\u304D\u308B\u5217\u306F ${MAX_SORT_COLUMNS}\
|
|
20
|
-
\u3064\u307E\u3067\u3067\u3059: ${raw}`,usage);const columns=[];const directions=[];for(const part of parts){const[column="",direction="",...rest]=part.split(":").map(s=>s.trim());if(rest.length>0||!SORTABLE_COLUMNS.includes(column))throw new UsageError(`--sort \u306B\u6307\u5B9A\u3067\u304D\u306A\u3044\u5217\u3067\u3059: ${part}`,usage);if(direction!==""&&direction!=="asc"&&direction!=="desc")throw new UsageError(`--sort \u306E\u5411\u304D\u306F asc \u304B desc \u3067\u3059: ${part}`,usage);columns.
|
|
21
|
-
push(column);directions.push(direction)}return{sort_column:columns.join(","),...directions.some(d=>d!=="")?{sort_direction:directions.join(",")}:{}}}var LIST_USAGE="twp content list [--keyword <\u8A9E>] [--category <\u30AB\u30C6\u30B4\u30EA>] [--status <\u72B6\u614B>] [--publish-status <\u516C\u958B\u72B6\u614B>] [--sort <\u5217[:asc|desc]>,\u2026] [--limit <\u4EF6\u6570>] [--all]";var listOperation={name:"list",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4E00\u89A7\u3059\u308B\uFF08--keyword / --category / --status / --publish-status / --sort\uFF09",
|
|
22
|
-
usage:LIST_USAGE,description:`--category \u306F\u30AB\u30C6\u30B4\u30EA\u306E ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\uFF08twp content category list \u3067\u78BA\u8A8D\uFF09\u3002
|
|
23
|
-
--status \u306F ${Object.entries(STATUSES).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")}\u3001--publish-status \u306F ${Object.entries(PUBLISH_STATUSES).map(([k,v])=>`${k}\uFF08${v}\uFF09`).join(" / ")} \u3067\u3059\uFF08\u8868\u793A\u540D\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\uFF09\u3002
|
|
24
|
-
--sort \u306F\u753B\u9762\u306E\u5217\u898B\u51FA\u3057\u306E\u4E26\u3079\u66FF\u3048\u3068\u540C\u3058\u3067\u3001${SORTABLE_COLUMNS.join(" / ")} \u3092\u6700\u5927 ${MAX_SORT_COLUMNS} \u5217\u307E\u3067\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
25
|
-
--limit \u306E\u4E0A\u9650\u306F\u30B5\u30FC\u30D0\u5074\u3067 ${LIST_LIMIT_MAX} \u4EF6\u3067\u3059\uFF08\u65E2\u5B9A 20 \u4EF6\uFF09\u3002
|
|
26
|
-
|
|
27
|
-
--output json \u306F\u672C\u6587\uFF08content\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
28
|
-
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${LIST_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002
|
|
29
|
-
|
|
30
|
-
`+LIST_PAGING_HELP,flags:[{name:"--keyword",summary:"\u30BF\u30A4\u30C8\u30EB\u30FB\u672C\u6587\u306E\u8A9E\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u8A9E>"},{name:"--category",summary:"\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"},{name:"--status",summary:"\u72B6\u614B\uFF08draft / pending_review / approved / rejected / archived / published\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",
|
|
31
|
-
takesValue:true,placeholder:"<\u72B6\u614B>"},{name:"--publish-status",summary:"\u516C\u958B\u72B6\u614B\uFF08unpublished / published / scheduled\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",takesValue:true,placeholder:"<\u516C\u958B\u72B6\u614B>"},{name:"--sort",summary:`\u4E26\u3079\u66FF\u3048\uFF08\u5217[:asc|desc] \u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A\u30FB\u6700\u5927 ${MAX_SORT_COLUMNS} \u5217\uFF09`,takesValue:true,placeholder:"<\u5217[:asc|desc]>,\u2026"},...LIST_FLAGS],async prepare(input,ctx){
|
|
32
|
-
noArgs(input,LIST_USAGE);listQuery(input);const category=nonEmpty(input.flags,"--category");if(category===void 0)return input;return withResolved(input,{category_id:await categoryIdOf(category,ctx,"--category")})},plan:input=>({method:"GET",path:CONTENTS_PATH,query:{...listQuery(input),category_id:input.resolved?.["category_id"]}}),paging:envelopePaging({label:`${LABEL}\u4E00\u89A7`}),summarize:body=>itemsOf(body).map(row=>pick(row,LIST_COLUMNS)),raw:body=>itemsOf(body),notes:body=>isRecord(body)&&
|
|
33
|
-
body["sort_truncated"]===true?["\u26A0 \u30B5\u30FC\u30D0\u304C\u4E26\u3079\u66FF\u3048\u306E\u5BFE\u8C61\u3092\u4E0A\u9650\u3067\u6253\u3061\u5207\u308A\u307E\u3057\u305F\u3002\u7D50\u679C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08--keyword / --category \u3067\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044\uFF09\u3002"]:[]};function listQuery(input){const limit=positiveInteger(input.flags,"--limit");return{keyword:boundedText(input,"--keyword",{maxChars:255,label:"\u691C\u7D22\u8A9E"})?.
|
|
34
|
-
trim(),status:enumValue(input,"--status",STATUSES),publish_status:enumValue(input,"--publish-status",PUBLISH_STATUSES),...sortQuery(nonEmpty(input.flags,"--sort")),limit:limit===void 0?void 0:String(limit),cursor:nonEmpty(input.flags,"--cursor")}}function itemsOf(body){const items=isRecord(body)?body["items"]:void 0;if(!Array.isArray(items))throw new ApiResponseError(`${LABEL}\u4E00\u89A7\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
35
|
-
return items}var GET_USAGE="twp content get <\u30B3\u30F3\u30C6\u30F3\u30C4ID> [--output text]";var getOperation={name:"get",summary:"\u30B3\u30F3\u30C6\u30F3\u30C41\u4EF6\u3092\u8868\u793A\u3059\u308B\uFF08--output text \u3067\u672C\u6587\u3092\u9805\u76EE\u540D\u3064\u304D\u3067\u8AAD\u3081\u308B\u5F62\u306B\uFF09",usage:GET_USAGE,description:"\u7D9A\u3051\u3066\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3082\u53D6\u5F97\u3057\u3001--output text \u3067\u306F\u672C\u6587\u306E\u5404\u9805\u76EE\u3092\u753B\u9762\u3068\u540C\u3058\u9805\u76EE\u540D\uFF08display_name\uFF09\u30FB\u9806\u5E8F\u3067\u4E26\u3079\u307E\u3059\u3002\n\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306B\u7121\u3044\u5024\uFF08\u5B9A\u7FA9\u304B\u3089\u5916\u3057\u305F\u9805\u76EE\uFF09\u3082\u3001\u9805\u76EE\u306E\u5185\u90E8\u540D\u306E\u307E\u307E\u672B\u5C3E\u306B\u51FA\u3057\u307E\u3059\u3002\n\n--output json \u306F\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u30BF\u30B0\u30FB\u7DE8\u96C6\u53EF\u5426\u3092\
|
|
36
|
-
\u542B\u3080\uFF09\u3067\u3059\u3002",flags:[CONTENT_REF_FLAG],plan:input=>({method:"GET",path:contentPath(contentId(input,GET_USAGE))}),plannedNotes:()=>["\u7D9A\u3051\u3066\u30AB\u30C6\u30B4\u30EA\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08GET /api/v2/cms/categories/{\u30AB\u30C6\u30B4\u30EAID}\uFF09\u3082\u53D6\u5F97\u3057\u307E\u3059\u3002"],async execute(input,ctx){const content=await ctx.send({method:"GET",path:contentPath(contentId(input,GET_USAGE))});const categoryId=dataRecord(content,
|
|
37
|
-
LABEL)["category_id"];if(typeof categoryId!=="string"||categoryId==="")return{content,category:null};try{return{content,category:dataRecord(await ctx.send({method:"GET",path:`${CATEGORIES_PATH}/${encodeURIComponent(serverId(categoryId,"\u30AB\u30C6\u30B4\u30EA"))}`}),"\u30AB\u30C6\u30B4\u30EA")}}catch(error){if(!(error instanceof ApiError&&error.status===404))throw error;ctx.warn(`\u30AB\u30C6\u30B4\u30EA\uFF08${categoryId}\uFF09\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\u305F\u3081\u3001\u672C\u6587\u306E\u9805\u76EE\u306F\u5185\u90E8\u540D\u3067\u51FA\u3057\u307E\u3059\uFF08${error.
|
|
38
|
-
message}\uFF09`);return{content,category:null}}},summarize:body=>pick(contentRow(body),GET_COLUMNS),raw:body=>contentRow(body),document:contentDocument};function contentRow(body){return dataRecord(isRecord(body)?body["content"]:void 0,LABEL)}var HISTORY_USAGE="twp content history <\u30B3\u30F3\u30C6\u30F3\u30C4ID> [--limit <\u4EF6\u6570>]";var historyOperation={name:"history",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u5909\u66F4\u5C65\u6B74\uFF08\u7248\u30FB\u64CD\u4F5C\u30FB\u30B3\u30E1\u30F3\u30C8\uFF09\u3092\u4E00\u89A7\u3059\u308B",
|
|
39
|
-
usage:HISTORY_USAGE,description:`--output json \u306F\u5404\u7248\u306E\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8\uFF08snapshot\uFF09\u3068\u5909\u66F4\u70B9\uFF08changes\uFF09\u3092\u542B\u307F\u307E\u3059\u3002
|
|
40
|
-
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${HISTORY_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002`,flags:[CONTENT_REF_FLAG,{name:"--limit",summary:"\u53D6\u5F97\u4EF6\u6570",takesValue:true,placeholder:"<\u4EF6\u6570>"}],plan(input){const limit=positiveInteger(input.flags,"--limit");return{method:"GET",path:contentPath(contentId(input,HISTORY_USAGE),"/history"),query:{limit:limit===void 0?void 0:String(limit)}}},summarize:body=>dataList(body,`${LABEL}\u306E\u5909\u66F4\u5C65\u6B74`).
|
|
41
|
-
map(row=>pick(row,HISTORY_COLUMNS)),raw:body=>dataList(body,`${LABEL}\u306E\u5909\u66F4\u5C65\u6B74`)};var DIFF_USAGE="twp content diff <\u30B3\u30F3\u30C6\u30F3\u30C4ID>";var diffOperation={name:"diff",summary:"\u4E0B\u66F8\u304D\u3068\u516C\u958B\u4E2D\u306E\u7248\u3092\u4E26\u3079\u3001\u672A\u516C\u958B\u306E\u5909\u66F4\u304C\u3042\u308B\u304B\u3092\u8868\u793A\u3059\u308B",usage:DIFF_USAGE,description:"--output json \u306F\u4E0B\u66F8\u304D\uFF08draft\uFF09\u3068\u516C\u958B\u4E2D\uFF08published\u30FB\u672A\u516C\u958B\u306A\u3089 null\uFF09\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002\ntable / text / tsv \u306F\u3001\u5024\u304C\u9055\u3046\u9805\
|
|
42
|
-
\u76EE\uFF08\u30BF\u30A4\u30C8\u30EB\u30FB\u672C\u6587\u306E\u5404\u9805\u76EE\uFF09\u3060\u3051\u3092\u300C\u9805\u76EE / \u4E0B\u66F8\u304D / \u516C\u958B\u4E2D\u300D\u3067\u4E26\u3079\u307E\u3059\u3002",flags:[CONTENT_REF_FLAG],plan:input=>({method:"GET",path:contentPath(contentId(input,DIFF_USAGE),"/diff")}),summarize:body=>diffRows(dataRecord(body,`${LABEL}\u306E\u5DEE\u5206`)),raw:body=>dataRecord(body,`${LABEL}\u306E\u5DEE\u5206`),notes(body){const diff=dataRecord(body,`${LABEL}\u306E\u5DEE\u5206`);
|
|
43
|
-
if(diff["published"]===null||diff["published"]===void 0)return["\u307E\u3060\u516C\u958B\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08\u516C\u958B\u4E2D\u306E\u7248\u304C\u3042\u308A\u307E\u305B\u3093\uFF09\u3002"];if(diff["has_changes"]!==true)return["\u4E0B\u66F8\u304D\u306F\u516C\u958B\u4E2D\u306E\u7248\u3068\u540C\u3058\u3067\u3059\u3002"];return[diffRows(diff).length>0?"\u672A\u516C\u958B\u306E\u5909\u66F4\u304C\u3042\u308A\u307E\u3059\u3002":"\u672A\u516C\u958B\u306E\u7248\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u30BF\u30A4\u30C8\u30EB\u30FB\u30B9\u30E9\u30C3\u30B0\u30FB\u672C\u6587\u306E\u5024\u306F\u516C\u958B\u4E2D\u306E\u7248\u3068\u540C\u3058\u3067\u3059\uFF08\u629C\u7C8B\u30FBSEO \
|
|
44
|
-
\u7B49\u306E\u5DEE\u306F --output json \u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002"]}};function diffRows(diff){const draft=isRecord(diff["draft"])?diff["draft"]:{};const published=isRecord(diff["published"])?diff["published"]:{};const rows=[];const compare=(field,a2,b2)=>{if(fieldText(a2)===void 0&&fieldText(b2)===void 0)return;if(JSON.stringify(a2??null)!==JSON.stringify(b2??null))rows.push({field,draft:fieldText(a2)??null,published:fieldText(b2)??null})};compare("title",
|
|
45
|
-
draft["title"],published["title"]);compare("slug",draft["slug"],published["slug"]);const a=isRecord(draft["content"])?draft["content"]:{};const b=isRecord(published["content"])?published["content"]:{};for(const key of[...new Set([...Object.keys(a),...Object.keys(b)])])compare(`content.${key}`,a[key],b[key]);return rows}var WORKFLOW_USAGE="twp content workflow <\u30B3\u30F3\u30C6\u30F3\u30C4ID>";var workflowOperation={name:"workflow",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u516C\u958B\u7533\u8ACB\uFF08\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\uFF09\u306E\u72B6\u6CC1\u3092\u8868\u793A\u3059\u308B",
|
|
46
|
-
usage:WORKFLOW_USAGE,description:"\u516C\u958B\u7533\u8ACB\u3092\u3057\u3066\u3044\u306A\u3044\u30B3\u30F3\u30C6\u30F3\u30C4\u306F\u30B5\u30FC\u30D0\u304C 404\uFF08\u300C\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u60C5\u5831\u304C\u3042\u308A\u307E\u305B\u3093\u300D\uFF09\u3092\u8FD4\u3057\u307E\u3059\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 3\uFF09\u3002\n--output json \u306F\u7533\u8ACB\uFF08instance\uFF09\u30FB\u6BB5\u306E\u5C65\u6B74\uFF08step_history\uFF09\u30FB\u7D4C\u8DEF\uFF08workflow_steps\uFF09\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002",
|
|
47
|
-
flags:[CONTENT_REF_FLAG],plan:input=>({method:"GET",path:contentPath(contentId(input,WORKFLOW_USAGE),"/workflow")}),summarize(body){const data=dataRecord(body,"\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC");const instance=isRecord(data["instance"])?data["instance"]:{};const state=isRecord(data["workflow_state"])?data["workflow_state"]:{};return{workflow_status:state["status"]??null,instance_id:instance["id"]??null,workflow_name:instance["workflow_name"]??null,applicant_name:instance["applicant_name"]??null,
|
|
48
|
-
status:instance["status"]??null,current_step_no:instance["current_step_no"]??null,applied_at:state["applied_at"]??null}},raw:body=>dataRecord(body,"\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC")};function withoutHookSecrets(category){if(!isRecord(category))return category;const hook=category["publish_hook_settings"];if(!isRecord(hook)||!Array.isArray(hook["headers"]))return category;const headers=hook["headers"].map(h=>isRecord(h)&&h["value"]!==void 0&&h["value"]!==null&&h["value"]!==""?{...h,value:REDACTED}:
|
|
49
|
-
h);return{...category,publish_hook_settings:{...hook,headers}}}var CATEGORY_LIST_USAGE="twp content category list [--active | --inactive]";var categoryListOperation={name:"list",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30AB\u30C6\u30B4\u30EA\u3092\u4E00\u89A7\u3059\u308B",usage:CATEGORY_LIST_USAGE,description:`--output json \u306F\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08schema.form_fields\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002
|
|
50
|
-
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${CATEGORY_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002`,flags:activeFlags("\u30AB\u30C6\u30B4\u30EA"),plan(input){noArgs(input,CATEGORY_LIST_USAGE);return{method:"GET",path:CATEGORIES_PATH,query:{is_active:activeQuery(input)}}},summarize:body=>dataList(body,"\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7").map(row=>pick(row,CATEGORY_COLUMNS)),raw:body=>dataList(body,"\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7").map(withoutHookSecrets)};var CATEGORY_REF_FLAG={
|
|
51
|
-
name:"--category",summary:"\u5BFE\u8C61\u306E\u30AB\u30C6\u30B4\u30EA\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"};var CATEGORY_GET_USAGE="twp content category get <\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09> [--output text]";var categoryGetOperation={name:"get",summary:"\u30AB\u30C6\u30B4\u30EA1\u4EF6\u3068\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\uFF08\u9805\u76EE\u540D\u30FB\u578B\u30FB\u5FC5\u9808\u30FB\u9078\u629E\u80A2\uFF09\u3092\u8868\u793A\u3059\u308B",
|
|
52
|
-
usage:CATEGORY_GET_USAGE,description:"\u30AB\u30C6\u30B4\u30EA\u306F ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n--output table / tsv \u306F\u30D5\u30A9\u30FC\u30E0\u9805\u76EE\u30921\u884C\u305A\u3064\uFF08name / display_name / type / required / options\uFF09\u3001--output text \u306F\u8AAD\u3081\u308B\u5F62\u3067\u51FA\u3057\u307E\u3059\u3002\n--output json \u306F\u30AB\u30C6\u30B4\u30EA\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002",
|
|
53
|
-
flags:[CATEGORY_REF_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:CATEGORY_REF_FLAG.name,label:"\u30AB\u30C6\u30B4\u30EA",usage:CATEGORY_GET_USAGE});return withResolved(input,{id:await categoryIdOf(ref,ctx,"<\u30AB\u30C6\u30B4\u30EA>")})},plan:input=>({method:"GET",path:`${CATEGORIES_PATH}/${encodeURIComponent(requireResolved(input,"id"))}`}),summarize:body=>formFields(dataRecord(body,"\u30AB\u30C6\u30B4\u30EA")).map(f=>({...pick(f,FIELD_COLUMNS),options:Array.isArray(f["options"])?
|
|
54
|
-
f["options"].filter(isRecord).map(o=>`${String(o["key"])}=${String(o["value"])}`).join(" / "):null})),raw:body=>withoutHookSecrets(dataRecord(body,"\u30AB\u30C6\u30B4\u30EA")),document:categoryDocument};function activeFlags(what){return[{name:"--active",summary:`\u6709\u52B9\u306A${what}\u3060\u3051`,takesValue:false},{name:"--inactive",summary:`\u7121\u52B9\u306A${what}\u3060\u3051`,takesValue:false}]}function activeQuery(input){if(input.flags.has("--active")&&input.flags.has("--inactive"))throw new UsageError(
|
|
55
|
-
"--active \u3068 --inactive \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");if(input.flags.has("--active"))return"true";if(input.flags.has("--inactive"))return"false";return void 0}var TAG_DESCRIPTION=`--output json \u306F\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3067\u3059\u3002--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${TAG_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u3042\u308A\u307E\u305B\u3093\u3002`;function tagListOperation(name,summary,usage,path,extra=[]){
|
|
56
|
-
return{name,summary,usage,description:TAG_DESCRIPTION,flags:[...extra,...activeFlags("\u30BF\u30B0")],plan(input){noArgs(input,usage);return{method:"GET",path,query:{is_active:activeQuery(input),scope:nonEmpty(input.flags,"--scope")?.trim()}}},summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")}}var TAG_SCOPE_FLAG={name:"--scope",summary:"\u30B9\u30B3\u30FC\u30D7\uFF08free=\u81EA\u7531\u30BF\u30B0 / field:<\u30AB\u30C6\u30B4\u30EAID>:<\u9805\u76EE\u540D>\uFF09\u3067\u7D5E\u308A\u8FBC\u3080",
|
|
57
|
-
takesValue:true,placeholder:"<\u30B9\u30B3\u30FC\u30D7>"};var tagList=tagListOperation("list","\u30BF\u30B0\u3092\u4E00\u89A7\u3059\u308B\uFF08\u81EA\u7531\u30BF\u30B0\u3068\u30D5\u30A3\u30FC\u30EB\u30C9\u30BF\u30B0\u306E\u4E21\u65B9\uFF09","twp content tag list [--scope <\u30B9\u30B3\u30FC\u30D7>] [--active | --inactive]",TAGS_PATH,[TAG_SCOPE_FLAG]);var tagFree=tagListOperation("free","\u81EA\u7531\u30BF\u30B0\uFF08\u3069\u306E\u9805\u76EE\u306B\u3082\u5C5E\u3055\u306A\u3044\u30BF\u30B0\uFF09\u3092\u4E00\u89A7\u3059\u308B",
|
|
58
|
-
"twp content tag free [--active | --inactive]",`${TAGS_PATH}/free`);var TAG_FIELD_USAGE="twp content tag field <\u30AB\u30C6\u30B4\u30EA\uFF08ID\u30FB\u30B3\u30FC\u30C9\u30FB\u540D\u524D\uFF09> <\u9805\u76EE\u540D>";var tagField={name:"field",summary:"\u30AB\u30C6\u30B4\u30EA\u306E\u30BF\u30B0\u578B\u306E\u9805\u76EE\u306B\u4ED8\u3044\u305F\u30BF\u30B0\u3092\u4E00\u89A7\u3059\u308B",usage:TAG_FIELD_USAGE,description:`\u9805\u76EE\u540D\u306F\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E name\uFF08twp content category get \u3067\u78BA\u8A8D\uFF09\u3067\u3059\u3002
|
|
59
|
-
${TAG_DESCRIPTION}`,flags:activeFlags("\u30BF\u30B0"),async prepare(input,ctx){const[category,field,...rest]=input.args;if(category===void 0||field===void 0||rest.length>0||field.trim()===""){throw new UsageError("\u30AB\u30C6\u30B4\u30EA\u3068\u9805\u76EE\u540D\u30921\u3064\u305A\u3064\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",TAG_FIELD_USAGE)}if(!isSafePathSegment(field.trim()))throw new UsageError(`\u9805\u76EE\u540D\u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${field}`,
|
|
60
|
-
TAG_FIELD_USAGE);return withResolved(input,{category_id:await categoryIdOf(category,ctx,"<\u30AB\u30C6\u30B4\u30EA>"),field:field.trim()})},plan:input=>({method:"GET",path:`${TAGS_PATH}/field/${encodeURIComponent(requireResolved(input,"category_id"))}/${encodeURIComponent(requireResolved(input,"field"))}`,query:{is_active:activeQuery(input)}}),summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")};var TAG_SEARCH_USAGE="\
|
|
61
|
-
twp content tag search <\u8A9E> [--scope <\u30B9\u30B3\u30FC\u30D7>]";var tagSearch={name:"search",summary:"\u5024\u30FB\u8868\u793A\u540D\u306E\u8A9E\u3067\u30BF\u30B0\u3092\u63A2\u3059",usage:TAG_SEARCH_USAGE,description:TAG_DESCRIPTION,flags:[TAG_SCOPE_FLAG,...activeFlags("\u30BF\u30B0")],plan(input){const q=singleRef(input,{flag:"--query",label:"\u691C\u7D22\u8A9E",usage:TAG_SEARCH_USAGE});return{method:"GET",path:`${TAGS_PATH}/search`,query:{q,scope:nonEmpty(input.flags,"--scope")?.trim(),is_active:activeQuery(
|
|
62
|
-
input)}}},summarize:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7").map(row=>pick(row,TAG_COLUMNS)),raw:body=>dataList(body,"\u30BF\u30B0\u4E00\u89A7")};var TAG_GET_USAGE="twp content tag get <\u30BF\u30B0\uFF08ID\u30FB\u5024\u30FB\u8868\u793A\u540D\uFF09>";var tagGet={name:"get",summary:"\u30BF\u30B01\u4EF6\u3092\u8868\u793A\u3059\u308B",usage:TAG_GET_USAGE,description:"\u30BF\u30B0\u306F ID\u30FB\u5024\uFF08value\uFF09\u30FB\u8868\u793A\u540D\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\u8868\u793A\u540D\u304C\u91CD\u306A\u308B\u3068\u304D\u306F\u5019\u88DC\u3092\u51FA\u3057\u3066\u6B62\u3081\u307E\u3059\uFF08ID \u304B\u5024\u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",
|
|
63
|
-
flags:[{name:"--tag",summary:"\u5BFE\u8C61\u306E\u30BF\u30B0\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",takesValue:true,placeholder:"<\u30BF\u30B0>"}],async prepare(input,ctx){const ref=singleRef(input,{flag:"--tag",label:"\u30BF\u30B0",usage:TAG_GET_USAGE});const id=UUID_RE.test(ref)?ref:serverId((await ctx.resolver.cmsTag(ref)).id,"\u30BF\u30B0");return withResolved(input,{id})},plan:input=>({method:"GET",path:`${TAGS_PATH}/${encodeURIComponent(requireResolved(
|
|
64
|
-
input,"id"))}`}),summarize:body=>pick(dataRecord(body,"\u30BF\u30B0"),[...TAG_COLUMNS,"color","sort","is_system","updated_at"]),raw:body=>dataRecord(body,"\u30BF\u30B0")};function withForbidden(operations){return operations.map(op=>({...op,forbidden:FORBIDDEN}))}var categoryResource={name:"category",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30AB\u30C6\u30B4\u30EA\uFF08\u4E00\u89A7\u30FB\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E\u8868\u793A\uFF09",operations:withForbidden([categoryListOperation,
|
|
65
|
-
categoryGetOperation])};var tagResource={name:"tag",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u30BF\u30B0\uFF08\u4E00\u89A7\u30FB\u81EA\u7531\u30BF\u30B0\u30FB\u9805\u76EE\u306E\u30BF\u30B0\u30FB\u691C\u7D22\u30FB\u8868\u793A\uFF09",operations:withForbidden([tagList,tagFree,tagField,tagSearch,tagGet])};var contentDomain={name:"content",summary:"\u30B3\u30F3\u30C6\u30F3\u30C4\u7BA1\u7406\uFF08CMS\uFF09\u306E\u8AAD\u307F\u53D6\u308A\uFF08\u4E00\u89A7\u30FB\u672C\u6587\u30FB\u5909\u66F4\u5C65\u6B74\u30FB\u5DEE\u5206\u30FB\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u30FB\u30AB\u30C6\u30B4\u30EA\u30FB\u30BF\u30B0\uFF09",
|
|
66
|
-
operations:withForbidden([listOperation,getOperation,historyOperation,diffOperation,workflowOperation]),subresources:[categoryResource,tagResource]};export{contentDomain,diffRows,fieldText,sortQuery,withoutHookSecrets};
|