@takagaki/cortex-decisions-viewer 0.12.270 → 0.12.276

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 CHANGED
@@ -2521,13 +2521,22 @@ function evidenceRowsOf(section, items, keyOf, refs) {
2521
2521
  const key = it.url ? keyOf(it.url) : `text:${it.text_ref}`;
2522
2522
  // 言い直し(restated)は決めた場面(decided)と同じ根拠でも 1 行に溶かさない(日を言い直しの日に替えない)。照らしの鍵 `key` は同じまま
2523
2523
  const groupKey = `${it.kind === "restated" ? "restated" : "main"}\u0000${key}`;
2524
- const quotes = it.quotes.map((q) => ({ speaker: q.speaker, text: q.text, ...(q.time ? { time: q.time } : {}), ...(q.context ? { context: true } : {}) }));
2524
+ const quotes = it.quotes.map((q) => ({
2525
+ speaker: q.speaker, text: q.text, ...(q.time ? { time: q.time } : {}), ...(q.context ? { context: true } : {}),
2526
+ ...(q.role ? { role: q.role } : {}), ...(q.url ? { url: q.url } : {}), ...(q.cond ? { cond: q.cond } : {}),
2527
+ }));
2525
2528
  const hit = byKey.get(groupKey);
2526
2529
  if (hit) {
2530
+ // 重なりの見分け: 文・話し手・前の発言・役目・元の URL(便 EV: 同じ文で役目だけ違う引用を潰さない)
2527
2531
  for (const q of quotes) {
2528
- if (!hit.quotes.some((x) => x.text === q.text && x.speaker === q.speaker && !!x.context === !!q.context))
2532
+ if (!hit.quotes.some((x) => x.text === q.text && x.speaker === q.speaker && !!x.context === !!q.context && x.role === q.role && x.url === q.url))
2529
2533
  hit.quotes.push(q);
2530
2534
  }
2535
+ for (const sg of it.signs ?? []) {
2536
+ const k = JSON.stringify(sg);
2537
+ if (!(hit.signs ?? []).some((x) => JSON.stringify(x) === k))
2538
+ (hit.signs ??= []).push(sg);
2539
+ }
2531
2540
  if (it.at > hit.at)
2532
2541
  hit.at = it.at;
2533
2542
  // 名前は先に積まれた項目のものを使う(後の項目で上書きしない)。先の項目に無ければ後の名前を採る
@@ -2542,7 +2551,7 @@ function evidenceRowsOf(section, items, keyOf, refs) {
2542
2551
  // 課題キーだけの名前は、帳の題名が引けるなら帳を先に使う(キーが題名より劣らない)
2543
2552
  const bookLabel = it.url ? refs.resolve(it.url).label : "";
2544
2553
  const label = it.url ? (it.label && WEAK_NAME_RE.test(it.label) && /backlog\.|github\.com\//i.test(it.url) ? bookLabel || it.label : it.label || bookLabel) || it.url : String(it.text_ref);
2545
- const row = { at: it.at, kind: it.kind, label, url: it.url, key, quotes };
2554
+ const row = { at: it.at, kind: it.kind, label, url: it.url, key, quotes, ...(it.signs?.length ? { signs: [...it.signs] } : {}) };
2546
2555
  if (it.label && !WEAK_NAME_RE.test(it.label))
2547
2556
  labelNight.set(row, it.night ?? "");
2548
2557
  byKey.set(groupKey, row);
@@ -18,7 +18,8 @@ exports.TENANT_INTAKE_SCOPE = "tenant";
18
18
  exports.TENANT_INTAKE_TABLES = {
19
19
  // `memory-refresh`・`memory-runs` は時計の今すぐ更新と要約(cortex-engine #2357 便 MT-VCLOCK-2・受け口の表と同じ)
20
20
  // `memory-history`・`memory-report` は更新の記録の一覧と 1 回の報告(cortex-engine #2893 便 RAIL-T2a・受け口の表と同じ)
21
- ops: ["state", "config", "probe", "secret", "slack-oauth-start", "google-confirm-info", "memory-refresh", "memory-runs", "memory-history", "memory-report"],
21
+ // `member-*`・`project-info*` はメンバーとプロジェクトの情報(cortex-engine #2896 便 RAIL-T2b・受け口の表と同じ)
22
+ ops: ["state", "config", "probe", "secret", "slack-oauth-start", "google-confirm-info", "memory-refresh", "memory-runs", "memory-history", "memory-report", "member-list", "member-preview", "member-invite", "member-remove", "project-info", "project-info-update"],
22
23
  // Google の確認の 3 つ(便 RS-T85f 続き)と Drive の入口②の許可(便 RS-T85g・受け口の `TENANT_INTAKE_GOOGLE_PAYLOAD_OPS`)。種別は op で決まるか、google-nonce は本文の kind
23
24
  configPayloadOps: ["google-nonce", "confirm-drive-folder", "confirm-google-chat-space", "connect-drive-account"],
24
25
  configKinds: ["github", "backlog", "slack", "drive", "google-chat", "memory"],
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ /**
3
+ * メンバーのページ・プロジェクトの情報・旗の出し分け(cortex-engine #2897 便 RAIL-T4・設計 #2860 確定版 §4・§5・§7 T4)。
4
+ *
5
+ * 画面(render.ts の埋め込み JS)へは `.toString()` で流し込む。🔴 **どの関数もクロージャを持たない純関数に保つ**
6
+ * (外の名前を参照しない。表は引数で受ける)。
7
+ *
8
+ * 🔴 **守りはポータルの門と intake の門。** ここは「押せないボタンを出さない」ための出し分けと、呼ぶ前に止める 1 段目だけ。
9
+ *
10
+ * 口の名前と答えの形(intake の `?op=`)は T2b(cortex-engine #2896・cortex-tools PR 1759)を正とする(便 RAIL-T4-2・#2897 の突き合わせの表 13 項目)。
11
+ * T2b はポータルの口(P1b)と 1 対 1 で結ばれている。食い違いが出たら、この 1 か所を直す(試験は表を通して見る)。
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.SOURCE_EDIT_LOCKED_BAND = exports.SOURCE_EDIT_LOCKED_TEXT = exports.SOURCE_EDIT_OPS = exports.MEMBER_PAGE_OPS = void 0;
15
+ exports.rightsOfState = rightsOfState;
16
+ exports.sourceEditBlocked = sourceEditBlocked;
17
+ exports.probeSyncBlocked = probeSyncBlocked;
18
+ exports.inviteEmailOf = inviteEmailOf;
19
+ exports.invitePlanOf = invitePlanOf;
20
+ exports.inviteResultLineOf = inviteResultLineOf;
21
+ exports.removeResultLineOf = removeResultLineOf;
22
+ exports.memberErrorLineOf = memberErrorLineOf;
23
+ exports.memberRowsOf = memberRowsOf;
24
+ exports.projectNameProblemOf = projectNameProblemOf;
25
+ /** intake の口の名前(画面が呼ぶ 6 本・T2b の `MEMBER_ADMIN_OPS` と同じ)。アイコンを変える・外す口は無い(#1781 で外した・戻さない) */
26
+ exports.MEMBER_PAGE_OPS = {
27
+ list: "member-list",
28
+ preview: "member-preview",
29
+ invite: "member-invite",
30
+ remove: "member-remove",
31
+ info: "project-info",
32
+ infoUpdate: "project-info-update",
33
+ };
34
+ /**
35
+ * つなぎ先を変える口(設計 §5 の `canEditSources` の対象)。`config` の `kind: "memory"`(右下の時計の開始・停止・再開)は
36
+ * 対象外(時計は `memoryCanOperate` が持つ)
37
+ */
38
+ exports.SOURCE_EDIT_OPS = ["config", "secret", "slack-oauth-start", "sync", "backlog-target-add", "backlog-target-remove"];
39
+ /** 社外の方がつなぎ先を変えようとしたときの 1 行(押した後・オーナーの答え Q7) */
40
+ exports.SOURCE_EDIT_LOCKED_TEXT = "つなぎ先を変えられるのは社内のメンバーだけです";
41
+ /** 設定のページの先頭の帯(症状と一手。押した後の 1 行と同じ文を繰り返さない) */
42
+ exports.SOURCE_EDIT_LOCKED_BAND = "社外の方は、つなぎ先を変えられません。変更は社内のメンバーに頼んでください";
43
+ /**
44
+ * op=state の `permissions`(設計 §5・T2b の閉じた 5 欄)を読む。呼び手は `state.permissions` を渡す(頭の欄ではない)。
45
+ * 欄が無い(門を通った人が居ない配り・古い intake・取得前)・真偽でない値は null=「分からない」。
46
+ * 🔴 null は押せない側に倒す(メンバー・情報)。ただし つなぎ先だけは null で止めない(今まで押せていた人を古い intake で締め出さない)
47
+ */
48
+ function rightsOfState(j) {
49
+ const o = j && typeof j === "object" ? j : {};
50
+ const b = (v) => (typeof v === "boolean" ? v : null);
51
+ return {
52
+ editSources: b(o.canEditSources),
53
+ manageMembers: b(o.canManageMembers),
54
+ requestInvite: b(o.canRequestInvite),
55
+ editIcon: b(o.canEditIcon),
56
+ classify: b(o.canClassify),
57
+ };
58
+ }
59
+ /** この呼び出しを つなぎ先の旗で止めるか(旗が false のときだけ・時計の config は止めない)。ops は SOURCE_EDIT_OPS(引数で受ける・純関数に保つ) */
60
+ function sourceEditBlocked(op, body, rights, ops) {
61
+ if (!rights || rights.editSources !== false)
62
+ return false;
63
+ if (typeof op !== "string" || ops.indexOf(op) < 0)
64
+ return false;
65
+ const p = body && typeof body === "object" ? body : {};
66
+ if (op === "config" && p.kind === "memory" && p.op === undefined)
67
+ return false;
68
+ return true;
69
+ }
70
+ /** 行ごとの[同期](probe に sync: true)も つなぎ先を動かす操作として止める。接続の確かめ(sync 無し)は止めない */
71
+ function probeSyncBlocked(op, body, rights) {
72
+ if (!rights || rights.editSources !== false || op !== "probe")
73
+ return false;
74
+ const p = body && typeof body === "object" ? body : {};
75
+ return p.sync === true;
76
+ }
77
+ /** メールアドレスの形だけを見る(判じの正本はポータル)。前後の空白は落として返す。形が違えば null */
78
+ function inviteEmailOf(v) {
79
+ if (typeof v !== "string")
80
+ return null;
81
+ const s = v.trim();
82
+ if (s.length > 254 || !/^[^\s@<>()",;:]+@[^\s@<>()",;:]+\.[^\s@<>()",;:]+$/.test(s))
83
+ return null;
84
+ return s;
85
+ }
86
+ /**
87
+ * 見立て(member-preview の答え `{ ok, verdict, mailer? }`・T2b の口)と旗から、ボタンと言い方を決める(設計 §4 の表)。
88
+ * verdict: `add`(名簿に居る・組織に属さない形でログイン済みの人も)/`invite-mail`(社内・名簿に居ない)/`invite-external`(社外・管理できる人)/
89
+ * `request-external`(社外・申請)/`already-member`/`operator-admin`(運営の組織の方)/`internal-managers-only`(社内・オーナーか管理者が招く)/`undetermined`。
90
+ * 管理できない人には `request-external`・`operator-admin`・`internal-managers-only`・`undetermined` しか来ない(名簿を漏らさない・T2b が畳む)。
91
+ * 🔴 管理できる人の語(add・invite-mail・invite-external)は、旗 manageMembers が真のときだけボタンにする(二重の守り)。
92
+ * 判定できないときは社外の扱いにしない
93
+ */
94
+ function invitePlanOf(preview, rights) {
95
+ const p = preview && typeof preview === "object" ? preview : {};
96
+ const manage = !!(rights && rights.manageMembers === true);
97
+ const request = !!(rights && rights.requestInvite === true);
98
+ const v = p.verdict;
99
+ // 送信元の無い環境(管理できる人にだけ mailer が来る)は、押す前に次の一手を添える
100
+ const noMail = p.mailer === false ? "。お知らせのメールは送れないので、招いた後にこのページの URL をお伝えください" : "";
101
+ const none = (line) => ({ action: null, line, button: null });
102
+ if (v === "already-member")
103
+ return none("この方はすでにメンバーです");
104
+ if (v === "operator-admin")
105
+ return none("この方は基盤の管理者が追加します");
106
+ if (v === "internal-managers-only")
107
+ return none("社内の方の招待は、オーナーか管理者が行います");
108
+ if (v === "add")
109
+ return manage ? { action: "add", line: "この方をメンバーに加えます" + noMail, button: "メンバーに加える" } : none("社内の方の招待は、オーナーか管理者が行います");
110
+ if (v === "invite-mail")
111
+ return manage ? { action: "invite-mail", line: "社内の方です。招待のメールを送ります" + noMail, button: "招待のメールを送る" } : none("社内の方の招待は、オーナーか管理者が行います");
112
+ if (v === "invite-external")
113
+ return manage ? { action: "invite-external", line: "社外の方として招待します" + noMail, button: "社外の方として招待する" } : none("社外の方の招待は、メンバーが申請できます");
114
+ if (v === "request-external") {
115
+ return request ? { action: "request-external", line: "社外の方として招待を申請します(オーナーの承認待ち)", button: "招待を申請する" } : none("社外の方の招待は、メンバーが申請できます");
116
+ }
117
+ return none("社内か社外かを判定できません。時間をおいてもう一度お試しください");
118
+ }
119
+ /**
120
+ * 招いた結果の 1 行(member-invite の答え `{ ok, result, mailer? }`・T2b の口)。
121
+ * 🔴 知らせを送れない(送信元の無い環境・`mailer === false`)ことを黙って飲み込まない——次の一手は URL を直接伝えること
122
+ */
123
+ function inviteResultLineOf(ans) {
124
+ const a = ans && typeof ans === "object" ? ans : {};
125
+ const tail = a.mailer === false ? "。お知らせを送れていません。このページの URL をお伝えください" : "";
126
+ if (a.result === "added")
127
+ return "メンバーに加えました" + tail;
128
+ if (a.result === "invited")
129
+ return "招待しました" + tail;
130
+ if (a.result === "invited-external")
131
+ return "社外の方として招待しました" + tail;
132
+ if (a.result === "requested")
133
+ return "招待を申請しました。オーナーの承認を待っています";
134
+ if (a.result === "already-member")
135
+ return "この方はすでにメンバーです";
136
+ return "送りました";
137
+ }
138
+ /** 外した結果(member-remove の答え `{ ok, result }`)。`not-member` は「すでに外れていた」 */
139
+ function removeResultLineOf(ans, who) {
140
+ const a = ans && typeof ans === "object" ? ans : {};
141
+ if (a.result === "not-member")
142
+ return who + "はすでにメンバーではありません";
143
+ return who + "を外しました";
144
+ }
145
+ /**
146
+ * 断り(`{ ok: false, code }`・T2b の口)の 1 行。決まった 3 つの綴りは固定の 1 行、ほかは呼び手の汎用の文(項目 10)。
147
+ * 🔴 届いた `message` は読まない(T2b の口は返さない。手前の層の英語・内部向けの文を画面に出さない)
148
+ */
149
+ function memberErrorLineOf(j, fallback) {
150
+ const o = j && typeof j === "object" ? j : {};
151
+ if (o.code === "INVALID_EMAIL")
152
+ return "メールアドレスの形を確かめてください";
153
+ if (o.code === "TERM_NOT_ALLOWED")
154
+ return "選べない言葉が含まれています。選び肢から選んでください";
155
+ if (o.code === "LAST_OWNER")
156
+ return "最後のオーナーは外せません";
157
+ return fallback;
158
+ }
159
+ /**
160
+ * member-list の答え(`{ ok, members: [{ name|null, internal, role, pending, email?, userId? }], truncated }`・T2b の口)を画面の行にする。
161
+ * 招待中は `pending: true` の行(別の並びは無い)。名前が null の行は「名前未設定」で出す(行は落とさない)。
162
+ * 🔴 メールアドレスは オーナー・管理者にだけ出す(オーナーの答え Q4)。サーバが返しても、旗が真でなければ読まない(二重の守り)。
163
+ * 🔴 外せるのは 管理できる人・userId がある・オーナーでない 行だけ
164
+ */
165
+ function memberRowsOf(ans, rights) {
166
+ const a = ans && typeof ans === "object" ? ans : {};
167
+ const manage = !!(rights && rights.manageMembers === true);
168
+ const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : null);
169
+ const rows = [];
170
+ const members = Array.isArray(a.members) ? a.members : [];
171
+ for (const m of members) {
172
+ if (!m || typeof m !== "object")
173
+ continue;
174
+ const r = m;
175
+ if (typeof r.internal !== "boolean")
176
+ continue;
177
+ const email = manage ? str(r.email) : null;
178
+ const userId = manage ? str(r.userId) : null;
179
+ const owner = r.role === "owner";
180
+ // 🔴 名前の欄にメールが入って届いても、管理できない人には出さない(二重の守りを名前にも掛ける)
181
+ const name = str(r.name);
182
+ rows.push({
183
+ userId,
184
+ name: (name && (manage || name.indexOf("@") < 0) ? name : null) || "名前未設定",
185
+ side: r.internal ? "internal" : "external",
186
+ owner,
187
+ email,
188
+ removable: manage && !owner && !!userId,
189
+ status: r.pending === true ? "invited" : "member",
190
+ });
191
+ }
192
+ return rows;
193
+ }
194
+ /** 案件名・顧客名の検め(ポータルの ProjectClassificationForm と同じ線: 必須〈案件名〉・100 字・「{{」なし)。通れば null、だめなら 1 行 */
195
+ function projectNameProblemOf(label, value, required) {
196
+ const v = typeof value === "string" ? value.trim() : "";
197
+ if (required && v === "")
198
+ return label + "を入力してください";
199
+ if (v.length > 100)
200
+ return label + "は100文字以内で入力してください";
201
+ if (v.indexOf("{{") >= 0)
202
+ return label + "に「{{」は使えません";
203
+ // 改行・タブなどの制御文字(Home.md の 1 行に書かれる・ポータルと同じ)
204
+ if (/[\u0000-\u001f\u007f]/.test(v))
205
+ return label + "に使えない文字が含まれています";
206
+ return null;
207
+ }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MEMORY_EVIDENCE_KINDS = exports.MEMORY_EVIDENCE_VERSION = exports.MEMORY_EVIDENCE_FILE = void 0;
6
+ exports.EVIDENCE_ROLES = exports.MEMORY_EVIDENCE_KINDS = exports.MEMORY_EVIDENCE_VERSION = exports.MEMORY_EVIDENCE_FILE = void 0;
7
7
  exports.memoryEvidenceItemOf = memoryEvidenceItemOf;
8
8
  exports.parseMemoryEvidence = parseMemoryEvidence;
9
9
  exports.readMemoryEvidence = readMemoryEvidence;
@@ -43,6 +43,8 @@ exports.MEMORY_EVIDENCE_FILE = "memory-evidence.json";
43
43
  exports.MEMORY_EVIDENCE_VERSION = 1;
44
44
  /** 項目の種類(決定の場面・言い直し・ルール・用語と関係者の作った晩/書き換えた晩) */
45
45
  exports.MEMORY_EVIDENCE_KINDS = ["decided", "restated", "ruled", "created", "rewrote"];
46
+ /** 役目の語(engine `common.screen-evidence-by-region` の表の左) */
47
+ exports.EVIDENCE_ROLES = ["origin", "agree", "relay", "external", "told", "use", "meaning", "duty", "center"];
46
48
  const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
47
49
  // engine の台帳の検め(`^https?://`)と揃える。空白を含む URL も項目ごと捨てない
48
50
  const HTTP_RE = /^https?:\/\/\S/i;
@@ -65,8 +67,31 @@ function quoteOf(v) {
65
67
  q.time = v.time.trim();
66
68
  if (v.context === true)
67
69
  q.context = true;
70
+ // 便 EV: 欄ごとに検め、崩れた欄だけ捨てる(引用は残す)
71
+ if (typeof v.role === "string" && exports.EVIDENCE_ROLES.includes(v.role))
72
+ q.role = v.role;
73
+ if (typeof v.url === "string" && HTTP_RE.test(v.url))
74
+ q.url = v.url;
75
+ if (typeof v.cond === "string" && v.cond.trim() !== "")
76
+ q.cond = v.cond.trim();
68
77
  return q;
69
78
  }
79
+ /** 印 1 つ。崩れていれば null(その印だけ捨てる)。`did` が空でない文字列でなければ崩れ */
80
+ function signOf(v) {
81
+ if (!isObj(v) || !isText(v.did))
82
+ return null;
83
+ // 補助の欄(型違いはその欄だけ null に落とす)。`did` と人数が無い印だけ、印ごと捨てる
84
+ const str = (x) => (typeof x === "string" && x.trim() !== "" ? x.trim() : null);
85
+ const onUrl = str(v.on_url);
86
+ const s = { on_url: onUrl && HTTP_RE.test(onUrl) ? onUrl : null, by: str(v.by), by_name: str(v.by_name), did: v.did, at: str(v.at) };
87
+ // 人数は `by` が null の時だけ・1 以上の整数。無い・崩れていれば人数の印として出せないので捨てる
88
+ if (!s.by) {
89
+ if (typeof v.count !== "number" || !Number.isInteger(v.count) || v.count < 1)
90
+ return null;
91
+ s.count = v.count;
92
+ }
93
+ return s;
94
+ }
70
95
  /** 項目 1 つ。崩れていれば null(捨てる) */
71
96
  function memoryEvidenceItemOf(v) {
72
97
  if (!isObj(v))
@@ -87,6 +112,11 @@ function memoryEvidenceItemOf(v) {
87
112
  return null;
88
113
  const quotes = Array.isArray(v.quotes) ? v.quotes.map(quoteOf).filter((q) => q !== null) : [];
89
114
  const item = { key: v.key, at: typeof v.at === "string" ? v.at : "", kind: v.kind, url, text_ref: url ? null : textRef, quotes };
115
+ if (Array.isArray(v.signs)) {
116
+ const signs = v.signs.map(signOf).filter((x) => x !== null);
117
+ if (signs.length)
118
+ item.signs = signs;
119
+ }
90
120
  if (typeof v.night === "string" && DAY_RE.test(v.night))
91
121
  item.night = v.night;
92
122
  if (typeof v.cand === "string" && v.cand)