@takagaki/cortex-decisions-viewer 0.12.276 → 0.12.278
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/dist/build.js +151 -40
- package/dist/forward-reads.js +98 -0
- package/dist/intake-code-lines.js +19 -0
- package/dist/member-page.js +122 -94
- package/dist/memory-evidence.js +2 -0
- package/dist/render.js +170 -145
- package/dist/run-history.js +39 -33
- package/package.json +1 -1
package/dist/run-history.js
CHANGED
|
@@ -101,14 +101,16 @@ function runRowsShownOf(rows, nowMs, days) {
|
|
|
101
101
|
}
|
|
102
102
|
return out;
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
105
|
-
|
|
104
|
+
/**
|
|
105
|
+
* 行のきっかけの語(開始の押しは「開始」・毎晩・今すぐ更新・運営)。知らない語は空文字。
|
|
106
|
+
* 表は引数で受ける(`RUN_CAUSE_WORDS`・`RUN_KIND_WORDS`・forward-reads.ts。題材の `expects.words` と突き合わせる)
|
|
107
|
+
*/
|
|
108
|
+
function runCauseWordOf(row, causes, kinds) {
|
|
106
109
|
if (!row || typeof row !== "object")
|
|
107
110
|
return "";
|
|
108
|
-
if (row.kind === "
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
return Object.prototype.hasOwnProperty.call(words, row.cause) ? words[row.cause] : "";
|
|
111
|
+
if (typeof row.kind === "string" && Object.prototype.hasOwnProperty.call(kinds, row.kind))
|
|
112
|
+
return kinds[row.kind];
|
|
113
|
+
return typeof row.cause === "string" && Object.prototype.hasOwnProperty.call(causes, row.cause) ? causes[row.cause] : "";
|
|
112
114
|
}
|
|
113
115
|
/** 行の最後の試行(`runId`・`attempt` の大きい方。並びに頼らない)。形の違う試行は飛ばす。無ければ null */
|
|
114
116
|
function runLastAttemptOf(row) {
|
|
@@ -125,60 +127,64 @@ function runLastAttemptOf(row) {
|
|
|
125
127
|
/**
|
|
126
128
|
* 行の状態(設計 §2「報告の無い行の言い分け」)。
|
|
127
129
|
* - `not_run` … 押したが走らなかった(試行も run へのリンクも無い・開始に失敗した押し)
|
|
128
|
-
* - `running` … 最後の試行がまだ終わっていない(結果の語が走っている側の語)
|
|
129
130
|
* - `done` … それ以外(開けるかは `runRowOpenRunOf` が決める)
|
|
130
|
-
*
|
|
131
|
+
* 試行の結果の語(ポータルの `attempts[].outcome`)は、どれも終わった試行の語なので語で状態を分けない(語の一覧も持たない。
|
|
132
|
+
* 走っている側の語は契約に無い。cortex-engine #2896 便 MEMBER-ONE-TRUTH 3 版・仕上げ 2・tools 仕上げ 5)。
|
|
133
|
+
* 試行が 1 つも読めず run へのリンクだけがある行(試行の欄の無い古い行・結果の語が窓口の形を外れて落ちた試行)も `done` だが、
|
|
131
134
|
* 結果の文は言い切らない(`runRowResultTextOf` はポータルの文だけを出す)
|
|
132
135
|
*/
|
|
133
136
|
function runRowStateOf(row) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const running = ["in_progress", "queued", "requested", "waiting", "pending", "running"];
|
|
138
|
-
return running.indexOf(lastA.outcome) >= 0 ? "running" : "done";
|
|
137
|
+
if (runLastAttemptOf(row))
|
|
138
|
+
return "done";
|
|
139
|
+
return row && typeof row.runUrl === "string" && row.runUrl ? "done" : "not_run";
|
|
139
140
|
}
|
|
140
141
|
/** 行から開く回(最後の試行の `<runId>-<attempt>`)。試行が無ければ null(開けない) */
|
|
141
142
|
function runRowOpenRunOf(row) {
|
|
142
143
|
const lastA = runLastAttemptOf(row);
|
|
143
144
|
return lastA ? lastA.runId + "-" + lastA.attempt : null;
|
|
144
145
|
}
|
|
145
|
-
/** 行の結果の 1 文。ポータルの文(`message
|
|
146
|
+
/** 行の結果の 1 文。ポータルの文(`message`)があればそれ、無ければ空文字(試行の結果の語から文を作らない=言い切らない) */
|
|
146
147
|
function runRowResultTextOf(row) {
|
|
147
|
-
|
|
148
|
-
if (state === "not_run")
|
|
148
|
+
if (runRowStateOf(row) === "not_run")
|
|
149
149
|
return "走りませんでした";
|
|
150
|
-
|
|
151
|
-
return "実行中";
|
|
152
|
-
if (row && typeof row.message === "string" && row.message.trim())
|
|
153
|
-
return row.message.trim();
|
|
154
|
-
const lastA = runLastAttemptOf(row);
|
|
155
|
-
const words = { success: "終わりました", failure: "失敗しました", cancelled: "止めました", timed_out: "時間切れで止まりました" };
|
|
156
|
-
return lastA && Object.prototype.hasOwnProperty.call(words, lastA.outcome) ? words[lastA.outcome] : "";
|
|
150
|
+
return row && typeof row.message === "string" && row.message.trim() ? row.message.trim() : "";
|
|
157
151
|
}
|
|
158
152
|
/**
|
|
159
153
|
* 窓口の答え(一覧・1 回の中身)が 200 でないときの 1 文と、名乗り券を読み直すか。
|
|
160
|
-
*
|
|
161
|
-
*
|
|
154
|
+
* 入口の門の断り(券・参加)と、口がまだ無い一覧の 404 は共通の表(`INTAKE_CODE_LINES`・引数 `lines`)の 1 行と一手
|
|
155
|
+
* (cortex-engine #2896 便 MEMBER-ONE-TRUTH 3 版・リーダーの決め 1)。ほかの 403 は見る権限が無い・1 回のページの 404 は見つからない・
|
|
156
|
+
* 大きすぎる控えは言い分ける・ほか(届かない・5xx・打ち切り)は待ってから開き直す。
|
|
157
|
+
* `page` は `"list"`(一覧)か `"run"`(1 回のページ)。1 回のページの 404 は「見えない回・無い回」(運営の回が在るかを漏らさないので分けない)。
|
|
158
|
+
* 一覧(ポータルの memory-history の答え)の 400・403 で、この画面の表(`RUN_LIST_CODE_LINES`・引数 `codes`・forward-reads.ts)に在る語は、その 1 行。
|
|
159
|
+
* **クロージャを持たない純関数に保つこと**(`.toString()` でクライアントへ渡す)
|
|
162
160
|
*/
|
|
163
|
-
function runFailTextOf(status, body) {
|
|
161
|
+
function runFailTextOf(status, body, lines, page, codes) {
|
|
164
162
|
const code = body && typeof body === "object" ? body.code : undefined;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
const refused = status === 400 || status === 403;
|
|
164
|
+
const gate = refused && typeof code === "string" && Object.prototype.hasOwnProperty.call(lines, code) ? lines[code] : null;
|
|
165
|
+
if (gate)
|
|
166
|
+
return { text: gate.text, reopen: gate.forgetTicket };
|
|
167
|
+
if (page === "list" && refused && typeof code === "string" && Object.prototype.hasOwnProperty.call(codes, code))
|
|
168
|
+
return { text: codes[code], reopen: false };
|
|
168
169
|
if (status === 403)
|
|
169
170
|
return { text: "この案件の更新の記録を見る権限がありません", reopen: false };
|
|
171
|
+
if (status === 404 && page === "list")
|
|
172
|
+
return { text: lines.NOT_FOUND.text, reopen: false };
|
|
170
173
|
if (status === 404 || status === 400)
|
|
171
174
|
return { text: "この回は見つかりません(見られない回か、古い回です)", reopen: false };
|
|
172
175
|
if (status === 503 && code === "TOO_LARGE")
|
|
173
176
|
return { text: "この回の中身は大きすぎて、ここには出せません", reopen: false };
|
|
174
177
|
return { text: "更新の記録を読めませんでした。少し待ってから開き直してください", reopen: false };
|
|
175
178
|
}
|
|
176
|
-
/**
|
|
177
|
-
|
|
179
|
+
/**
|
|
180
|
+
* 一覧の `status`(ok 以外)の 1 文。ok は null(行を並べる)。語ごとの文は表(`RUN_HISTORY_STATUS_LINES`・forward-reads.ts)から引く。
|
|
181
|
+
* 表に無い語は「読めませんでした」
|
|
182
|
+
*/
|
|
183
|
+
function runHistoryStatusTextOf(status, lines) {
|
|
178
184
|
if (status === "ok")
|
|
179
185
|
return null;
|
|
180
|
-
if (status === "
|
|
181
|
-
return
|
|
186
|
+
if (typeof status === "string" && Object.prototype.hasOwnProperty.call(lines, status))
|
|
187
|
+
return lines[status];
|
|
182
188
|
return "更新の記録を読めませんでした。少し待ってから開き直してください";
|
|
183
189
|
}
|
|
184
190
|
/** 回の結果の語(報告の `outcome`)。知らない語は空文字 */
|
package/package.json
CHANGED