@things-factory/ai-dashboard 10.1.220 → 10.1.222
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/client/components/card-dialogs.ts +1 -1
- package/client/utils/card-api.ts +1 -2
- package/dist-client/components/card-dialogs.js +1 -1
- package/dist-client/components/card-dialogs.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/card-api.d.ts +0 -1
- package/dist-client/utils/card-api.js +1 -1
- package/dist-client/utils/card-api.js.map +1 -1
- package/dist-server/service/card/card-access.d.ts +4 -33
- package/dist-server/service/card/card-access.js +6 -35
- package/dist-server/service/card/card-access.js.map +1 -1
- package/dist-server/service/card/card-resolver.js +11 -34
- package/dist-server/service/card/card-resolver.js.map +1 -1
- package/dist-server/service/card/card-run.d.ts +2 -0
- package/dist-server/service/card/card-run.js +7 -4
- package/dist-server/service/card/card-run.js.map +1 -1
- package/dist-server/service/card/card-tool.js +8 -12
- package/dist-server/service/card/card-tool.js.map +1 -1
- package/dist-server/service/card/card-types.d.ts +0 -1
- package/dist-server/service/card/card-types.js +0 -4
- package/dist-server/service/card/card-types.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/server/service/card/card-access.test.ts +5 -25
- package/server/service/card/card-access.ts +7 -43
- package/server/service/card/card-resolver.ts +15 -36
- package/server/service/card/card-run.ts +10 -5
- package/server/service/card/card-tool.ts +8 -11
- package/server/service/card/card-types.ts +0 -3
- package/server/service/card/card-words.test.ts +72 -0
- package/test/translations.test.ts +1 -1
- package/translations/en.json +2 -2
- package/translations/es.json +2 -2
- package/translations/ja.json +2 -2
- package/translations/ko.json +2 -2
- package/translations/ms.json +2 -2
- package/translations/zh.json +2 -2
|
@@ -53,7 +53,9 @@ async function readSource(source, where, deps) {
|
|
|
53
53
|
if (refused.length)
|
|
54
54
|
return { issue: { code: 'condition-unreadable', params: { refused } } };
|
|
55
55
|
try {
|
|
56
|
-
const read = await (0, ai_assistant_1.readRows)(source.target, (0, ai_assistant_1.filtersOf)(source.target, criteria), deps.run, typeof criteria.text === 'string' && source.target.search ? criteria.text : undefined
|
|
56
|
+
const read = await (0, ai_assistant_1.readRows)(source.target, (0, ai_assistant_1.filtersOf)(source.target, criteria), deps.run, typeof criteria.text === 'string' && source.target.search ? criteria.text : undefined, {
|
|
57
|
+
timeZone: deps.timeZone
|
|
58
|
+
});
|
|
57
59
|
return { rows: read.rows, total: read.total, complete: read.complete };
|
|
58
60
|
}
|
|
59
61
|
catch (error) {
|
|
@@ -72,7 +74,7 @@ async function readSource(source, where, deps) {
|
|
|
72
74
|
/* An empty list is no rows; a path that holds no list is the declaration's mistake, said as such. */
|
|
73
75
|
if (!Array.isArray(items))
|
|
74
76
|
return { issue: { code: 'list-missing', params: { read: source.key, list: source.list.key, at } } };
|
|
75
|
-
const rows = items.slice(0, ai_assistant_1.MAX_READ_ROWS).map(item => (0, ai_assistant_1.rowOf)({ columns: source.columns }, item));
|
|
77
|
+
const rows = items.slice(0, ai_assistant_1.MAX_READ_ROWS).map(item => (0, ai_assistant_1.rowOf)({ columns: source.columns }, item, { timeZone: deps.timeZone }));
|
|
76
78
|
return { rows, total: items.length, complete: items.length <= ai_assistant_1.MAX_READ_ROWS };
|
|
77
79
|
}
|
|
78
80
|
/** The currencies a currency column's rows hold - `unknown` for a row without one. */
|
|
@@ -220,7 +222,8 @@ async function runCard(definition, deps) {
|
|
|
220
222
|
block: {
|
|
221
223
|
kind: 'table',
|
|
222
224
|
columns: drawn.map(column => ({ name: column.name, label: label(column), type: column.type })),
|
|
223
|
-
|
|
225
|
+
/* A coded value is shown by its word in the viewer's language; the rows were matched and sorted by the code. */
|
|
226
|
+
rows: rows.map(row => Object.fromEntries(drawn.map(column => [column.name, (0, ai_assistant_1.wordOf)(column, row[column.name] ?? null, words)])))
|
|
224
227
|
},
|
|
225
228
|
counts,
|
|
226
229
|
asOf,
|
|
@@ -236,7 +239,7 @@ async function runCard(definition, deps) {
|
|
|
236
239
|
block: {
|
|
237
240
|
kind: 'chart',
|
|
238
241
|
chart: view.kind,
|
|
239
|
-
x: rows.map(row => String(row[x] ?? '').slice(0, 60)),
|
|
242
|
+
x: rows.map(row => String((0, ai_assistant_1.wordOf)(shaped.columns.find(one => one.name === x), row[x] ?? '', words) ?? '').slice(0, 60)),
|
|
240
243
|
series: series.map(column => ({ name: label(column), values: rows.map(row => (typeof row[column.name] === 'number' ? row[column.name] : null)) })),
|
|
241
244
|
...(unitOf(series) && unitOf(series) !== 'unknown' ? { unit: unitOf(series) } : {})
|
|
242
245
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-run.js","sourceRoot":"","sources":["../../../server/service/card/card-run.ts"],"names":[],"mappings":";;;AAoMA,0BAiGC;AArSD;;;;;;;;;GASG;AACH,+DAAwJ;AAExJ,6DAc6B;AA8QpB,kGAnRP,sCAAiB,OAmRO;AA7N1B,MAAM,OAAO,GAAG,CAAC,CAAU,EAAE,CAAU,EAAU,EAAE;IACjD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAChE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/E,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,CAAA;IAC5C,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED,SAAS,OAAO,CAAC,GAAQ,EAAE,MAAkB,EAAE,EAAU,EAAE,KAAc,EAAE,KAAa;IACtF,MAAM,IAAI,GAAG,GAAG,CAAC,MAA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EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,+BAAU,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IAC9J,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACrD,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAC9J,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpF;QACD,MAAM;QACN,IAAI;QACJ,MAAM,EAAE,KAAK;KACd,CAAA;AACH,CAAC","sourcesContent":["/*\n * Drawing a card - its definition run as the one looking at it (ADR-0160 decisions 2, 4, 5, 6).\n *\n * The read's door is asked first, with the viewer's request; then the application's query runs with that request,\n * so the rows are those its API gives this person. The rows are filtered, grouped, ordered and cut - in that order -\n * and become one AI 작업판 block, already within what the 작업판 draws: a card that would need a ninth series or a\n * thirteenth figure is refused, never folded, so two currencies are never added on the way. Nothing is kept.\n *\n * Dependencies come in as arguments - tested without a server.\n */\nimport { filtersOf, MAX_READ_ROWS, readCriteria, readRows, rootFieldOf, rowOf, runDetail, valueAt, type ReadColumn } from '@things-factory/ai-assistant'\n\nimport {\n checkDefinition,\n MAX_CHART_POINTS,\n MAX_FIGURES,\n MAX_SERIES,\n MAX_TABLE_ROWS,\n resolveRelativeDate,\n isRelativeDate,\n resolveWhere,\n shapedColumnNames,\n sourceOf,\n type CardDefinition,\n type CardIssue,\n type CardSource\n} from './card-definition.js'\n\ntype Row = Record<string, string | number | null>\ntype Runner = (document: string, variables: Record<string, unknown>) => Promise<{ data?: any; errors?: readonly { message: string }[] }>\n\nexport interface CardRunDeps {\n readTargetOf(key: string): any\n detailReadOf(key: string): any\n /** Whether the viewer passes a door (`Query.receivables`) - their request's answer. */\n passesDoor(door: string): Promise<boolean>\n /** The application's API with the viewer's request state. */\n run: Runner\n /** Today in the domain's time zone - `YYYY-MM-DD`. */\n today: string\n /** The reader's words for a label key. */\n words?(key: string | undefined, fallback: string): string\n}\n\n/** How much of the source the card was drawn from - said on the card (decision 4). */\nexport interface CardCounts {\n /** Rows read from the source. */\n read: number\n /** Rows the source holds. */\n total: number\n /** Every row of the source was read. */\n complete: boolean\n /** Rows (or groups) after filtering and grouping, before the cut. */\n shaped: number\n /** Rows (or points) drawn. */\n shown: number\n}\n\nexport interface CardRunResult {\n /** One AI 작업판 block - metrics, table or chart. */\n block?: Record<string, unknown>\n issue?: CardIssue\n counts?: CardCounts\n /** The day relative conditions were read for. */\n asOf: string\n source?: { key: string; labelKey?: string }\n}\n\n/** A column of the shaped rows, with the currency its sums are kept in. */\ninterface Shaped extends ReadColumn {\n /** Set on a column split by currency: `remaining:USD` holds remaining in USD only. */\n of?: string\n code?: string\n}\n\nconst compare = (a: unknown, b: unknown): number => {\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (a === null || a === undefined) return b === null || b === undefined ? 0 : 1\n if (b === null || b === undefined) return -1\n return String(a).localeCompare(String(b))\n}\n\nfunction matches(row: Row, column: ReadColumn, op: string, given: unknown, today: string): boolean {\n const cell = row[column.name]\n if (op === 'in' || op === 'not_in') {\n const listed = (given as unknown[]).some(one => (column.type === 'number' ? Number(cell) === Number(one) : String(cell ?? '') === String(one)))\n return op === 'in' ? listed : !listed\n }\n const value = column.type === 'date' && isRelativeDate(given) ? resolveRelativeDate(given as string, today) : given\n if (op === 'eq') return column.type === 'number' ? Number(cell) === Number(value) : String(cell ?? '') === String(value)\n if (op === 'ne') return column.type === 'number' ? Number(cell) !== Number(value) : String(cell ?? '') !== String(value)\n if (cell === null || cell === undefined) return false\n /*\n * A date column holds a month, a day or a time - compared as text over the shorter of the two, so a time of\n * 2026-10-01 is within `gte 2026-10-01`, and a pay month 2026-05 is within `gte 2026-05-01` (2026-10-25: compared over\n * the day's length, the first month of 「최근 6개월」 always fell out).\n */\n const shorter = column.type === 'date' ? Math.min(String(cell).length, String(value).length) : String(value).length\n const order = column.type === 'number' ? Number(cell) - Number(value) : String(cell).slice(0, shorter).localeCompare(String(value).slice(0, shorter))\n return op === 'gt' ? order > 0 : op === 'gte' ? order >= 0 : op === 'lt' ? order < 0 : order <= 0\n}\n\n/** The rows of the source, read as the viewer - or why there are none. */\nasync function readSource(source: CardSource, where: Record<string, unknown>, deps: CardRunDeps): Promise<{ rows?: Row[]; total?: number; complete?: boolean; issue?: CardIssue }> {\n if (source.kind === 'list') {\n const { criteria, refused } = readCriteria(source.target!, where)\n if (refused.length) return { issue: { code: 'condition-unreadable', params: { refused } } }\n try {\n const read = await readRows(source.target!, filtersOf(source.target!, criteria), deps.run, typeof criteria.text === 'string' && source.target!.search ? criteria.text : undefined)\n return { rows: read.rows as Row[], total: read.total, complete: read.complete }\n } catch (error: any) {\n return { issue: { code: 'query-failed', params: { message: String(error?.message ?? error) } } }\n }\n }\n const ran = await runDetail(source.detail!, where, deps.run)\n if (ran.error === 'argument-unreadable') return { issue: { code: 'condition-unreadable', params: { refused: ran.refused } } }\n if (ran.error === 'query-failed') return { issue: { code: 'query-failed', params: { message: ran.message } } }\n if (ran.error === 'not-found') return { issue: { code: 'not-found' } }\n const at = source.list!.at\n const items = at ? valueAt(ran.value, at) : ran.value\n /* An empty list is no rows; a path that holds no list is the declaration's mistake, said as such. */\n if (!Array.isArray(items)) return { issue: { code: 'list-missing', params: { read: source.key, list: source.list!.key, at } } }\n const rows = items.slice(0, MAX_READ_ROWS).map(item => rowOf({ columns: source.columns }, item) as Row)\n return { rows, total: items.length, complete: items.length <= MAX_READ_ROWS }\n}\n\n/** The currencies a currency column's rows hold - `unknown` for a row without one. */\nfunction currenciesIn(rows: Row[], column: ReadColumn): string[] {\n const codes = new Set<string>()\n for (const row of rows) codes.add(typeof row[column.currency!] === 'string' && row[column.currency!] ? String(row[column.currency!]) : 'unknown')\n return [...codes].sort()\n}\n\nconst round = (n: number) => Math.round(n * 100) / 100\n\n/**\n * Grouped rows - the group column, a count and each number column summed. A number with a currency is summed per\n * currency; its column is split into one per currency when the rows hold more than one.\n */\nfunction group(rows: Row[], by: ReadColumn, numbers: ReadColumn[]): { rows: Row[]; columns: Shaped[] } {\n const splits = new Map(numbers.filter(one => one.currency).map(one => [one.name, currenciesIn(rows, one)]))\n const columns: Shaped[] = [\n { ...by, type: by.type === 'date' ? 'string' : by.type },\n { name: 'count', type: 'number' },\n ...numbers.flatMap(one => {\n const codes = splits.get(one.name)\n return codes && codes.length > 1 ? codes.map(code => ({ ...one, name: `${one.name}:${code}`, of: one.name, code })) : [{ ...one, ...(codes ? { code: codes[0] } : {}) }]\n })\n ]\n const groups = new Map<string, Row[]>()\n for (const row of rows) {\n const raw = row[by.name]\n const key = raw === null || raw === undefined ? '' : by.type === 'date' ? String(raw).slice(0, 7) : String(raw)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n const out = [...groups].map(([key, members]) => {\n const row: Row = { [by.name]: key, count: members.length }\n for (const column of columns.slice(2)) {\n const name = column.of ?? column.name\n const kept = column.of ? members.filter(one => (one[column.currency!] || 'unknown') === column.code) : members\n row[column.name] = round(kept.reduce((sum, one) => sum + (typeof one[name] === 'number' ? (one[name] as number) : 0), 0))\n }\n return row\n })\n return { rows: out, columns }\n}\n\n/** Ungrouped rows with a number column split by currency when the rows hold more than one - each row in its own. */\nfunction splitUngrouped(rows: Row[], columns: ReadColumn[]): { rows: Row[]; columns: Shaped[] } {\n const shaped: Shaped[] = []\n const splits: { column: ReadColumn; codes: string[] }[] = []\n for (const column of columns) {\n const codes = column.currency ? currenciesIn(rows, column) : []\n if (codes.length > 1) {\n splits.push({ column, codes })\n shaped.push(...codes.map(code => ({ ...column, name: `${column.name}:${code}`, of: column.name, code })))\n } else shaped.push({ ...column, ...(codes.length ? { code: codes[0] } : {}) })\n }\n if (!splits.length) return { rows, columns: shaped }\n return {\n rows: rows.map(row => {\n const out: Row = { ...row }\n for (const { column, codes } of splits) {\n const mine = (row[column.currency!] as string) || 'unknown'\n for (const code of codes) out[`${column.name}:${code}`] = code === mine ? row[column.name] : null\n }\n return out\n }),\n columns: shaped\n }\n}\n\n/** The shaped columns a definition's name stands for - one, or one per currency when it was split. */\nconst expand = (columns: Shaped[], name: string) => columns.filter(one => one.name === name || one.of === name)\n\n/** Runs a card's definition as the viewer and draws it as one block. */\nexport async function runCard(definition: CardDefinition, deps: CardRunDeps): Promise<CardRunResult> {\n const asOf = deps.today\n const words = deps.words ?? ((_key: string | undefined, fallback: string) => fallback)\n const { source, issue } = sourceOf(definition?.source, deps.readTargetOf, deps.detailReadOf)\n if (!source) return { issue, asOf }\n const about = { key: source.key, ...(source.labelKey ? { labelKey: source.labelKey } : {}) }\n const issues = checkDefinition(definition, source)\n if (issues.length) return { issue: issues[0], asOf, source: about }\n\n /* ① The viewer may read this source at all - a shared card gives the definition, never the data (decision 6). */\n if (!(await deps.passesDoor(rootFieldOf(source.query, 'query')))) return { issue: { code: 'door-closed' }, asOf, source: about }\n\n const read = await readSource(source, resolveWhere(definition.source.where, asOf, source.conditions), deps)\n if (read.issue) return { issue: read.issue, asOf, source: about }\n const rowsDef = definition.rows ?? {}\n const view = definition.view\n const columns = new Map(source.columns.map(one => [one.name, one]))\n\n /* ② Filter → group → order → cut (decision 4). */\n let rows = read.rows!.filter(row => (rowsDef.match ?? []).every(one => matches(row, columns.get(one.column)!, one.op, one.value, asOf)))\n let shaped: { rows: Row[]; columns: Shaped[] }\n if (rowsDef.groupBy) {\n const by = columns.get(rowsDef.groupBy)!\n const numbers = source.columns.filter(one => one.type === 'number' && one.name !== by.name)\n shaped = group(rows, by, numbers)\n } else shaped = splitUngrouped(rows, source.columns)\n /* A group of rows with no value in the grouped column is said as such, never drawn as a bar without a name. */\n if (rowsDef.groupBy) {\n const blank = words('ai-dashboard.card.blank', '(none)')\n shaped.rows = shaped.rows.map(row => (row[rowsDef.groupBy!] === '' ? { ...row, [rowsDef.groupBy!]: blank } : row))\n }\n rows = shaped.rows\n const shapedCount = rows.length\n\n if (rowsDef.sortBy) {\n const order = expand(shaped.columns, rowsDef.sortBy)\n /* Two currencies have no common order - ranking them would compare yen with won. */\n if (order.length > 1) return { issue: { code: 'mixed-currency-order', params: { column: rowsDef.sortBy, currencies: order.map(one => one.code) } }, asOf, source: about }\n const by = order[0].name\n rows = [...rows].sort((a, b) => (rowsDef.desc ? -compare(a[by], b[by]) : compare(a[by], b[by])))\n }\n const cap = view.kind === 'table' ? MAX_TABLE_ROWS : view.kind === 'number' ? Infinity : MAX_CHART_POINTS\n const limit = Math.min(rowsDef.limit ?? cap, cap)\n if (view.kind !== 'number') rows = rows.slice(0, limit)\n\n const counts: CardCounts = { read: read.rows!.length, total: read.total!, complete: !!read.complete, shaped: shapedCount, shown: view.kind === 'number' ? shapedCount : rows.length }\n const label = (column: Shaped) => {\n const base = column.name === 'count' ? words('ai-dashboard.card.count', 'count') : words(column.labelKey, column.of ?? column.name)\n return column.code && column.of ? `${base} (${column.code})` : base\n }\n /* A unit beside the numbers: a single currency says itself, else the card's own. */\n const unitOf = (drawn: Shaped[]) => {\n const codes = [...new Set(drawn.map(one => one.code).filter(Boolean))]\n return codes.length === 1 && !drawn.some(one => one.of) ? codes[0] : view.unit\n }\n\n if (view.kind === 'number') {\n const names = view.values?.length ? view.values : []\n const drawn = names.flatMap(name => expand(shaped.columns, name))\n const items = drawn.length\n ? drawn.map(column => ({ label: label(column), value: round(rows.reduce((sum, row) => sum + (typeof row[column.name] === 'number' ? (row[column.name] as number) : 0), 0)), ...(column.code && column.code !== 'unknown' ? { unit: column.code } : view.unit ? { unit: view.unit } : {}) }))\n : [{ label: words('ai-dashboard.card.count', 'count'), value: rowsDef.groupBy ? shapedCount : rows.length, ...(view.unit ? { unit: view.unit } : {}) }]\n if (items.length > MAX_FIGURES) return { issue: { code: 'too-many-figures', params: { figures: items.length, max: MAX_FIGURES } }, asOf, source: about, counts }\n return { block: { kind: 'metrics', items }, counts, asOf, source: about }\n }\n\n if (view.kind === 'table') {\n const names = [...(view.columns ?? []), ...(view.values ?? []).filter(one => !(view.columns ?? []).includes(one))]\n const drawn = names.length ? names.flatMap(name => expand(shaped.columns, name)) : shaped.columns\n return {\n block: {\n kind: 'table',\n columns: drawn.map(column => ({ name: column.name, label: label(column), type: column.type })),\n rows: rows.map(row => Object.fromEntries(drawn.map(column => [column.name, row[column.name] ?? null])))\n },\n counts,\n asOf,\n source: about\n }\n }\n\n const x = (view.label ?? rowsDef.groupBy)!\n const values = view.values?.length ? view.values : ['count']\n const series = values.flatMap(name => expand(shaped.columns, name))\n if (series.length > MAX_SERIES) return { issue: { code: 'too-many-series', params: { series: series.length, max: MAX_SERIES } }, asOf, source: about, counts }\n return {\n block: {\n kind: 'chart',\n chart: view.kind,\n x: rows.map(row => String(row[x] ?? '').slice(0, 60)),\n series: series.map(column => ({ name: label(column), values: rows.map(row => (typeof row[column.name] === 'number' ? (row[column.name] as number) : null)) })),\n ...(unitOf(series) && unitOf(series) !== 'unknown' ? { unit: unitOf(series) } : {})\n },\n counts,\n asOf,\n source: about\n }\n}\n\n/** The columns a definition may name after its `rows` - for a refusal that says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;YAChB,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAA,qBAAM,EAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtH,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAC9J,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpF;QACD,MAAM;QACN,IAAI;QACJ,MAAM,EAAE,KAAK;KACd,CAAA;AACH,CAAC","sourcesContent":["/*\n * Drawing a card - its definition run as the one looking at it (ADR-0160 decisions 2, 4, 5, 6).\n *\n * The read's door is asked first, with the viewer's request; then the application's query runs with that request,\n * so the rows are those its API gives this person. The rows are filtered, grouped, ordered and cut - in that order -\n * and become one AI 작업판 block, already within what the 작업판 draws: a card that would need a ninth series or a\n * thirteenth figure is refused, never folded, so two currencies are never added on the way. Nothing is kept.\n *\n * Dependencies come in as arguments - tested without a server.\n */\nimport { filtersOf, MAX_READ_ROWS, readCriteria, readRows, rootFieldOf, rowOf, runDetail, valueAt, wordOf, type ReadColumn } from '@things-factory/ai-assistant'\n\nimport {\n checkDefinition,\n MAX_CHART_POINTS,\n MAX_FIGURES,\n MAX_SERIES,\n MAX_TABLE_ROWS,\n resolveRelativeDate,\n isRelativeDate,\n resolveWhere,\n shapedColumnNames,\n sourceOf,\n type CardDefinition,\n type CardIssue,\n type CardSource\n} from './card-definition.js'\n\ntype Row = Record<string, string | number | null>\ntype Runner = (document: string, variables: Record<string, unknown>) => Promise<{ data?: any; errors?: readonly { message: string }[] }>\n\nexport interface CardRunDeps {\n readTargetOf(key: string): any\n detailReadOf(key: string): any\n /** Whether the viewer passes a door (`Query.receivables`) - their request's answer. */\n passesDoor(door: string): Promise<boolean>\n /** The application's API with the viewer's request state. */\n run: Runner\n /** Today in the domain's time zone - `YYYY-MM-DD`. */\n today: string\n /** The domain's time zone - a moment in the rows is read in it. */\n timeZone?: string\n /** The reader's words for a label key. */\n words?(key: string | undefined, fallback: string): string\n}\n\n/** How much of the source the card was drawn from - said on the card (decision 4). */\nexport interface CardCounts {\n /** Rows read from the source. */\n read: number\n /** Rows the source holds. */\n total: number\n /** Every row of the source was read. */\n complete: boolean\n /** Rows (or groups) after filtering and grouping, before the cut. */\n shaped: number\n /** Rows (or points) drawn. */\n shown: number\n}\n\nexport interface CardRunResult {\n /** One AI 작업판 block - metrics, table or chart. */\n block?: Record<string, unknown>\n issue?: CardIssue\n counts?: CardCounts\n /** The day relative conditions were read for. */\n asOf: string\n source?: { key: string; labelKey?: string }\n}\n\n/** A column of the shaped rows, with the currency its sums are kept in. */\ninterface Shaped extends ReadColumn {\n /** Set on a column split by currency: `remaining:USD` holds remaining in USD only. */\n of?: string\n code?: string\n}\n\nconst compare = (a: unknown, b: unknown): number => {\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (a === null || a === undefined) return b === null || b === undefined ? 0 : 1\n if (b === null || b === undefined) return -1\n return String(a).localeCompare(String(b))\n}\n\nfunction matches(row: Row, column: ReadColumn, op: string, given: unknown, today: string): boolean {\n const cell = row[column.name]\n if (op === 'in' || op === 'not_in') {\n const listed = (given as unknown[]).some(one => (column.type === 'number' ? Number(cell) === Number(one) : String(cell ?? '') === String(one)))\n return op === 'in' ? listed : !listed\n }\n const value = column.type === 'date' && isRelativeDate(given) ? resolveRelativeDate(given as string, today) : given\n if (op === 'eq') return column.type === 'number' ? Number(cell) === Number(value) : String(cell ?? '') === String(value)\n if (op === 'ne') return column.type === 'number' ? Number(cell) !== Number(value) : String(cell ?? '') !== String(value)\n if (cell === null || cell === undefined) return false\n /*\n * A date column holds a month, a day or a time - compared as text over the shorter of the two, so a time of\n * 2026-10-01 is within `gte 2026-10-01`, and a pay month 2026-05 is within `gte 2026-05-01` (2026-10-25: compared over\n * the day's length, the first month of 「최근 6개월」 always fell out).\n */\n const shorter = column.type === 'date' ? Math.min(String(cell).length, String(value).length) : String(value).length\n const order = column.type === 'number' ? Number(cell) - Number(value) : String(cell).slice(0, shorter).localeCompare(String(value).slice(0, shorter))\n return op === 'gt' ? order > 0 : op === 'gte' ? order >= 0 : op === 'lt' ? order < 0 : order <= 0\n}\n\n/** The rows of the source, read as the viewer - or why there are none. */\nasync function readSource(source: CardSource, where: Record<string, unknown>, deps: CardRunDeps): Promise<{ rows?: Row[]; total?: number; complete?: boolean; issue?: CardIssue }> {\n if (source.kind === 'list') {\n const { criteria, refused } = readCriteria(source.target!, where)\n if (refused.length) return { issue: { code: 'condition-unreadable', params: { refused } } }\n try {\n const read = await readRows(source.target!, filtersOf(source.target!, criteria), deps.run, typeof criteria.text === 'string' && source.target!.search ? criteria.text : undefined, {\n timeZone: deps.timeZone\n })\n return { rows: read.rows as Row[], total: read.total, complete: read.complete }\n } catch (error: any) {\n return { issue: { code: 'query-failed', params: { message: String(error?.message ?? error) } } }\n }\n }\n const ran = await runDetail(source.detail!, where, deps.run)\n if (ran.error === 'argument-unreadable') return { issue: { code: 'condition-unreadable', params: { refused: ran.refused } } }\n if (ran.error === 'query-failed') return { issue: { code: 'query-failed', params: { message: ran.message } } }\n if (ran.error === 'not-found') return { issue: { code: 'not-found' } }\n const at = source.list!.at\n const items = at ? valueAt(ran.value, at) : ran.value\n /* An empty list is no rows; a path that holds no list is the declaration's mistake, said as such. */\n if (!Array.isArray(items)) return { issue: { code: 'list-missing', params: { read: source.key, list: source.list!.key, at } } }\n const rows = items.slice(0, MAX_READ_ROWS).map(item => rowOf({ columns: source.columns }, item, { timeZone: deps.timeZone }) as Row)\n return { rows, total: items.length, complete: items.length <= MAX_READ_ROWS }\n}\n\n/** The currencies a currency column's rows hold - `unknown` for a row without one. */\nfunction currenciesIn(rows: Row[], column: ReadColumn): string[] {\n const codes = new Set<string>()\n for (const row of rows) codes.add(typeof row[column.currency!] === 'string' && row[column.currency!] ? String(row[column.currency!]) : 'unknown')\n return [...codes].sort()\n}\n\nconst round = (n: number) => Math.round(n * 100) / 100\n\n/**\n * Grouped rows - the group column, a count and each number column summed. A number with a currency is summed per\n * currency; its column is split into one per currency when the rows hold more than one.\n */\nfunction group(rows: Row[], by: ReadColumn, numbers: ReadColumn[]): { rows: Row[]; columns: Shaped[] } {\n const splits = new Map(numbers.filter(one => one.currency).map(one => [one.name, currenciesIn(rows, one)]))\n const columns: Shaped[] = [\n { ...by, type: by.type === 'date' ? 'string' : by.type },\n { name: 'count', type: 'number' },\n ...numbers.flatMap(one => {\n const codes = splits.get(one.name)\n return codes && codes.length > 1 ? codes.map(code => ({ ...one, name: `${one.name}:${code}`, of: one.name, code })) : [{ ...one, ...(codes ? { code: codes[0] } : {}) }]\n })\n ]\n const groups = new Map<string, Row[]>()\n for (const row of rows) {\n const raw = row[by.name]\n const key = raw === null || raw === undefined ? '' : by.type === 'date' ? String(raw).slice(0, 7) : String(raw)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n const out = [...groups].map(([key, members]) => {\n const row: Row = { [by.name]: key, count: members.length }\n for (const column of columns.slice(2)) {\n const name = column.of ?? column.name\n const kept = column.of ? members.filter(one => (one[column.currency!] || 'unknown') === column.code) : members\n row[column.name] = round(kept.reduce((sum, one) => sum + (typeof one[name] === 'number' ? (one[name] as number) : 0), 0))\n }\n return row\n })\n return { rows: out, columns }\n}\n\n/** Ungrouped rows with a number column split by currency when the rows hold more than one - each row in its own. */\nfunction splitUngrouped(rows: Row[], columns: ReadColumn[]): { rows: Row[]; columns: Shaped[] } {\n const shaped: Shaped[] = []\n const splits: { column: ReadColumn; codes: string[] }[] = []\n for (const column of columns) {\n const codes = column.currency ? currenciesIn(rows, column) : []\n if (codes.length > 1) {\n splits.push({ column, codes })\n shaped.push(...codes.map(code => ({ ...column, name: `${column.name}:${code}`, of: column.name, code })))\n } else shaped.push({ ...column, ...(codes.length ? { code: codes[0] } : {}) })\n }\n if (!splits.length) return { rows, columns: shaped }\n return {\n rows: rows.map(row => {\n const out: Row = { ...row }\n for (const { column, codes } of splits) {\n const mine = (row[column.currency!] as string) || 'unknown'\n for (const code of codes) out[`${column.name}:${code}`] = code === mine ? row[column.name] : null\n }\n return out\n }),\n columns: shaped\n }\n}\n\n/** The shaped columns a definition's name stands for - one, or one per currency when it was split. */\nconst expand = (columns: Shaped[], name: string) => columns.filter(one => one.name === name || one.of === name)\n\n/** Runs a card's definition as the viewer and draws it as one block. */\nexport async function runCard(definition: CardDefinition, deps: CardRunDeps): Promise<CardRunResult> {\n const asOf = deps.today\n const words = deps.words ?? ((_key: string | undefined, fallback: string) => fallback)\n const { source, issue } = sourceOf(definition?.source, deps.readTargetOf, deps.detailReadOf)\n if (!source) return { issue, asOf }\n const about = { key: source.key, ...(source.labelKey ? { labelKey: source.labelKey } : {}) }\n const issues = checkDefinition(definition, source)\n if (issues.length) return { issue: issues[0], asOf, source: about }\n\n /* ① The viewer may read this source at all - a shared card gives the definition, never the data (decision 6). */\n if (!(await deps.passesDoor(rootFieldOf(source.query, 'query')))) return { issue: { code: 'door-closed' }, asOf, source: about }\n\n const read = await readSource(source, resolveWhere(definition.source.where, asOf, source.conditions), deps)\n if (read.issue) return { issue: read.issue, asOf, source: about }\n const rowsDef = definition.rows ?? {}\n const view = definition.view\n const columns = new Map(source.columns.map(one => [one.name, one]))\n\n /* ② Filter → group → order → cut (decision 4). */\n let rows = read.rows!.filter(row => (rowsDef.match ?? []).every(one => matches(row, columns.get(one.column)!, one.op, one.value, asOf)))\n let shaped: { rows: Row[]; columns: Shaped[] }\n if (rowsDef.groupBy) {\n const by = columns.get(rowsDef.groupBy)!\n const numbers = source.columns.filter(one => one.type === 'number' && one.name !== by.name)\n shaped = group(rows, by, numbers)\n } else shaped = splitUngrouped(rows, source.columns)\n /* A group of rows with no value in the grouped column is said as such, never drawn as a bar without a name. */\n if (rowsDef.groupBy) {\n const blank = words('ai-dashboard.card.blank', '(none)')\n shaped.rows = shaped.rows.map(row => (row[rowsDef.groupBy!] === '' ? { ...row, [rowsDef.groupBy!]: blank } : row))\n }\n rows = shaped.rows\n const shapedCount = rows.length\n\n if (rowsDef.sortBy) {\n const order = expand(shaped.columns, rowsDef.sortBy)\n /* Two currencies have no common order - ranking them would compare yen with won. */\n if (order.length > 1) return { issue: { code: 'mixed-currency-order', params: { column: rowsDef.sortBy, currencies: order.map(one => one.code) } }, asOf, source: about }\n const by = order[0].name\n rows = [...rows].sort((a, b) => (rowsDef.desc ? -compare(a[by], b[by]) : compare(a[by], b[by])))\n }\n const cap = view.kind === 'table' ? MAX_TABLE_ROWS : view.kind === 'number' ? Infinity : MAX_CHART_POINTS\n const limit = Math.min(rowsDef.limit ?? cap, cap)\n if (view.kind !== 'number') rows = rows.slice(0, limit)\n\n const counts: CardCounts = { read: read.rows!.length, total: read.total!, complete: !!read.complete, shaped: shapedCount, shown: view.kind === 'number' ? shapedCount : rows.length }\n const label = (column: Shaped) => {\n const base = column.name === 'count' ? words('ai-dashboard.card.count', 'count') : words(column.labelKey, column.of ?? column.name)\n return column.code && column.of ? `${base} (${column.code})` : base\n }\n /* A unit beside the numbers: a single currency says itself, else the card's own. */\n const unitOf = (drawn: Shaped[]) => {\n const codes = [...new Set(drawn.map(one => one.code).filter(Boolean))]\n return codes.length === 1 && !drawn.some(one => one.of) ? codes[0] : view.unit\n }\n\n if (view.kind === 'number') {\n const names = view.values?.length ? view.values : []\n const drawn = names.flatMap(name => expand(shaped.columns, name))\n const items = drawn.length\n ? drawn.map(column => ({ label: label(column), value: round(rows.reduce((sum, row) => sum + (typeof row[column.name] === 'number' ? (row[column.name] as number) : 0), 0)), ...(column.code && column.code !== 'unknown' ? { unit: column.code } : view.unit ? { unit: view.unit } : {}) }))\n : [{ label: words('ai-dashboard.card.count', 'count'), value: rowsDef.groupBy ? shapedCount : rows.length, ...(view.unit ? { unit: view.unit } : {}) }]\n if (items.length > MAX_FIGURES) return { issue: { code: 'too-many-figures', params: { figures: items.length, max: MAX_FIGURES } }, asOf, source: about, counts }\n return { block: { kind: 'metrics', items }, counts, asOf, source: about }\n }\n\n if (view.kind === 'table') {\n const names = [...(view.columns ?? []), ...(view.values ?? []).filter(one => !(view.columns ?? []).includes(one))]\n const drawn = names.length ? names.flatMap(name => expand(shaped.columns, name)) : shaped.columns\n return {\n block: {\n kind: 'table',\n columns: drawn.map(column => ({ name: column.name, label: label(column), type: column.type })),\n /* A coded value is shown by its word in the viewer's language; the rows were matched and sorted by the code. */\n rows: rows.map(row => Object.fromEntries(drawn.map(column => [column.name, wordOf(column, row[column.name] ?? null, words)])))\n },\n counts,\n asOf,\n source: about\n }\n }\n\n const x = (view.label ?? rowsDef.groupBy)!\n const values = view.values?.length ? view.values : ['count']\n const series = values.flatMap(name => expand(shaped.columns, name))\n if (series.length > MAX_SERIES) return { issue: { code: 'too-many-series', params: { series: series.length, max: MAX_SERIES } }, asOf, source: about, counts }\n return {\n block: {\n kind: 'chart',\n chart: view.kind,\n x: rows.map(row => String(wordOf(shaped.columns.find(one => one.name === x), row[x] ?? '', words) ?? '').slice(0, 60)),\n series: series.map(column => ({ name: label(column), values: rows.map(row => (typeof row[column.name] === 'number' ? (row[column.name] as number) : null)) })),\n ...(unitOf(series) && unitOf(series) !== 'unknown' ? { unit: unitOf(series) } : {})\n },\n counts,\n asOf,\n source: about\n }\n}\n\n/** The columns a definition may name after its `rows` - for a refusal that says what there is. */\nexport { shapedColumnNames }\n"]}
|
|
@@ -178,7 +178,8 @@ async function proposeDashboardCard(args, context, deps = {}) {
|
|
|
178
178
|
detailReadOf: ai_assistant_1.detailReadOf,
|
|
179
179
|
passesDoor: deps.passesDoor ?? (door => (0, ai_assistant_1.toolAccessFor)(context)(door)),
|
|
180
180
|
run: deps.run ?? (0, ai_assistant_1.runAsCaller)(context),
|
|
181
|
-
today: deps.today ?? (0, card_definition_js_1.todayIn)(context?.state?.domain?.timezone)
|
|
181
|
+
today: deps.today ?? (0, card_definition_js_1.todayIn)(context?.state?.domain?.timezone),
|
|
182
|
+
timeZone: context?.state?.domain?.timezone
|
|
182
183
|
});
|
|
183
184
|
if (ran.issue) {
|
|
184
185
|
return { rejected: true, error: ran.issue.code, ...(ran.issue.params ? { params: ran.issue.params } : {}), source: sourceSheet(source, definition.rows?.groupBy), message: 'the card could not be drawn - fix the definition and call again in this turn; say plainly if it cannot be.' };
|
|
@@ -329,25 +330,20 @@ async function readDashboardCard(args, context, cardOf) {
|
|
|
329
330
|
}
|
|
330
331
|
/** A card in the person's domain and how they may use it - loaded late so the rules are tested without a database. */
|
|
331
332
|
const usableInDomain = (context) => async (id) => {
|
|
332
|
-
const [{ getRepository }, { DashboardCard, DashboardCardShare }, { cardAccessOf,
|
|
333
|
+
const [{ getRepository }, { DashboardCard, DashboardCardShare }, { cardAccessOf }, { audienceMemberOf }] = await Promise.all([
|
|
333
334
|
Promise.resolve().then(() => __importStar(require('@things-factory/shell'))),
|
|
334
335
|
Promise.resolve().then(() => __importStar(require('./dashboard-card.js'))),
|
|
335
|
-
Promise.resolve().then(() => __importStar(require('./card-access.js')))
|
|
336
|
+
Promise.resolve().then(() => __importStar(require('./card-access.js'))),
|
|
337
|
+
Promise.resolve().then(() => __importStar(require('@things-factory/organization')))
|
|
336
338
|
]);
|
|
337
339
|
const domainId = context?.state?.domain?.id;
|
|
338
340
|
const card = await getRepository(DashboardCard).findOne({ where: { id, domain: { id: domainId } } });
|
|
339
341
|
if (!card)
|
|
340
342
|
return {};
|
|
341
343
|
const shares = await getRepository(DashboardCardShare).find({ where: { card: { id: card.id } } });
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
records = answer.errors?.length ? [] : answer.data?.myEmployees;
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
348
|
-
records = [];
|
|
349
|
-
}
|
|
350
|
-
const access = cardAccessOf(card, { userId: context?.state?.user?.id, domainId, departmentIds: departmentsOfEmployees(records) }, shares);
|
|
344
|
+
/* The same viewer the card doors see - its roles included, which this read left out until 2026-10-26. */
|
|
345
|
+
const { ownDepartments, ...viewer } = await audienceMemberOf(context?.state?.domain, context?.state?.user ?? {});
|
|
346
|
+
const access = cardAccessOf(card, viewer, shares);
|
|
351
347
|
return { card, access };
|
|
352
348
|
};
|
|
353
349
|
const readSpec = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-tool.js","sourceRoot":"","sources":["../../../server/service/card/card-tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,kCAKC;AAMD,8BAGC;AAqBD,oDAoIC;AA8ED,8CAoBC;AAtTD;;;;;;;;GAQG;AACH,mEAAuG;AACvG,+DAUqC;AAErC,6DAAsL;AACtL,+CAA0D;AAE1D,mDAAqF;AAG5E,8FAHW,6BAAa,OAGX;AAAE,0FAHW,yBAAS,OAGX;AAAE,+FAHW,8BAAc,OAGX;AAFjD,yDAA6C;AAI7C,qFAAqF;AACrF,SAAS,WAAW,CAAC,MAAkB,EAAE,OAAgB;IACvD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,GAAG;QAChB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MA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C5M,gSAAgS;QAChS,UAAU,yBAAS,8IAA8I;QACjK,0HAA0H,yBAAS,6JAA6J;KACjS,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;CACxB,CAAA;AAED,IAAA,qCAAoB,EAAC,oBAAY,CAAC,CAAA;AAClC,iHAAiH;AACjH,IAAA,2CAA4B,EAAC;IAC3B,IAAI,EAAE,6BAAa;IACnB,UAAU,EAAE,CAAC,8BAAc,CAAC;IAC5B,SAAS,EAAE,CAAC,yBAAS,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,EACN,0IAA0I;QAC1I,4CAA4C,yBAAS,2FAA2F;QAChJ,qGAAqG;CACxG,CAAC,CAAA","sourcesContent":["/*\n * proposeDashboardCard - the assistant writes a card's definition in a conversation; the person saves it by pressing\n * the card (ADR-0160 decision 9).\n *\n * The server checks the definition against the read it names and runs it once as the person, so a card that cannot\n * be drawn is sent back with what the read has - never offered. The proposal carries the definition only: the\n * preview on the card is run again by whoever looks at the conversation, as themselves (decision 6), and the model\n * is told no values - its answer is read by everyone the conversation lets in, whatever door they pass.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\nimport {\n detailReadKeys,\n detailReadOf,\n detailToolName,\n queryToolName,\n readTargetKeys,\n readTargetOf,\n registerConversationCategory,\n runAsCaller,\n toolAccessFor\n} from '@things-factory/ai-assistant'\n\nimport { CARD_SCHEMA_VERSION, checkCardIntent, checkDefinition, LIST_OPS, MATCH_OPS, sourceOf, todayIn, VIEW_KINDS, type CardDefinition, type CardSource } from './card-definition.js'\nimport { runCard, shapedColumnNames } from './card-run.js'\n\nimport { CARD_AXIS, CARD_CATEGORY, CARD_TOOL, DASHBOARD_PAGE } from './card-names.js'\nimport { cardIdOf } from './card-proposal.js'\n\nexport { CARD_CATEGORY, CARD_TOOL, DASHBOARD_PAGE }\n\n/** What a read offers a card - for a refusal the model fixes the definition from. */\nfunction sourceSheet(source: CardSource, groupBy?: string) {\n return {\n read: source.key,\n ...(source.list ? { list: source.list.key } : {}),\n /* What the rows are - a state as of today or a ledger over time - decides whether a period is a filter at all. */\n description: source.description,\n ...(source.mine ? { mine: 'the rows are the viewer\\'s own, whoever looks - no filter on a person' } : {}),\n conditions: source.conditions.map(one => ({ name: one.name, type: one.type, ...(one.format ? { format: 'YYYY-MM' } : {}), ...(one.many ? { takes: 'one value or a list' } : {}), ...(one.required ? { required: true } : {}), ...(one.values ? { values: one.values } : {}), ...(one.description ? { description: one.description } : {}) })),\n columns: source.columns.map(one => ({ name: one.name, type: one.type, ...(one.currency ? { currency: one.currency } : {}) })),\n ...(groupBy ? { columnsAfterGroupBy: [...shapedColumnNames(source, { groupBy }).keys()] } : {})\n }\n}\n\n/** The reads a card may name - each list read target and each detail read's list, with the tool the model knows it by. */\nexport function cardSources(): { read: string; list?: string; tool: string; mine?: true }[] {\n return [\n ...readTargetKeys().map(key => ({ read: key, tool: queryToolName(key), ...(readTargetOf(key)?.mine ? { mine: true as const } : {}) })),\n ...detailReadKeys().flatMap(key => (detailReadOf(key)?.lists ?? []).map(list => ({ read: key, list: list.key, tool: detailToolName(key), ...(detailReadOf(key)?.mine ? { mine: true as const } : {}) })))\n ]\n}\n\n/**\n * The read a model named - its key, or the name of the tool it reads it with (`queryPlantJobOrder` is `plant.job-order`):\n * the model knows reads by their tools, and named the tool as the card's source (2026-10-25, plant).\n */\nexport function readKeyOf(given: unknown): unknown {\n if (typeof given !== 'string' || readTargetOf(given) || detailReadOf(given)) return given\n return readTargetKeys().find(key => queryToolName(key) === given) ?? detailReadKeys().find(key => detailToolName(key) === given) ?? given\n}\n\n/** A part of a definition without the fields the model left empty - `groupBy: null` is no grouping, not a column named null. */\nfunction withoutEmpty<T extends Record<string, any>>(given: T | undefined): T | undefined {\n if (!given || typeof given !== 'object' || Array.isArray(given)) return given\n const kept = Object.entries(given).filter(([, value]) => value !== null && value !== undefined && value !== '')\n return kept.length ? (Object.fromEntries(kept) as T) : undefined\n}\n\n/** A saved card as a change needs it - whose it is and its version. */\nexport type CardOf = (id: string) => Promise<{ ownerId?: string; version: number } | undefined>\n\n/** The card in the person's domain - loaded late so the rules are tested without a database. */\nconst cardInDomain =\n (context: any): CardOf =>\n async id => {\n const [{ getRepository }, { DashboardCard }] = await Promise.all([import('@things-factory/shell'), import('./dashboard-card.js')])\n const card = await getRepository(DashboardCard).findOne({ where: { id, domain: { id: context?.state?.domain?.id } } as any })\n return card ? { ownerId: card.ownerId, version: card.version } : undefined\n }\n\nexport async function proposeDashboardCard(args: any, context: any, deps: { run?: any; passesDoor?: (door: string) => Promise<boolean>; today?: string; cardOf?: CardOf } = {}) {\n const name = typeof args?.name === 'string' ? args.name.trim().slice(0, 100) : ''\n if (!name) return { rejected: true, error: 'no-name', message: 'give the card a short name in the person\\'s language.' }\n const where = withoutEmpty(args?.source?.where)\n const rows = withoutEmpty(args?.rows)\n /* One value, or the list `in` and `not_in` take - kept as the match's value either way. */\n if (Array.isArray(rows?.match))\n rows.match = rows.match.map((one: any) => {\n if (!one || typeof one !== 'object' || !('values' in one)) return one\n const { values, ...match } = one\n return (LIST_OPS as readonly string[]).includes(match.op) ? { ...match, value: values } : match.value === undefined ? { ...match, value: values } : match\n })\n const definition: CardDefinition = {\n schemaVersion: CARD_SCHEMA_VERSION,\n source: { read: readKeyOf(args?.source?.read) as string, ...(args?.source?.list ? { list: args.source.list } : {}), ...(where ? { where } : {}) },\n ...(rows ? { rows } : {}),\n view: withoutEmpty(args?.view) as any\n }\n const { source, issue } = sourceOf(definition.source, readTargetOf, detailReadOf)\n if (!source) {\n return {\n rejected: true,\n error: issue!.code,\n ...issue!.params,\n ...(issue!.code === 'unknown-read' || issue!.code === 'not-a-card-source' ? { sources: cardSources() } : {}),\n message: 'source.read is one of the sources listed - its read key or its tool (a detail read also names its list). Call again now with one of them.'\n }\n }\n const issues = checkDefinition(definition, source)\n if (issues.length) {\n return {\n rejected: true,\n error: 'definition-unfit',\n issues,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n 'fix every issue against the source below and call again now, in this turn - do not ask the person. source.where takes only the conditions listed (give every required one); ' +\n 'a column is filtered with rows.match; a period with no date condition is a rows.match on a date column, or left out when the source is a state as of today.'\n }\n }\n /* What the card says it shows, and whose rows it shows - checked before it runs, so a wrong card is never drawn once. */\n const description = typeof args?.description === 'string' ? args.description : undefined\n const user = context?.state?.user\n const mine = cardSources().filter(one => one.mine).map(one => (one.list ? `${one.read} (list ${one.list})` : one.read))\n const intent = checkCardIntent({ name, description, definition }, source, { id: user?.id, name: user?.name, email: user?.email }, mine)\n if (intent.length) {\n return {\n rejected: true,\n error: 'card-says-otherwise',\n issues: intent,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n 'the card would not show what it says - fix each issue and call again now, in this turn. ' +\n 'period-without-condition: put the period in source.where with relative values (this-month-start..this-month-end; a YYYY-MM condition this-month; the last 6 months -5m-start..this-month-end) or as a rows.match on a date column - or, when the source is a state as of today, take the period out of the name. ' +\n 'period-held-to-fixed-days: use relative values so the card stays current. period-unlike-condition: make the condition the period the name says. ' +\n 'viewer-filter-on-own-read: drop the filter - the read is the viewer\\'s own whoever looks. viewer-filter-use-own-read: read one of the listed own reads instead, with no filter on the person.'\n }\n }\n\n /* A change is of one's own card, from the version it was read at - a newer version is not overwritten unseen. */\n const given = typeof args?.cardId === 'string' ? args.cardId.trim() : ''\n const cardId = given ? cardIdOf(given) : undefined\n if (given && !cardId) return { rejected: true, error: 'card-id-unreadable', cardId: given, message: `cardId is the card's uuid or its key ${CARD_AXIS}:<uuid>, as readDashboardCard gave it - call again now with it.` }\n let baseVersion: number | undefined\n if (cardId) {\n const saved = await (deps.cardOf ?? cardInDomain(context))(cardId)\n if (!saved) return { rejected: true, error: 'unknown-card', message: 'there is no such card - leave cardId out to offer a new one.' }\n if (saved.ownerId !== context?.state?.user?.id) return { rejected: true, error: 'not-your-card', message: 'only its owner changes a card - offer a new card instead, without cardId.' }\n baseVersion = Number.isInteger(args?.baseVersion) ? args.baseVersion : saved.version\n if (baseVersion !== saved.version) return { rejected: true, error: 'stale-version', current: saved.version, message: `the card is at version ${saved.version} now - start from it and call again.` }\n }\n\n /* Run once as the person - what cannot be drawn is not offered. */\n const ran = await runCard(definition, {\n readTargetOf,\n detailReadOf,\n passesDoor: deps.passesDoor ?? (door => toolAccessFor(context)(door)),\n run: deps.run ?? runAsCaller(context),\n today: deps.today ?? todayIn(context?.state?.domain?.timezone)\n })\n if (ran.issue) {\n return { rejected: true, error: ran.issue.code, ...(ran.issue.params ? { params: ran.issue.params } : {}), source: sourceSheet(source, definition.rows?.groupBy), message: 'the card could not be drawn - fix the definition and call again in this turn; say plainly if it cannot be.' }\n }\n /*\n * A table or chart that draws nothing today is offered only when the person asked for something that may be empty - a\n * request that expects rows was most likely read wrong (2026-10-24: 「이번 달 미수금」 filtered a state of today by the\n * contract date and drew nothing).\n */\n if (ran.counts && ran.counts.shown === 0 && definition.view.kind !== 'number' && args?.allowEmpty !== true) {\n return {\n rejected: true,\n error: 'draws-nothing',\n read: ran.counts.read,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n `no row meets these conditions today (${ran.counts.read} read). Read the source's description: a state as of today takes no period filter. ` +\n 'Fix the conditions and call again now; only if the person asked for something that may well be empty, call again with allowEmpty: true.'\n }\n }\n /*\n * Bars or a line whose names repeat cannot be read - two bars of one customer are two contracts the reader cannot tell\n * apart (2026-10-24: 「미수금 상위 5곳」 drew one customer twice). Asked when the card is offered; a saved card draws as\n * its data stands.\n */\n const x: unknown[] = Array.isArray((ran.block as any)?.x) ? (ran.block as any).x : []\n if (!definition.rows?.groupBy && new Set(x).size < x.length) {\n const label = definition.view.label!\n return {\n rejected: true,\n error: 'label-repeats',\n label,\n use: `rows.groupBy: '${label}' (and sortBy a summed value)`,\n source: sourceSheet(source, label),\n message: `the bars' names (${label}) repeat - one name stands for several rows. Group by it so each name is one bar, and call again now, in this turn.`\n }\n }\n\n return {\n proposed: true,\n kind: 'dashboard-card',\n icon: 'dashboard_customize',\n label: name,\n card: {\n name,\n ...(typeof args?.description === 'string' && args.description.trim() ? { description: args.description.trim().slice(0, 300) } : {}),\n definition,\n ...(cardId ? { cardId, baseVersion } : {})\n },\n message:\n 'the card is offered with its preview; the person saves it to their dashboard by pressing it. Say in one line what it shows. ' +\n 'Do not ask whether to save it, and do not repeat its numbers - the preview shows them to whoever looks.'\n }\n}\n\nconst COLUMN = { type: 'string' }\n\nconst spec = {\n kind: 'read',\n name: CARD_TOOL,\n /* Only someone who may save a card is offered one. The data's doors are asked when it runs, as the person. */\n doors: ['Mutation.saveDashboardCardProposal'],\n description:\n 'Offer a dashboard card - a definition the person saves to 나의 대시보드, drawn afterwards from the data without you. ' +\n 'source.read is a read you have (a list target, or a detail read with source.list naming one of its lists); source.where holds its conditions or arguments - ' +\n 'for a period use relative values so the card stays current - a day: today, -30d, this-month-start, this-month-end, last-month-start, this-year-start, -5m-start (the first day five months ago); ' +\n 'an integer year or month: this-year, last-month; a month as YYYY-MM: this-month, last-month, -5m. The last 6 months is -5m-start..this-month-end. A name that says a period has that condition. ' +\n `rows: match [{column, op: ${MATCH_OPS.join('|')}, value}] - every match holds (two eq of one column never do: use in [..]); not_in [..] for \"not one of\"; groupBy (a date groups by month), sortBy (a column, or count when grouped), desc, limit. ` +\n 'A read marked mine is the viewer\\'s own rows, whoever looks - prefer it for \"my ...\" cards and never filter by a person\\'s name or id. ' +\n `view.kind: ${VIEW_KINDS.join('|')}; label is the column along the bottom of a chart (the groupBy column by default); values are the number columns summed or drawn (none counts rows); columns lists a table's columns. ` +\n 'To change a saved card, pass its cardId and the version you changed as baseVersion.',\n schema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'The card name, short, in the person\\'s language.' },\n description: { type: 'string', description: 'One line of what it shows.' },\n source: {\n type: 'object',\n properties: {\n read: { type: 'string', description: 'The read - its key (office.receivables) or the tool that reads it (readOfficeReceivables).' },\n list: { type: 'string', description: 'A detail read\\'s list key.' },\n where: { type: 'object', description: 'Conditions or arguments by name; dates may be relative.', additionalProperties: true }\n },\n required: ['read']\n },\n rows: {\n type: 'object',\n properties: {\n match: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n column: COLUMN,\n op: { type: 'string', enum: [...MATCH_OPS] },\n value: { type: 'string', description: 'A number, a day, a word or a relative date.' },\n values: { type: 'array', items: { type: 'string' }, description: `The values of ${LIST_OPS.join(' and ')}, in place of value.` }\n },\n required: ['column', 'op']\n }\n },\n groupBy: COLUMN,\n sortBy: COLUMN,\n desc: { type: 'boolean' },\n limit: { type: 'integer' }\n }\n },\n view: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: [...VIEW_KINDS] },\n label: COLUMN,\n values: { type: 'array', items: COLUMN },\n columns: { type: 'array', items: COLUMN },\n unit: { type: 'string' }\n },\n required: ['kind']\n },\n allowEmpty: { type: 'boolean', description: 'true only when the person asked for something that may be empty today (overdue items, alerts).' },\n cardId: { type: 'string', description: 'A saved card being changed.' },\n baseVersion: { type: 'integer', description: 'The version of that card the change starts from.' }\n },\n required: ['name', 'source', 'view']\n },\n builder: (args: any, context: any) => proposeDashboardCard(args, context)\n} as ToolSpec\n\n/**\n * A saved card's name, version and definition - no values - for a change asked from the dashboard (「AI로 고치기」 picks\n * the card; the model reads it here, then offers the changed definition with cardId and baseVersion).\n */\nexport async function readDashboardCard(args: any, context: any, cardOf?: (id: string) => Promise<{ card?: any; access?: string }>) {\n const given = typeof args?.id === 'string' ? args.id.trim() : ''\n if (!given) return { rejected: true, error: 'no-id', message: 'give the card id the person picked.' }\n const id = cardIdOf(given)\n if (!id) return { rejected: true, error: 'card-id-unreadable', id: given, message: `a card is named by its key ${CARD_AXIS}:<uuid> (after [keys] dashboardCards) or its uuid - call again now with it.` }\n const found = await (cardOf ?? usableInDomain(context))(id)\n if (!found?.card) return { rejected: true, error: 'unknown-card', message: 'there is no such card - say so.' }\n if (!found.access) return { rejected: true, error: 'card-not-shared', message: 'this card is not shared with the person - say so.' }\n const { card, access } = found\n return {\n id: card.id,\n name: card.name,\n version: card.version,\n access,\n definition: card.definition,\n message:\n access === 'owner'\n ? `to change it, call ${CARD_TOOL} with the whole changed definition, cardId \"${card.id}\" and baseVersion ${card.version}.`\n : `the person does not own it - offer a new card (no cardId) made from this definition.`\n }\n}\n\n/** A card in the person's domain and how they may use it - loaded late so the rules are tested without a database. */\nconst usableInDomain =\n (context: any) =>\n async (id: string): Promise<{ card?: any; access?: string }> => {\n const [{ getRepository }, { DashboardCard, DashboardCardShare }, { cardAccessOf, departmentsOfEmployees }] = await Promise.all([\n import('@things-factory/shell'),\n import('./dashboard-card.js'),\n import('./card-access.js')\n ])\n const domainId = context?.state?.domain?.id\n const card = await getRepository(DashboardCard).findOne({ where: { id, domain: { id: domainId } } as any })\n if (!card) return {}\n const shares = await getRepository(DashboardCardShare).find({ where: { card: { id: card.id } } as any })\n let records: any[] | undefined\n try {\n const answer = await runAsCaller(context)('query { myEmployees { active department { id } } }', {})\n records = answer.errors?.length ? [] : answer.data?.myEmployees\n } catch {\n records = []\n }\n const access = cardAccessOf(card, { userId: context?.state?.user?.id, domainId, departmentIds: departmentsOfEmployees(records) }, shares)\n return { card, access }\n }\n\nconst readSpec = {\n kind: 'read',\n name: 'readDashboardCard',\n doors: ['Query.dashboardCardRun'],\n description: 'Read a saved dashboard card the person picked - its name, version and definition, never its values - before changing it.',\n schema: { type: 'object', properties: { id: { type: 'string', description: 'The card id the person picked.' } }, required: ['id'] },\n builder: (args: any, context: any) => readDashboardCard(args, context)\n} as ToolSpec\n\nexport const cardCategory: ToolCategory = {\n name: CARD_CATEGORY,\n description: 'dashboard cards - definitions the person saves and the dashboard draws from the data',\n guidance: [\n `- When the person asks for a card, a tile, a chart or a table on their dashboard (대시보드 카드, 카드로 만들어 줘), read the data with its read tool to learn its columns, then call ${CARD_TOOL} in the same turn. Never ask whether to make or save it; the card is the answer.`,\n `- A card is drawn later from the data as whoever opens it - you are not there. Put periods as relative values in source.where, never today's dates; say \"this month\" as this-month-start / this-month-end.`,\n `- \"Top N\" is rows.sortBy the amount, desc: true, limit N. Counting customers, places or months (상위 5곳, 거래처별, 월별) is rows.groupBy that column with view.values - each name one bar. Amounts in two currencies are never added - group or match by the currency, or use a column already in won.`,\n `- When ${CARD_TOOL} refuses, fix the definition from what it returns and call again in the same turn; if the data cannot be drawn this way, say so in one line.`,\n `- When the person picked a dashboard card to change (its id after [keys] dashboardCards), call readDashboardCard, then ${CARD_TOOL} with the whole changed definition, cardId and baseVersion - in the same turn. When the change makes its name untrue (top 5 → top 10), give it a true name.`\n ].join('\\n'),\n specs: [spec, readSpec]\n}\n\nregisterToolCategory(cardCategory)\n/* In reach of every conversation, in front on the dashboard page and for a picked card (ADR-0061 decision 9). */\nregisterConversationCategory({\n name: CARD_CATEGORY,\n frontPages: [DASHBOARD_PAGE],\n frontAxes: [CARD_AXIS],\n /* FINISH_RULE on this page: the card is what was asked for. */\n pageRule:\n `This turn is asked from 나의 대시보드, where what the person asks to see - a figure, a total, a count, a list, a chart - is a dashboard card. ` +\n `Read what it needs and end the turn with ${CARD_TOOL}, in this turn; never answer with the figure in words, and never ask whether to make it. ` +\n `Only a question about the dashboard itself (how to share, how to move a card) is answered in words.`\n})\n"]}
|
|
1
|
+
{"version":3,"file":"card-tool.js","sourceRoot":"","sources":["../../../server/service/card/card-tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,kCAKC;AAMD,8BAGC;AAqBD,oDAqIC;AA8ED,8CAoBC;AAvTD;;;;;;;;GAQG;AACH,mEAAuG;AACvG,+DAUqC;AAErC,6DAAsL;AACtL,+CAA0D;AAE1D,mDAAqF;AAG5E,8FAHW,6BAAa,OAGX;AAAE,0FAHW,yBAAS,OAGX;AAAE,+FAHW,8BAAc,OAGX;AAFjD,yDAA6C;AAI7C,qFAAqF;AACrF,SAAS,WAAW,CAAC,MAAkB,EAAE,OAAgB;IACvD,OAAO;QACL,IAAI,EAAE,MA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AAI,CAAC;IACZ,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;CACxB,CAAA;AAED,IAAA,qCAAoB,EAAC,oBAAY,CAAC,CAAA;AAClC,iHAAiH;AACjH,IAAA,2CAA4B,EAAC;IAC3B,IAAI,EAAE,6BAAa;IACnB,UAAU,EAAE,CAAC,8BAAc,CAAC;IAC5B,SAAS,EAAE,CAAC,yBAAS,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,EACN,0IAA0I;QAC1I,4CAA4C,yBAAS,2FAA2F;QAChJ,qGAAqG;CACxG,CAAC,CAAA","sourcesContent":["/*\n * proposeDashboardCard - the assistant writes a card's definition in a conversation; the person saves it by pressing\n * the card (ADR-0160 decision 9).\n *\n * The server checks the definition against the read it names and runs it once as the person, so a card that cannot\n * be drawn is sent back with what the read has - never offered. The proposal carries the definition only: the\n * preview on the card is run again by whoever looks at the conversation, as themselves (decision 6), and the model\n * is told no values - its answer is read by everyone the conversation lets in, whatever door they pass.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\nimport {\n detailReadKeys,\n detailReadOf,\n detailToolName,\n queryToolName,\n readTargetKeys,\n readTargetOf,\n registerConversationCategory,\n runAsCaller,\n toolAccessFor\n} from '@things-factory/ai-assistant'\n\nimport { CARD_SCHEMA_VERSION, checkCardIntent, checkDefinition, LIST_OPS, MATCH_OPS, sourceOf, todayIn, VIEW_KINDS, type CardDefinition, type CardSource } from './card-definition.js'\nimport { runCard, shapedColumnNames } from './card-run.js'\n\nimport { CARD_AXIS, CARD_CATEGORY, CARD_TOOL, DASHBOARD_PAGE } from './card-names.js'\nimport { cardIdOf } from './card-proposal.js'\n\nexport { CARD_CATEGORY, CARD_TOOL, DASHBOARD_PAGE }\n\n/** What a read offers a card - for a refusal the model fixes the definition from. */\nfunction sourceSheet(source: CardSource, groupBy?: string) {\n return {\n read: source.key,\n ...(source.list ? { list: source.list.key } : {}),\n /* What the rows are - a state as of today or a ledger over time - decides whether a period is a filter at all. */\n description: source.description,\n ...(source.mine ? { mine: 'the rows are the viewer\\'s own, whoever looks - no filter on a person' } : {}),\n conditions: source.conditions.map(one => ({ name: one.name, type: one.type, ...(one.format ? { format: 'YYYY-MM' } : {}), ...(one.many ? { takes: 'one value or a list' } : {}), ...(one.required ? { required: true } : {}), ...(one.values ? { values: one.values } : {}), ...(one.description ? { description: one.description } : {}) })),\n columns: source.columns.map(one => ({ name: one.name, type: one.type, ...(one.currency ? { currency: one.currency } : {}) })),\n ...(groupBy ? { columnsAfterGroupBy: [...shapedColumnNames(source, { groupBy }).keys()] } : {})\n }\n}\n\n/** The reads a card may name - each list read target and each detail read's list, with the tool the model knows it by. */\nexport function cardSources(): { read: string; list?: string; tool: string; mine?: true }[] {\n return [\n ...readTargetKeys().map(key => ({ read: key, tool: queryToolName(key), ...(readTargetOf(key)?.mine ? { mine: true as const } : {}) })),\n ...detailReadKeys().flatMap(key => (detailReadOf(key)?.lists ?? []).map(list => ({ read: key, list: list.key, tool: detailToolName(key), ...(detailReadOf(key)?.mine ? { mine: true as const } : {}) })))\n ]\n}\n\n/**\n * The read a model named - its key, or the name of the tool it reads it with (`queryPlantJobOrder` is `plant.job-order`):\n * the model knows reads by their tools, and named the tool as the card's source (2026-10-25, plant).\n */\nexport function readKeyOf(given: unknown): unknown {\n if (typeof given !== 'string' || readTargetOf(given) || detailReadOf(given)) return given\n return readTargetKeys().find(key => queryToolName(key) === given) ?? detailReadKeys().find(key => detailToolName(key) === given) ?? given\n}\n\n/** A part of a definition without the fields the model left empty - `groupBy: null` is no grouping, not a column named null. */\nfunction withoutEmpty<T extends Record<string, any>>(given: T | undefined): T | undefined {\n if (!given || typeof given !== 'object' || Array.isArray(given)) return given\n const kept = Object.entries(given).filter(([, value]) => value !== null && value !== undefined && value !== '')\n return kept.length ? (Object.fromEntries(kept) as T) : undefined\n}\n\n/** A saved card as a change needs it - whose it is and its version. */\nexport type CardOf = (id: string) => Promise<{ ownerId?: string; version: number } | undefined>\n\n/** The card in the person's domain - loaded late so the rules are tested without a database. */\nconst cardInDomain =\n (context: any): CardOf =>\n async id => {\n const [{ getRepository }, { DashboardCard }] = await Promise.all([import('@things-factory/shell'), import('./dashboard-card.js')])\n const card = await getRepository(DashboardCard).findOne({ where: { id, domain: { id: context?.state?.domain?.id } } as any })\n return card ? { ownerId: card.ownerId, version: card.version } : undefined\n }\n\nexport async function proposeDashboardCard(args: any, context: any, deps: { run?: any; passesDoor?: (door: string) => Promise<boolean>; today?: string; cardOf?: CardOf } = {}) {\n const name = typeof args?.name === 'string' ? args.name.trim().slice(0, 100) : ''\n if (!name) return { rejected: true, error: 'no-name', message: 'give the card a short name in the person\\'s language.' }\n const where = withoutEmpty(args?.source?.where)\n const rows = withoutEmpty(args?.rows)\n /* One value, or the list `in` and `not_in` take - kept as the match's value either way. */\n if (Array.isArray(rows?.match))\n rows.match = rows.match.map((one: any) => {\n if (!one || typeof one !== 'object' || !('values' in one)) return one\n const { values, ...match } = one\n return (LIST_OPS as readonly string[]).includes(match.op) ? { ...match, value: values } : match.value === undefined ? { ...match, value: values } : match\n })\n const definition: CardDefinition = {\n schemaVersion: CARD_SCHEMA_VERSION,\n source: { read: readKeyOf(args?.source?.read) as string, ...(args?.source?.list ? { list: args.source.list } : {}), ...(where ? { where } : {}) },\n ...(rows ? { rows } : {}),\n view: withoutEmpty(args?.view) as any\n }\n const { source, issue } = sourceOf(definition.source, readTargetOf, detailReadOf)\n if (!source) {\n return {\n rejected: true,\n error: issue!.code,\n ...issue!.params,\n ...(issue!.code === 'unknown-read' || issue!.code === 'not-a-card-source' ? { sources: cardSources() } : {}),\n message: 'source.read is one of the sources listed - its read key or its tool (a detail read also names its list). Call again now with one of them.'\n }\n }\n const issues = checkDefinition(definition, source)\n if (issues.length) {\n return {\n rejected: true,\n error: 'definition-unfit',\n issues,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n 'fix every issue against the source below and call again now, in this turn - do not ask the person. source.where takes only the conditions listed (give every required one); ' +\n 'a column is filtered with rows.match; a period with no date condition is a rows.match on a date column, or left out when the source is a state as of today.'\n }\n }\n /* What the card says it shows, and whose rows it shows - checked before it runs, so a wrong card is never drawn once. */\n const description = typeof args?.description === 'string' ? args.description : undefined\n const user = context?.state?.user\n const mine = cardSources().filter(one => one.mine).map(one => (one.list ? `${one.read} (list ${one.list})` : one.read))\n const intent = checkCardIntent({ name, description, definition }, source, { id: user?.id, name: user?.name, email: user?.email }, mine)\n if (intent.length) {\n return {\n rejected: true,\n error: 'card-says-otherwise',\n issues: intent,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n 'the card would not show what it says - fix each issue and call again now, in this turn. ' +\n 'period-without-condition: put the period in source.where with relative values (this-month-start..this-month-end; a YYYY-MM condition this-month; the last 6 months -5m-start..this-month-end) or as a rows.match on a date column - or, when the source is a state as of today, take the period out of the name. ' +\n 'period-held-to-fixed-days: use relative values so the card stays current. period-unlike-condition: make the condition the period the name says. ' +\n 'viewer-filter-on-own-read: drop the filter - the read is the viewer\\'s own whoever looks. viewer-filter-use-own-read: read one of the listed own reads instead, with no filter on the person.'\n }\n }\n\n /* A change is of one's own card, from the version it was read at - a newer version is not overwritten unseen. */\n const given = typeof args?.cardId === 'string' ? args.cardId.trim() : ''\n const cardId = given ? cardIdOf(given) : undefined\n if (given && !cardId) return { rejected: true, error: 'card-id-unreadable', cardId: given, message: `cardId is the card's uuid or its key ${CARD_AXIS}:<uuid>, as readDashboardCard gave it - call again now with it.` }\n let baseVersion: number | undefined\n if (cardId) {\n const saved = await (deps.cardOf ?? cardInDomain(context))(cardId)\n if (!saved) return { rejected: true, error: 'unknown-card', message: 'there is no such card - leave cardId out to offer a new one.' }\n if (saved.ownerId !== context?.state?.user?.id) return { rejected: true, error: 'not-your-card', message: 'only its owner changes a card - offer a new card instead, without cardId.' }\n baseVersion = Number.isInteger(args?.baseVersion) ? args.baseVersion : saved.version\n if (baseVersion !== saved.version) return { rejected: true, error: 'stale-version', current: saved.version, message: `the card is at version ${saved.version} now - start from it and call again.` }\n }\n\n /* Run once as the person - what cannot be drawn is not offered. */\n const ran = await runCard(definition, {\n readTargetOf,\n detailReadOf,\n passesDoor: deps.passesDoor ?? (door => toolAccessFor(context)(door)),\n run: deps.run ?? runAsCaller(context),\n today: deps.today ?? todayIn(context?.state?.domain?.timezone),\n timeZone: context?.state?.domain?.timezone\n })\n if (ran.issue) {\n return { rejected: true, error: ran.issue.code, ...(ran.issue.params ? { params: ran.issue.params } : {}), source: sourceSheet(source, definition.rows?.groupBy), message: 'the card could not be drawn - fix the definition and call again in this turn; say plainly if it cannot be.' }\n }\n /*\n * A table or chart that draws nothing today is offered only when the person asked for something that may be empty - a\n * request that expects rows was most likely read wrong (2026-10-24: 「이번 달 미수금」 filtered a state of today by the\n * contract date and drew nothing).\n */\n if (ran.counts && ran.counts.shown === 0 && definition.view.kind !== 'number' && args?.allowEmpty !== true) {\n return {\n rejected: true,\n error: 'draws-nothing',\n read: ran.counts.read,\n source: sourceSheet(source, definition.rows?.groupBy),\n message:\n `no row meets these conditions today (${ran.counts.read} read). Read the source's description: a state as of today takes no period filter. ` +\n 'Fix the conditions and call again now; only if the person asked for something that may well be empty, call again with allowEmpty: true.'\n }\n }\n /*\n * Bars or a line whose names repeat cannot be read - two bars of one customer are two contracts the reader cannot tell\n * apart (2026-10-24: 「미수금 상위 5곳」 drew one customer twice). Asked when the card is offered; a saved card draws as\n * its data stands.\n */\n const x: unknown[] = Array.isArray((ran.block as any)?.x) ? (ran.block as any).x : []\n if (!definition.rows?.groupBy && new Set(x).size < x.length) {\n const label = definition.view.label!\n return {\n rejected: true,\n error: 'label-repeats',\n label,\n use: `rows.groupBy: '${label}' (and sortBy a summed value)`,\n source: sourceSheet(source, label),\n message: `the bars' names (${label}) repeat - one name stands for several rows. Group by it so each name is one bar, and call again now, in this turn.`\n }\n }\n\n return {\n proposed: true,\n kind: 'dashboard-card',\n icon: 'dashboard_customize',\n label: name,\n card: {\n name,\n ...(typeof args?.description === 'string' && args.description.trim() ? { description: args.description.trim().slice(0, 300) } : {}),\n definition,\n ...(cardId ? { cardId, baseVersion } : {})\n },\n message:\n 'the card is offered with its preview; the person saves it to their dashboard by pressing it. Say in one line what it shows. ' +\n 'Do not ask whether to save it, and do not repeat its numbers - the preview shows them to whoever looks.'\n }\n}\n\nconst COLUMN = { type: 'string' }\n\nconst spec = {\n kind: 'read',\n name: CARD_TOOL,\n /* Only someone who may save a card is offered one. The data's doors are asked when it runs, as the person. */\n doors: ['Mutation.saveDashboardCardProposal'],\n description:\n 'Offer a dashboard card - a definition the person saves to 나의 대시보드, drawn afterwards from the data without you. ' +\n 'source.read is a read you have (a list target, or a detail read with source.list naming one of its lists); source.where holds its conditions or arguments - ' +\n 'for a period use relative values so the card stays current - a day: today, -30d, this-month-start, this-month-end, last-month-start, this-year-start, -5m-start (the first day five months ago); ' +\n 'an integer year or month: this-year, last-month; a month as YYYY-MM: this-month, last-month, -5m. The last 6 months is -5m-start..this-month-end. A name that says a period has that condition. ' +\n `rows: match [{column, op: ${MATCH_OPS.join('|')}, value}] - every match holds (two eq of one column never do: use in [..]); not_in [..] for \"not one of\"; groupBy (a date groups by month), sortBy (a column, or count when grouped), desc, limit. ` +\n 'A read marked mine is the viewer\\'s own rows, whoever looks - prefer it for \"my ...\" cards and never filter by a person\\'s name or id. ' +\n `view.kind: ${VIEW_KINDS.join('|')}; label is the column along the bottom of a chart (the groupBy column by default); values are the number columns summed or drawn (none counts rows); columns lists a table's columns. ` +\n 'To change a saved card, pass its cardId and the version you changed as baseVersion.',\n schema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'The card name, short, in the person\\'s language.' },\n description: { type: 'string', description: 'One line of what it shows.' },\n source: {\n type: 'object',\n properties: {\n read: { type: 'string', description: 'The read - its key (office.receivables) or the tool that reads it (readOfficeReceivables).' },\n list: { type: 'string', description: 'A detail read\\'s list key.' },\n where: { type: 'object', description: 'Conditions or arguments by name; dates may be relative.', additionalProperties: true }\n },\n required: ['read']\n },\n rows: {\n type: 'object',\n properties: {\n match: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n column: COLUMN,\n op: { type: 'string', enum: [...MATCH_OPS] },\n value: { type: 'string', description: 'A number, a day, a word or a relative date.' },\n values: { type: 'array', items: { type: 'string' }, description: `The values of ${LIST_OPS.join(' and ')}, in place of value.` }\n },\n required: ['column', 'op']\n }\n },\n groupBy: COLUMN,\n sortBy: COLUMN,\n desc: { type: 'boolean' },\n limit: { type: 'integer' }\n }\n },\n view: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: [...VIEW_KINDS] },\n label: COLUMN,\n values: { type: 'array', items: COLUMN },\n columns: { type: 'array', items: COLUMN },\n unit: { type: 'string' }\n },\n required: ['kind']\n },\n allowEmpty: { type: 'boolean', description: 'true only when the person asked for something that may be empty today (overdue items, alerts).' },\n cardId: { type: 'string', description: 'A saved card being changed.' },\n baseVersion: { type: 'integer', description: 'The version of that card the change starts from.' }\n },\n required: ['name', 'source', 'view']\n },\n builder: (args: any, context: any) => proposeDashboardCard(args, context)\n} as ToolSpec\n\n/**\n * A saved card's name, version and definition - no values - for a change asked from the dashboard (「AI로 고치기」 picks\n * the card; the model reads it here, then offers the changed definition with cardId and baseVersion).\n */\nexport async function readDashboardCard(args: any, context: any, cardOf?: (id: string) => Promise<{ card?: any; access?: string }>) {\n const given = typeof args?.id === 'string' ? args.id.trim() : ''\n if (!given) return { rejected: true, error: 'no-id', message: 'give the card id the person picked.' }\n const id = cardIdOf(given)\n if (!id) return { rejected: true, error: 'card-id-unreadable', id: given, message: `a card is named by its key ${CARD_AXIS}:<uuid> (after [keys] dashboardCards) or its uuid - call again now with it.` }\n const found = await (cardOf ?? usableInDomain(context))(id)\n if (!found?.card) return { rejected: true, error: 'unknown-card', message: 'there is no such card - say so.' }\n if (!found.access) return { rejected: true, error: 'card-not-shared', message: 'this card is not shared with the person - say so.' }\n const { card, access } = found\n return {\n id: card.id,\n name: card.name,\n version: card.version,\n access,\n definition: card.definition,\n message:\n access === 'owner'\n ? `to change it, call ${CARD_TOOL} with the whole changed definition, cardId \"${card.id}\" and baseVersion ${card.version}.`\n : `the person does not own it - offer a new card (no cardId) made from this definition.`\n }\n}\n\n/** A card in the person's domain and how they may use it - loaded late so the rules are tested without a database. */\nconst usableInDomain =\n (context: any) =>\n async (id: string): Promise<{ card?: any; access?: string }> => {\n const [{ getRepository }, { DashboardCard, DashboardCardShare }, { cardAccessOf }, { audienceMemberOf }] = await Promise.all([\n import('@things-factory/shell'),\n import('./dashboard-card.js'),\n import('./card-access.js'),\n import('@things-factory/organization')\n ])\n const domainId = context?.state?.domain?.id\n const card = await getRepository(DashboardCard).findOne({ where: { id, domain: { id: domainId } } as any })\n if (!card) return {}\n const shares = await getRepository(DashboardCardShare).find({ where: { card: { id: card.id } } as any })\n /* The same viewer the card doors see - its roles included, which this read left out until 2026-10-26. */\n const { ownDepartments, ...viewer } = await audienceMemberOf(context?.state?.domain, context?.state?.user ?? {})\n const access = cardAccessOf(card, viewer, shares)\n return { card, access }\n }\n\nconst readSpec = {\n kind: 'read',\n name: 'readDashboardCard',\n doors: ['Query.dashboardCardRun'],\n description: 'Read a saved dashboard card the person picked - its name, version and definition, never its values - before changing it.',\n schema: { type: 'object', properties: { id: { type: 'string', description: 'The card id the person picked.' } }, required: ['id'] },\n builder: (args: any, context: any) => readDashboardCard(args, context)\n} as ToolSpec\n\nexport const cardCategory: ToolCategory = {\n name: CARD_CATEGORY,\n description: 'dashboard cards - definitions the person saves and the dashboard draws from the data',\n guidance: [\n `- When the person asks for a card, a tile, a chart or a table on their dashboard (대시보드 카드, 카드로 만들어 줘), read the data with its read tool to learn its columns, then call ${CARD_TOOL} in the same turn. Never ask whether to make or save it; the card is the answer.`,\n `- A card is drawn later from the data as whoever opens it - you are not there. Put periods as relative values in source.where, never today's dates; say \"this month\" as this-month-start / this-month-end.`,\n `- \"Top N\" is rows.sortBy the amount, desc: true, limit N. Counting customers, places or months (상위 5곳, 거래처별, 월별) is rows.groupBy that column with view.values - each name one bar. Amounts in two currencies are never added - group or match by the currency, or use a column already in won.`,\n `- When ${CARD_TOOL} refuses, fix the definition from what it returns and call again in the same turn; if the data cannot be drawn this way, say so in one line.`,\n `- When the person picked a dashboard card to change (its id after [keys] dashboardCards), call readDashboardCard, then ${CARD_TOOL} with the whole changed definition, cardId and baseVersion - in the same turn. When the change makes its name untrue (top 5 → top 10), give it a true name.`\n ].join('\\n'),\n specs: [spec, readSpec]\n}\n\nregisterToolCategory(cardCategory)\n/* In reach of every conversation, in front on the dashboard page and for a picked card (ADR-0061 decision 9). */\nregisterConversationCategory({\n name: CARD_CATEGORY,\n frontPages: [DASHBOARD_PAGE],\n frontAxes: [CARD_AXIS],\n /* FINISH_RULE on this page: the card is what was asked for. */\n pageRule:\n `This turn is asked from 나의 대시보드, where what the person asks to see - a figure, a total, a count, a list, a chart - is a dashboard card. ` +\n `Read what it needs and end the turn with ${CARD_TOOL}, in this turn; never answer with the figure in words, and never ask whether to make it. ` +\n `Only a question about the dashboard itself (how to share, how to move a card) is answered in words.`\n})\n"]}
|
|
@@ -39,7 +39,6 @@ export declare class DashboardShareChoice {
|
|
|
39
39
|
export declare class DashboardShareOptions {
|
|
40
40
|
domainId: string;
|
|
41
41
|
domainName: string;
|
|
42
|
-
departmentsAvailable: boolean;
|
|
43
42
|
departments: DashboardShareChoice[];
|
|
44
43
|
peopleAvailable: boolean;
|
|
45
44
|
roles: DashboardShareChoice[];
|
|
@@ -154,10 +154,6 @@ tslib_1.__decorate([
|
|
|
154
154
|
(0, type_graphql_1.Field)({ description: 'The domain name.' }),
|
|
155
155
|
tslib_1.__metadata("design:type", String)
|
|
156
156
|
], DashboardShareOptions.prototype, "domainName", void 0);
|
|
157
|
-
tslib_1.__decorate([
|
|
158
|
-
(0, type_graphql_1.Field)({ description: 'Whether departments are known here (the organization module).' }),
|
|
159
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
160
|
-
], DashboardShareOptions.prototype, "departmentsAvailable", void 0);
|
|
161
157
|
tslib_1.__decorate([
|
|
162
158
|
(0, type_graphql_1.Field)(type => [DashboardShareChoice], { description: "The viewer's own departments." }),
|
|
163
159
|
tslib_1.__metadata("design:type", Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-types.js","sourceRoot":"","sources":["../../../server/service/card/card-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,qDAA6C;AAE7C,2DAA6D;AAGtD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CASlC,CAAA;AATY,wDAAsB;AAEjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,2CAAuB,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;;qDAC3E;AAG9B;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;wDACnD;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;;0DACpD;iCARR,sBAAsB;IADlC,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;GACnE,sBAAsB,CASlC;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAiC7B,CAAA;AAjCY,8CAAiB;AAE5B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;6CACrC;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;;+CAC7B;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;sDAChD;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;;kDAC7C;AAGf;IADC,IAA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CAAC;;sDAC3E;AAG9B;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;yDACnD;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;2DACrD;kCARR,uBAAuB;IADnC,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACtC,uBAAuB,CASnC;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAY/B,CAAA;AAZY,kDAAmB;AAE9B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;;+CACtC;AAGV;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;kDACrC;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;;kDAC3C;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;;mDACvC;8BAXH,mBAAmB;IAD/B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;GAC7C,mBAAmB,CAY/B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { DashboardCardShareScope } from './dashboard-card.js'\n\n@ObjectType({ description: 'Who a card is shared with, as its owner sees it.' })\nexport class DashboardCardShareItem {\n @Field(type => DashboardCardShareScope, { description: 'A person, a department, a role or the domain.' })\n scope: DashboardCardShareScope\n\n @Field({ description: 'The user, department, role or domain id.' })\n targetId: string\n\n @Field({ nullable: true, description: 'Its name when it was shared.' })\n targetName?: string\n}\n\n@ObjectType({ description: 'A dashboard card as the viewer may use it.' })\nexport class DashboardCardItem {\n @Field(type => ID, { description: 'Card id.' })\n id: string\n\n @Field({ description: 'The card name.' })\n name: string\n\n @Field({ nullable: true, description: 'What it shows, in a line.' })\n description?: string\n\n @Field(type => Int, { description: 'The current version.' })\n version: number\n\n @Field(type => GraphQLJSON, { description: 'The current definition.' })\n definition: unknown\n\n @Field({ description: \"'owner' when the viewer made it, 'shared' when it was shared with them.\" })\n access: string\n\n @Field({ nullable: true, description: 'Who made it.' })\n ownerName?: string\n\n @Field({ nullable: true, description: 'The card it was copied from.' })\n copiedFromId?: string\n\n @Field({ description: 'Whether the viewer has placed it on their dashboard.' })\n placed: boolean\n\n @Field(type => [DashboardCardShareItem], { nullable: true, description: 'Who it is shared with - its owner only.' })\n shares?: DashboardCardShareItem[]\n\n @Field({ nullable: true, description: 'When it was changed last.' })\n updatedAt?: Date\n}\n\n@ObjectType({ description: 'One card placed on the viewer\\'s dashboard.' })\nexport class DashboardPlaceItem {\n @Field(type => ID, { description: 'Place id.' })\n id: string\n\n @Field(type => Int, { description: 'Its order in the grid.' })\n order: number\n\n @Field(type => Int, { description: 'Columns it spans, 1 to 4.' })\n width: number\n\n @Field(type => Int, { description: 'Rows it spans, 1 to 2.' })\n height: number\n\n @Field(type => DashboardCardItem, { description: 'The card.' })\n card: DashboardCardItem\n}\n\n@ObjectType({ description: 'A version of a card, as its owner sees it.' })\nexport class DashboardCardVersionItem {\n @Field(type => Int, { description: 'The version number.' })\n version: number\n\n @Field({ description: 'The name in this version.' })\n name: string\n\n @Field(type => GraphQLJSON, { description: 'The definition in this version.' })\n definition: unknown\n\n @Field({ nullable: true, description: 'Who saved it.' })\n creatorName?: string\n\n @Field({ nullable: true, description: 'When it was saved.' })\n createdAt?: Date\n}\n\n@ObjectType({ description: 'A department or person a card may be shared with.' })\nexport class DashboardShareChoice {\n @Field({ description: 'The department id, or the user id of a person.' })\n id: string\n\n @Field({ description: 'The name.' })\n name: string\n\n @Field({ nullable: true, description: 'Where the person works.' })\n note?: string\n}\n\n@ObjectType({ description: 'What a card may be shared with by the viewer.' })\nexport class DashboardShareOptions {\n @Field({ description: 'The domain - the whole-domain share names it.' })\n domainId: string\n\n @Field({ description: 'The domain name.' })\n domainName: string\n\n @Field(type => [DashboardShareChoice], { description: \"The viewer's own departments.\" })\n departments: DashboardShareChoice[]\n\n @Field({ description: 'Whether the viewer may look people up to share with them.' })\n peopleAvailable: boolean\n\n @Field(type => [DashboardShareChoice], { description: \"The domain's roles, the ones it inherits included - a card shared with one reaches whoever holds it.\" })\n roles: DashboardShareChoice[]\n}\n\n@InputType({ description: 'One share of a card.' })\nexport class DashboardCardShareInput {\n @Field(type => DashboardCardShareScope, { description: 'A person, a department, a role or the domain.' })\n scope: DashboardCardShareScope\n\n @Field({ description: 'The user, department, role or domain id.' })\n targetId: string\n\n @Field({ nullable: true, description: 'Its name, shown to the owner.' })\n targetName?: string\n}\n\n@InputType({ description: 'Where one placed card goes.' })\nexport class DashboardPlaceInput {\n @Field(type => ID, { description: 'Place id.' })\n id: string\n\n @Field(type => Int, { description: 'Its order.' })\n order: number\n\n @Field(type => Int, { description: 'Columns, 1 to 4.' })\n width: number\n\n @Field(type => Int, { description: 'Rows, 1 to 2.' })\n height: number\n}\n"]}
|