@things-factory/ai-dashboard 10.1.232 → 10.1.234

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.
@@ -8,3 +8,5 @@ export declare const DASHBOARD_PAGE = "my-dashboard";
8
8
  * picked row of any list (ai-assistant `selectedRecords`). The client's `CARD_AXIS` (card-words.ts) is the same word.
9
9
  */
10
10
  export declare const CARD_AXIS = "dashboard-card";
11
+ /** A card name's bound - the screen's `maxlength`, refused with the bound on the server, never cut. */
12
+ export declare const CARD_NAME_MAX = 100;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CARD_AXIS = exports.DASHBOARD_PAGE = exports.CARD_TOOL = exports.CARD_CATEGORY = void 0;
3
+ exports.CARD_NAME_MAX = exports.CARD_AXIS = exports.DASHBOARD_PAGE = exports.CARD_TOOL = exports.CARD_CATEGORY = void 0;
4
4
  /** The names other files of this package and its client share - kept apart so the pure rules load nothing else. */
5
5
  exports.CARD_CATEGORY = 'dashboard-card';
6
6
  exports.CARD_TOOL = 'proposeDashboardCard';
@@ -11,4 +11,6 @@ exports.DASHBOARD_PAGE = 'my-dashboard';
11
11
  * picked row of any list (ai-assistant `selectedRecords`). The client's `CARD_AXIS` (card-words.ts) is the same word.
12
12
  */
13
13
  exports.CARD_AXIS = 'dashboard-card';
14
+ /** A card name's bound - the screen's `maxlength`, refused with the bound on the server, never cut. */
15
+ exports.CARD_NAME_MAX = 100;
14
16
  //# sourceMappingURL=card-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"card-names.js","sourceRoot":"","sources":["../../../server/service/card/card-names.ts"],"names":[],"mappings":";;;AAAA,mHAAmH;AACtG,QAAA,aAAa,GAAG,gBAAgB,CAAA;AAChC,QAAA,SAAS,GAAG,sBAAsB,CAAA;AAC/C,sFAAsF;AACzE,QAAA,cAAc,GAAG,cAAc,CAAA;AAC5C;;;GAGG;AACU,QAAA,SAAS,GAAG,gBAAgB,CAAA","sourcesContent":["/** The names other files of this package and its client share - kept apart so the pure rules load nothing else. */\nexport const CARD_CATEGORY = 'dashboard-card'\nexport const CARD_TOOL = 'proposeDashboardCard'\n/** The route of the dashboard page - its conversations put the card tool in front. */\nexport const DASHBOARD_PAGE = 'my-dashboard'\n/**\n * The axis of a saved card - its key `dashboard-card:<uuid>` is how a picked card is handed to the conversation, like a\n * picked row of any list (ai-assistant `selectedRecords`). The client's `CARD_AXIS` (card-words.ts) is the same word.\n */\nexport const CARD_AXIS = 'dashboard-card'\n"]}
1
+ {"version":3,"file":"card-names.js","sourceRoot":"","sources":["../../../server/service/card/card-names.ts"],"names":[],"mappings":";;;AAAA,mHAAmH;AACtG,QAAA,aAAa,GAAG,gBAAgB,CAAA;AAChC,QAAA,SAAS,GAAG,sBAAsB,CAAA;AAC/C,sFAAsF;AACzE,QAAA,cAAc,GAAG,cAAc,CAAA;AAC5C;;;GAGG;AACU,QAAA,SAAS,GAAG,gBAAgB,CAAA;AACzC,uGAAuG;AAC1F,QAAA,aAAa,GAAG,GAAG,CAAA","sourcesContent":["/** The names other files of this package and its client share - kept apart so the pure rules load nothing else. */\nexport const CARD_CATEGORY = 'dashboard-card'\nexport const CARD_TOOL = 'proposeDashboardCard'\n/** The route of the dashboard page - its conversations put the card tool in front. */\nexport const DASHBOARD_PAGE = 'my-dashboard'\n/**\n * The axis of a saved card - its key `dashboard-card:<uuid>` is how a picked card is handed to the conversation, like a\n * picked row of any list (ai-assistant `selectedRecords`). The client's `CARD_AXIS` (card-words.ts) is the same word.\n */\nexport const CARD_AXIS = 'dashboard-card'\n/** A card name's bound - the screen's `maxlength`, refused with the bound on the server, never cut. */\nexport const CARD_NAME_MAX = 100\n"]}
@@ -21,6 +21,7 @@ const ai_assistant_1 = require("@things-factory/ai-assistant");
21
21
  const card_access_js_1 = require("./card-access.js");
22
22
  const card_definition_js_1 = require("./card-definition.js");
23
23
  Object.defineProperty(exports, "CARD_SCHEMA_VERSION", { enumerable: true, get: function () { return card_definition_js_1.CARD_SCHEMA_VERSION; } });
24
+ const card_names_js_1 = require("./card-names.js");
24
25
  const card_proposal_js_1 = require("./card-proposal.js");
25
26
  const card_run_js_1 = require("./card-run.js");
26
27
  const dashboard_card_js_1 = require("./dashboard-card.js");
@@ -29,11 +30,19 @@ const QUERY = '@privilege(category: "ai-dashboard", privilege: "query", domainOw
29
30
  const MUTATION = '@privilege(category: "ai-dashboard", privilege: "mutation", domainOwnerGranted: true)';
30
31
  const MAX_WIDTH = 4;
31
32
  const MAX_HEIGHT = 2;
33
+ /** The name as typed, or refused with the bound - a longer name was cut without a word (inline help audit 2026-10-30). */
34
+ function cardNameOf(name, context) {
35
+ const given = String(name ?? '').trim();
36
+ if (given.length > card_names_js_1.CARD_NAME_MAX)
37
+ refuse(context, 'name-too-long', 'a card name takes up to {max} characters; this one has {length}.', { max: card_names_js_1.CARD_NAME_MAX, length: given.length });
38
+ return given;
39
+ }
32
40
  /** A refusal said in the reader's words, with a code the screen may read. */
33
41
  function refuse(context, code, fallback, options = {}) {
34
42
  const message = context.t ? String(context.t(`ai-dashboard.refusal.${code}`, { defaultValue: fallback, ...options })) : fallback;
35
43
  const error = new Error(message);
36
- error.extensions = { code: `ai-dashboard.${code}` };
44
+ /* The issue code is for the people who keep the application - the sentence a person reads does not carry it. */
45
+ error.extensions = { code: `ai-dashboard.${code}`, ...(options.issue ? { issue: options.issue } : {}) };
37
46
  throw error;
38
47
  }
39
48
  /**
@@ -129,10 +138,10 @@ async function runAsViewer(definition, context) {
129
138
  function keepable(definition, context) {
130
139
  const { source, issue } = (0, card_definition_js_1.sourceOf)(definition?.source, ai_assistant_1.readTargetOf, ai_assistant_1.detailReadOf);
131
140
  if (!source)
132
- refuse(context, 'definition-unfit', 'the card reads nothing this application declares ({code}).', { code: issue?.code });
141
+ refuse(context, 'definition-unfit', 'the card reads nothing this application declares.', { issue: issue?.code });
133
142
  const issues = (0, card_definition_js_1.checkDefinition)(definition, source);
134
143
  if (issues.length)
135
- refuse(context, 'definition-unfit', 'the card definition does not fit its source ({code}).', { code: issues[0].code });
144
+ refuse(context, 'definition-unfit', 'the card definition does not fit its source.', { issue: issues[0].code });
136
145
  return definition;
137
146
  }
138
147
  async function placeAtEnd(cardId, context, tx) {
@@ -245,7 +254,7 @@ let DashboardCardResolver = class DashboardCardResolver {
245
254
  const { source } = (0, card_definition_js_1.sourceOf)(definition.source, ai_assistant_1.readTargetOf, ai_assistant_1.detailReadOf);
246
255
  if (!(await (0, ai_assistant_1.toolAccessFor)(context)((0, ai_assistant_1.rootFieldOf)(source.query, 'query'))))
247
256
  refuse(context, 'data-closed', 'you may not read the data this card draws.');
248
- const name = String(proposal.card.name ?? '').trim().slice(0, 100) || 'card';
257
+ const name = cardNameOf(proposal.card.name, context) || String(context.t ? context.t('ai-dashboard.text.untitled-card') : 'Untitled card');
249
258
  const description = proposal.card.description ? String(proposal.card.description).slice(0, 300) : null;
250
259
  let card;
251
260
  let version;
@@ -267,7 +276,7 @@ let DashboardCardResolver = class DashboardCardResolver {
267
276
  async renameDashboardCard(id, name, context) {
268
277
  const { domain, user, tx } = context.state;
269
278
  const card = await ownCard(id, context, tx);
270
- const given = (name ?? '').trim().slice(0, 100);
279
+ const given = cardNameOf(name, context);
271
280
  if (!given)
272
281
  refuse(context, 'no-name', 'a card needs a name.');
273
282
  const version = card.version + 1;
@@ -1 +1 @@
1
- {"version":3,"file":"card-resolver.js","sourceRoot":"","sources":["../../../server/service/card/card-resolver.ts"],"names":[],"mappings":";;;AA0HA,kCAcC;;AAxID;;;;;;;GAOG;AACH,+CAAkF;AAClF,qDAA6C;AAC7C,qCAAyC;AAEzC,iDAAqD;AACrD,yDAAgD;AAChD,+DAAuH;AACvH,+DAWqC;AAErC,qDAAiF;AACjF,6DAAmH;AAiZ1G,oGAjZA,wCAAmB,OAiZA;AAhZ5B,yDAA+D;AAC/D,+CAA2D;AAC3D,2DAA0I;AAC1I,mDAA4L;AAE5L,MAAM,KAAK,GAAG,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AG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA;AACrF,CAAC","sourcesContent":["/*\n * The doors of the dashboard cards (ADR-0160 decisions 6-10) - one's own cards and those shared with one, one's own\n * dashboard, a card's versions and shares (its owner's), running a card, and saving a proposal a conversation made.\n *\n * Every door asks who may use the card again (card-access.ts) - a share withdrawn closes at once. Running a card asks\n * the data's own door as the viewer and reads with the viewer's request (card-run.ts): the card gives the definition,\n * never the data.\n */\nimport { Arg, Ctx, Directive, Int, Mutation, Query, Resolver } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport { In, IsNull, Not } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { audienceMemberOf, audienceTargetRefusal, departmentTreeOf, domainRolesOf } from '@things-factory/organization'\nimport {\n assertMayWriteSession,\n ChatMessage,\n ChatSession,\n detailReadOf,\n isSessionParticipant,\n mayReadSession,\n readTargetOf,\n rootFieldOf,\n runAsCaller,\n toolAccessFor\n} from '@things-factory/ai-assistant'\n\nimport { cardAccessOf, type CardAccess, type CardViewer } from './card-access.js'\nimport { CARD_SCHEMA_VERSION, checkDefinition, sourceOf, todayIn, type CardDefinition } from './card-definition.js'\nimport { cardIdOf, findCardProposal } from './card-proposal.js'\nimport { runCard, type CardRunResult } from './card-run.js'\nimport { DashboardCard, DashboardCardPlace, DashboardCardShare, DashboardCardShareScope, DashboardCardVersion } from './dashboard-card.js'\nimport { DashboardCardItem, DashboardCardShareInput, DashboardCardVersionItem, DashboardPlaceInput, DashboardPlaceItem, DashboardShareChoice, DashboardShareOptions } from './card-types.js'\n\nconst QUERY = '@privilege(category: \"ai-dashboard\", privilege: \"query\", domainOwnerGranted: true)'\nconst MUTATION = '@privilege(category: \"ai-dashboard\", privilege: \"mutation\", domainOwnerGranted: true)'\n\nconst MAX_WIDTH = 4\nconst MAX_HEIGHT = 2\n\n/** A refusal said in the reader's words, with a code the screen may read. */\nfunction refuse(context: ResolverContext, code: string, fallback: string, options: Record<string, unknown> = {}): never {\n const message = context.t ? String(context.t(`ai-dashboard.refusal.${code}`, { defaultValue: fallback, ...options })) : fallback\n const error: any = new Error(message)\n error.extensions = { code: `ai-dashboard.${code}` }\n throw error\n}\n\n/**\n * The viewer of a request as an audience sees them (organization, ADR-0163 decision 2), and the departments of their own\n * active records - the ones they may share with. Asked once per request.\n */\nasync function viewerOf(context: ResolverContext): Promise<{ viewer: CardViewer; departments: { id: string; name: string }[] }> {\n const state: any = context.state\n if (state.__aiDashboardViewer) return state.__aiDashboardViewer\n const { ownDepartments, ...viewer } = await audienceMemberOf(state.domain, state.user ?? {})\n const answer = { viewer, departments: ownDepartments }\n state.__aiDashboardViewer = answer\n return answer\n}\n\nconst sharesOf = async (cardIds: string[], tx?: any) =>\n cardIds.length ? await getRepository(DashboardCardShare, tx).find({ where: { card: { id: In(cardIds) } } as any }) : []\n\n/** A card the viewer may use, and how - refused otherwise (decision 7). */\nasync function usableCard(given: string, context: ResolverContext, tx?: any): Promise<{ card: DashboardCard; access: CardAccess }> {\n /* A card's uuid or its key - anything else is no card, and is not handed to a database that refuses it as no uuid. */\n const id = cardIdOf(given)\n if (!id) refuse(context, 'unknown-card', 'there is no such card.')\n const card = await getRepository(DashboardCard, tx).findOne({ where: { id, domain: { id: context.state.domain.id } } as any })\n if (!card) refuse(context, 'unknown-card', 'there is no such card.')\n const { viewer } = await viewerOf(context)\n const access = cardAccessOf(card, viewer, await sharesOf([card.id], tx))\n if (!access) refuse(context, 'card-not-shared', 'this card is not shared with you.')\n return { card, access }\n}\n\nasync function ownCard(id: string, context: ResolverContext, tx?: any): Promise<DashboardCard> {\n const { card, access } = await usableCard(id, context, tx)\n if (access !== 'owner') refuse(context, 'not-your-card', 'only the one who made this card changes it - copy it to make your own.')\n return card\n}\n\nasync function namesOf(userIds: string[]): Promise<Map<string, string>> {\n const ids = [...new Set(userIds.filter(Boolean))]\n if (!ids.length) return new Map()\n const users = await getRepository(User).find({ where: { id: In(ids) } as any })\n return new Map(users.map(one => [one.id, one.name || one.email || one.id]))\n}\n\n/** The cards as the viewer sees them - each with its access, whether placed, and its shares for its owner. */\nasync function itemsOf(cards: DashboardCard[], context: ResolverContext): Promise<DashboardCardItem[]> {\n const { viewer } = await viewerOf(context)\n const shares = await sharesOf(cards.map(one => one.id))\n const placed = cards.length\n ? new Set((await getRepository(DashboardCardPlace).find({ where: { domain: { id: viewer.domainId }, user: { id: viewer.userId }, card: { id: In(cards.map(one => one.id)) } } as any })).map(one => one.cardId))\n : new Set<string>()\n const names = await namesOf(cards.map(one => one.ownerId))\n return cards.flatMap(card => {\n const mine = shares.filter(one => one.cardId === card.id)\n const access = cardAccessOf(card, viewer, mine)\n if (!access) return []\n return [\n {\n id: card.id,\n name: card.name,\n description: card.description,\n version: card.version,\n definition: card.definition,\n access,\n ownerName: names.get(card.ownerId),\n copiedFromId: card.copiedFromId,\n placed: placed.has(card.id),\n ...(access === 'owner' ? { shares: mine.map(one => ({ scope: one.scope, targetId: one.targetId, targetName: one.targetName })) } : {}),\n updatedAt: card.updatedAt\n }\n ]\n })\n}\n\n/** Runs a definition as the viewer - the data's door and the data's API, the viewer's (decision 6). */\nexport async function runAsViewer(definition: CardDefinition, context: ResolverContext): Promise<CardRunResult> {\n return await runCard(definition, {\n readTargetOf,\n detailReadOf,\n passesDoor: door => toolAccessFor(context)(door),\n run: runAsCaller(context),\n today: todayIn(context.state.domain?.timezone),\n timeZone: context.state.domain?.timezone,\n words: (key, fallback) => {\n if (!key || typeof context.t !== 'function') return fallback\n const said = context.t(key)\n return said && said !== key ? String(said) : fallback\n }\n })\n}\n\n/** A definition fit to keep - its source known and every name its own. */\nfunction keepable(definition: any, context: ResolverContext): CardDefinition {\n const { source, issue } = sourceOf(definition?.source, readTargetOf, detailReadOf)\n if (!source) refuse(context, 'definition-unfit', 'the card reads nothing this application declares ({code}).', { code: issue?.code })\n const issues = checkDefinition(definition, source)\n if (issues.length) refuse(context, 'definition-unfit', 'the card definition does not fit its source ({code}).', { code: issues[0].code })\n return definition\n}\n\nasync function placeAtEnd(cardId: string, context: ResolverContext, tx: any): Promise<DashboardCardPlace> {\n const { domain, user } = context.state\n const repository = getRepository(DashboardCardPlace, tx)\n const existing = await repository.findOne({ where: { domain: { id: domain.id }, user: { id: user.id }, card: { id: cardId } } as any })\n if (existing) return existing\n const last = await repository.findOne({ where: { domain: { id: domain.id }, user: { id: user.id } } as any, order: { order: 'DESC' } as any })\n return await repository.save({ domain, user, card: { id: cardId }, order: (last?.order ?? -1) + 1, width: 2, height: 1, creator: user, updater: user } as any)\n}\n\n@Resolver()\nexport class DashboardCardResolver {\n @Directive(QUERY)\n @Query(returns => [DashboardPlaceItem], { description: \"The cards on the viewer's dashboard, in order - only those the viewer may still use.\" })\n async myDashboard(@Ctx() context: ResolverContext): Promise<DashboardPlaceItem[]> {\n const { domain, user } = context.state\n const places = await getRepository(DashboardCardPlace).find({ where: { domain: { id: domain.id }, user: { id: user.id } } as any, order: { order: 'ASC' } as any })\n const cards = places.length ? await getRepository(DashboardCard).find({ where: { id: In(places.map(one => one.cardId)), domain: { id: domain.id } } as any }) : []\n const items = new Map((await itemsOf(cards, context)).map(one => [one.id, one]))\n return places.flatMap(place => (items.has(place.cardId) ? [{ id: place.id, order: place.order, width: place.width, height: place.height, card: items.get(place.cardId)! }] : []))\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardCardItem], { description: \"The viewer's card library - 'mine', the cards they made, or 'shared', those shared with them.\" })\n async dashboardCards(@Arg('which', { description: \"'mine' or 'shared'.\" }) which: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem[]> {\n const { viewer } = await viewerOf(context)\n if (which === 'mine') {\n const cards = await getRepository(DashboardCard).find({ where: { domain: { id: viewer.domainId }, owner: { id: viewer.userId } } as any, order: { updatedAt: 'DESC' } as any })\n return await itemsOf(cards, context)\n }\n const shares = await getRepository(DashboardCardShare).find({\n where: [\n { domain: { id: viewer.domainId }, scope: DashboardCardShareScope.USER, targetId: viewer.userId },\n { domain: { id: viewer.domainId }, scope: DashboardCardShareScope.DOMAIN, targetId: viewer.domainId },\n ...(viewer.departmentIds.length ? [{ domain: { id: viewer.domainId }, scope: DashboardCardShareScope.DEPARTMENT, targetId: In([...viewer.departmentIds]) }] : []),\n ...(viewer.roleIds?.length ? [{ domain: { id: viewer.domainId }, scope: DashboardCardShareScope.ROLE, targetId: In([...viewer.roleIds]) }] : [])\n ] as any\n })\n const ids = [...new Set(shares.map(one => one.cardId))]\n const cards = ids.length ? await getRepository(DashboardCard).find({ where: { id: In(ids), domain: { id: viewer.domainId }, owner: { id: Not(viewer.userId) } } as any, order: { updatedAt: 'DESC' } as any }) : []\n return await itemsOf(cards, context)\n }\n\n @Directive(QUERY)\n @Query(returns => GraphQLJSON, { description: 'Draws one card as the viewer - its block, how much of the source it was drawn from, or why it cannot be drawn. No model is asked.' })\n async dashboardCardRun(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<CardRunResult> {\n const { card } = await usableCard(id, context)\n return await runAsViewer(card.definition as CardDefinition, context)\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardCardVersionItem], { description: \"A card's versions, newest first - its owner only.\" })\n async dashboardCardVersions(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DashboardCardVersionItem[]> {\n const card = await ownCard(id, context)\n const versions = await getRepository(DashboardCardVersion).find({ where: { card: { id: card.id } } as any, order: { version: 'DESC' } as any })\n const names = await namesOf(versions.map(one => one.creatorId))\n return versions.map(one => ({ version: one.version, name: one.name, definition: one.definition, creatorName: names.get(one.creatorId), createdAt: one.createdAt }))\n }\n\n @Directive(QUERY)\n @Query(returns => DashboardShareOptions, { description: 'What the viewer may share a card with - the domain, their own departments, and whether people can be looked up.' })\n async dashboardShareOptions(@Ctx() context: ResolverContext): Promise<DashboardShareOptions> {\n const { departments } = await viewerOf(context)\n const domain: any = context.state.domain\n return {\n domainId: domain.id,\n domainName: domain.name ?? domain.subdomain ?? domain.id,\n departments,\n peopleAvailable: await toolAccessFor(context)('Query.employees'),\n roles: (await domainRolesOf(context.state.domain)).map(one => ({ id: one.id, name: one.name, ...(one.description ? { note: one.description } : {}) }))\n }\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardShareChoice], { description: \"People to share a card with, found by name through the organization's own list as the viewer.\" })\n async dashboardSharePeople(@Arg('text') text: string, @Ctx() context: ResolverContext): Promise<DashboardShareChoice[]> {\n const words = (text ?? '').trim()\n if (!words) return []\n const answer = await runAsCaller(context)(\n 'query ($filters: [Filter!], $pagination: Pagination) { employees(filters: $filters, pagination: $pagination) { items { name department { name } user { id } } } }',\n { filters: [{ name: 'active', operator: 'eq', value: true }, { name: 'name', operator: 'i_like', value: words }], pagination: { page: 1, limit: 20 } }\n )\n if (answer.errors?.length) refuse(context, 'people-unavailable', 'people cannot be looked up here.')\n return (answer.data?.employees?.items ?? [])\n .filter((one: any) => one?.user?.id && one.user.id !== context.state.user.id)\n .map((one: any) => ({ id: one.user.id, name: one.name, note: one.department?.name }))\n }\n\n @Directive(QUERY)\n @Query(returns => GraphQLJSON, {\n description: \"Draws a card a conversation proposed, as the one looking at the conversation - the proposal keeps the definition, never its values.\"\n })\n async dashboardCardProposalPreview(@Arg('sessionId') sessionId: string, @Arg('proposalKey') proposalKey: string, @Ctx() context: ResolverContext): Promise<CardRunResult> {\n const { domain, user } = context.state\n const session = await getRepository(ChatSession).findOneBy({ id: sessionId, domain: { id: domain.id } } as any)\n if (!session) refuse(context, 'unknown-conversation', 'there is no such conversation.')\n const participant = await isSessionParticipant(domain.id, session.id, user?.id)\n if (!mayReadSession(session.visibility, participant)) refuse(context, 'conversation-closed', 'this conversation is not open to you.')\n const { proposal } = findCardProposal(await proposalMessages(session.id), proposalKey)\n if (!proposal) refuse(context, 'unknown-proposal', 'there is no such card in this conversation.')\n return await runAsViewer(proposal.card.definition, context)\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => GraphQLJSON, {\n description:\n \"Saves a card a conversation proposed and places it on the viewer's dashboard - the stored proposal's definition, never one the screen sends. A change of a saved card is its owner's, from the version it was read at. Pressing it again answers the same card.\"\n })\n async saveDashboardCardProposal(@Arg('sessionId') sessionId: string, @Arg('proposalKey') proposalKey: string, @Ctx() context: ResolverContext): Promise<{ cardId: string; version: number; placeId: string; again?: boolean }> {\n const { domain, user, tx } = context.state as any\n const session = await getRepository(ChatSession, tx).findOneBy({ id: sessionId, domain: { id: domain.id } } as any)\n if (!session) refuse(context, 'unknown-conversation', 'there is no such conversation.')\n await assertMayWriteSession({\n session,\n userId: user?.id,\n isParticipant: () => isSessionParticipant(domain.id, session.id, user?.id),\n t: (key, options) => (context.t ? context.t(key, options) : String(options?.defaultValue ?? key))\n })\n\n /* Saved already - the same card, whoever's request it is now asked by. */\n const saved = await getRepository(DashboardCardVersion, tx).findOne({ where: { domain: { id: domain.id }, proposalSessionId: session.id, proposalKey } as any })\n if (saved) {\n const card = await ownCard(saved.cardId, context, tx)\n const place = await placeAtEnd(card.id, context, tx)\n return { cardId: card.id, version: saved.version, placeId: place.id, again: true }\n }\n\n const { proposal, superseded, notACard } = findCardProposal(await proposalMessages(session.id, tx), proposalKey)\n if (notACard) refuse(context, 'not-a-card', 'this proposal is not a dashboard card.')\n if (!proposal) refuse(context, 'unknown-proposal', 'there is no such card in this conversation.')\n if (superseded) refuse(context, 'superseded', 'a newer card replaced this one in the conversation - save that one.')\n const definition = keepable(proposal.card.definition, context)\n /* Keeping a card one cannot read draws nothing - the data's door is the saver's too. */\n const { source } = sourceOf(definition.source, readTargetOf, detailReadOf)\n if (!(await toolAccessFor(context)(rootFieldOf(source!.query, 'query')))) refuse(context, 'data-closed', 'you may not read the data this card draws.')\n const name = String(proposal.card.name ?? '').trim().slice(0, 100) || 'card'\n const description = proposal.card.description ? String(proposal.card.description).slice(0, 300) : null\n\n let card: DashboardCard\n let version: number\n if (proposal.card.cardId) {\n card = await ownCard(proposal.card.cardId, context, tx)\n if (proposal.card.baseVersion !== card.version) refuse(context, 'stale-version', 'the card changed since this proposal (now version {version}) - ask for the change again.', { version: card.version })\n version = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name, description, version, definitionJson: JSON.stringify(definition), updater: user } as any)\n } else {\n version = 1\n card = await getRepository(DashboardCard, tx).save({ domain, name, description, owner: user, version, definitionJson: JSON.stringify(definition), creator: user, updater: user } as any)\n }\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version, name, definitionJson: JSON.stringify(definition), proposalSessionId: session.id, proposalKey, creator: user, updater: user } as any)\n const place = await placeAtEnd(card.id, context, tx)\n return { cardId: card.id, version, placeId: place.id }\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Renames one's own card - a new version.\" })\n async renameDashboardCard(@Arg('id') id: string, @Arg('name') name: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const given = (name ?? '').trim().slice(0, 100)\n if (!given) refuse(context, 'no-name', 'a card needs a name.')\n const version = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name: given, version, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version, name: given, definitionJson: card.definitionJson, creator: user, updater: user } as any)\n return (await itemsOf([await getRepository(DashboardCard, tx).findOneBy({ id: card.id })], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Brings back an earlier version of one's own card - its definition and name become a new version.\" })\n async restoreDashboardCardVersion(@Arg('id') id: string, @Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const earlier = await getRepository(DashboardCardVersion, tx).findOne({ where: { card: { id: card.id }, version } as any })\n if (!earlier) refuse(context, 'unknown-version', 'there is no such version.')\n keepable(earlier.definition, context)\n const next = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name: earlier.name, definitionJson: earlier.definitionJson, version: next, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version: next, name: earlier.name, definitionJson: earlier.definitionJson, creator: user, updater: user } as any)\n return (await itemsOf([await getRepository(DashboardCard, tx).findOneBy({ id: card.id })], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: 'Copies a card one may use into a card of one\\'s own, placed on one\\'s dashboard.' })\n async copyDashboardCard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const { card } = await usableCard(id, context, tx)\n const copy = await getRepository(DashboardCard, tx).save({ domain, name: card.name, description: card.description, owner: user, version: 1, definitionJson: card.definitionJson, copiedFromId: card.id, creator: user, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: copy.id }, version: 1, name: copy.name, definitionJson: copy.definitionJson, creator: user, updater: user } as any)\n await placeAtEnd(copy.id, context, tx)\n return (await itemsOf([copy], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Deletes one's own card - its versions, shares and every place it was put.\" })\n async deleteDashboardCard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx } = context.state as any\n const card = await ownCard(id, context, tx)\n for (const entity of [DashboardCardPlace, DashboardCardShare, DashboardCardVersion] as any[]) {\n const rows = await getRepository(entity, tx).find({ where: { card: { id: card.id } } as any })\n if (rows.length) await getRepository(entity, tx).softRemove(rows)\n }\n await getRepository(DashboardCard, tx).softRemove(card)\n return true\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Sets who one's own card is shared with - the whole list; none keeps it to oneself. A share gives the definition, never the data.\" })\n async shareDashboardCard(@Arg('id') id: string, @Arg('shares', type => [DashboardCardShareInput]) shares: DashboardCardShareInput[], @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const roleIds = (shares ?? []).some(one => one.scope === DashboardCardShareScope.ROLE) ? (await domainRolesOf(domain, undefined, tx)).map(one => one.id) : []\n const departmentIds = (shares ?? []).some(one => one.scope === DashboardCardShareScope.DEPARTMENT) ? [...(await departmentTreeOf(domain, tx)).keys()] : []\n const wanted = new Map<string, DashboardCardShareInput>()\n for (const share of shares ?? []) {\n const refusal = audienceTargetRefusal(share, { domainId: domain.id, departmentIds, roleIds })\n if (refusal) refuse(context, `share-${refusal}`, 'this share cannot be given ({code}).', { code: refusal })\n if (share.scope === DashboardCardShareScope.USER && share.targetId === user.id) continue\n wanted.set(`${share.scope}:${share.targetId}`, share)\n }\n const repository = getRepository(DashboardCardShare, tx)\n const current = await repository.find({ where: { card: { id: card.id } } as any })\n const gone = current.filter(one => !wanted.has(`${one.scope}:${one.targetId}`))\n if (gone.length) await repository.softRemove(gone)\n for (const [key, share] of wanted) {\n if (current.some(one => `${one.scope}:${one.targetId}` === key)) continue\n await repository.save({ domain, card: { id: card.id }, scope: share.scope, targetId: share.targetId, targetName: share.targetName?.slice(0, 100), creator: user, updater: user } as any)\n }\n return (await itemsOf([card], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardPlaceItem, { description: \"Places a card one may use at the end of one's dashboard.\" })\n async placeDashboardCard(@Arg('cardId') cardId: string, @Ctx() context: ResolverContext): Promise<DashboardPlaceItem> {\n const { tx } = context.state as any\n const { card } = await usableCard(cardId, context, tx)\n const place = await placeAtEnd(card.id, context, tx)\n return { id: place.id, order: place.order, width: place.width, height: place.height, card: (await itemsOf([card], context))[0] }\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Takes a card off one's dashboard - the card stays in the library.\" })\n async removeDashboardPlace(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state as any\n const place = await getRepository(DashboardCardPlace, tx).findOne({ where: { id, domain: { id: domain.id }, user: { id: user.id } } as any })\n if (!place) refuse(context, 'unknown-place', 'that card is not on your dashboard.')\n await getRepository(DashboardCardPlace, tx).softRemove(place)\n return true\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Sets the order and size of the cards on one's dashboard.\" })\n async arrangeDashboard(@Arg('places', type => [DashboardPlaceInput]) places: DashboardPlaceInput[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state as any\n const repository = getRepository(DashboardCardPlace, tx)\n const mine = await repository.find({ where: { domain: { id: domain.id }, user: { id: user.id } } as any })\n for (const given of places ?? []) {\n const place = mine.find(one => one.id === given.id)\n if (!place) refuse(context, 'unknown-place', 'that card is not on your dashboard.')\n if (!(given.width >= 1 && given.width <= MAX_WIDTH && given.height >= 1 && given.height <= MAX_HEIGHT)) refuse(context, 'size-out-of-range', 'a card spans 1 to 4 columns and 1 to 2 rows.')\n await repository.save({ ...place, order: given.order, width: given.width, height: given.height, updater: user } as any)\n }\n return true\n }\n}\n\n/** The conversation's messages that carry proposals, oldest first. */\nasync function proposalMessages(sessionId: string, tx?: any): Promise<{ proposals: any[] }[]> {\n const carrying = await getRepository(ChatMessage, tx).find({\n select: ['id', 'proposals', 'createdAt'] as any,\n where: { session: { id: sessionId } as any, proposals: Not(IsNull()) } as any,\n order: { createdAt: 'ASC' } as any\n })\n return carrying.map((message: any) => ({ proposals: message.proposalsJson ?? [] }))\n}\n\nexport { CARD_SCHEMA_VERSION }\n"]}
1
+ {"version":3,"file":"card-resolver.js","sourceRoot":"","sources":["../../../server/service/card/card-resolver.ts"],"names":[],"mappings":";;;AAmIA,kCAcC;;AAjJD;;;;;;;GAOG;AACH,+CAAkF;AAClF,qDAA6C;AAC7C,qCAAyC;AAEzC,iDAAqD;AACrD,yDAAg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,EAAE,0DAA0D,EAAE,CAAC;IAClF,mBAAA,IAAA,kBAAG,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,mCAAmB,CAAC,CAAC,CAAA;IAAiC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DAWzG;gCApQU,qBAAqB;IADjC,IAAA,uBAAQ,GAAE;GACE,qBAAqB,CAqQjC;AAED,sEAAsE;AACtE,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,EAAQ;IACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,0BAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAQ;QAC/C,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAS,EAAE,SAAS,EAAE,IAAA,aAAG,EAAC,IAAA,gBAAM,GAAE,CAAC,EAAS;QAC7E,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAS;KACnC,CAAC,CAAA;IACF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA;AACrF,CAAC","sourcesContent":["/*\n * The doors of the dashboard cards (ADR-0160 decisions 6-10) - one's own cards and those shared with one, one's own\n * dashboard, a card's versions and shares (its owner's), running a card, and saving a proposal a conversation made.\n *\n * Every door asks who may use the card again (card-access.ts) - a share withdrawn closes at once. Running a card asks\n * the data's own door as the viewer and reads with the viewer's request (card-run.ts): the card gives the definition,\n * never the data.\n */\nimport { Arg, Ctx, Directive, Int, Mutation, Query, Resolver } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport { In, IsNull, Not } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { audienceMemberOf, audienceTargetRefusal, departmentTreeOf, domainRolesOf } from '@things-factory/organization'\nimport {\n assertMayWriteSession,\n ChatMessage,\n ChatSession,\n detailReadOf,\n isSessionParticipant,\n mayReadSession,\n readTargetOf,\n rootFieldOf,\n runAsCaller,\n toolAccessFor\n} from '@things-factory/ai-assistant'\n\nimport { cardAccessOf, type CardAccess, type CardViewer } from './card-access.js'\nimport { CARD_SCHEMA_VERSION, checkDefinition, sourceOf, todayIn, type CardDefinition } from './card-definition.js'\nimport { CARD_NAME_MAX } from './card-names.js'\nimport { cardIdOf, findCardProposal } from './card-proposal.js'\nimport { runCard, type CardRunResult } from './card-run.js'\nimport { DashboardCard, DashboardCardPlace, DashboardCardShare, DashboardCardShareScope, DashboardCardVersion } from './dashboard-card.js'\nimport { DashboardCardItem, DashboardCardShareInput, DashboardCardVersionItem, DashboardPlaceInput, DashboardPlaceItem, DashboardShareChoice, DashboardShareOptions } from './card-types.js'\n\nconst QUERY = '@privilege(category: \"ai-dashboard\", privilege: \"query\", domainOwnerGranted: true)'\nconst MUTATION = '@privilege(category: \"ai-dashboard\", privilege: \"mutation\", domainOwnerGranted: true)'\n\nconst MAX_WIDTH = 4\nconst MAX_HEIGHT = 2\n\n/** The name as typed, or refused with the bound - a longer name was cut without a word (inline help audit 2026-10-30). */\nfunction cardNameOf(name: unknown, context: ResolverContext): string {\n const given = String(name ?? '').trim()\n if (given.length > CARD_NAME_MAX) refuse(context, 'name-too-long', 'a card name takes up to {max} characters; this one has {length}.', { max: CARD_NAME_MAX, length: given.length })\n return given\n}\n\n/** A refusal said in the reader's words, with a code the screen may read. */\nfunction refuse(context: ResolverContext, code: string, fallback: string, options: Record<string, unknown> = {}): never {\n const message = context.t ? String(context.t(`ai-dashboard.refusal.${code}`, { defaultValue: fallback, ...options })) : fallback\n const error: any = new Error(message)\n /* The issue code is for the people who keep the application - the sentence a person reads does not carry it. */\n error.extensions = { code: `ai-dashboard.${code}`, ...(options.issue ? { issue: options.issue } : {}) }\n throw error\n}\n\n/**\n * The viewer of a request as an audience sees them (organization, ADR-0163 decision 2), and the departments of their own\n * active records - the ones they may share with. Asked once per request.\n */\nasync function viewerOf(context: ResolverContext): Promise<{ viewer: CardViewer; departments: { id: string; name: string }[] }> {\n const state: any = context.state\n if (state.__aiDashboardViewer) return state.__aiDashboardViewer\n const { ownDepartments, ...viewer } = await audienceMemberOf(state.domain, state.user ?? {})\n const answer = { viewer, departments: ownDepartments }\n state.__aiDashboardViewer = answer\n return answer\n}\n\nconst sharesOf = async (cardIds: string[], tx?: any) =>\n cardIds.length ? await getRepository(DashboardCardShare, tx).find({ where: { card: { id: In(cardIds) } } as any }) : []\n\n/** A card the viewer may use, and how - refused otherwise (decision 7). */\nasync function usableCard(given: string, context: ResolverContext, tx?: any): Promise<{ card: DashboardCard; access: CardAccess }> {\n /* A card's uuid or its key - anything else is no card, and is not handed to a database that refuses it as no uuid. */\n const id = cardIdOf(given)\n if (!id) refuse(context, 'unknown-card', 'there is no such card.')\n const card = await getRepository(DashboardCard, tx).findOne({ where: { id, domain: { id: context.state.domain.id } } as any })\n if (!card) refuse(context, 'unknown-card', 'there is no such card.')\n const { viewer } = await viewerOf(context)\n const access = cardAccessOf(card, viewer, await sharesOf([card.id], tx))\n if (!access) refuse(context, 'card-not-shared', 'this card is not shared with you.')\n return { card, access }\n}\n\nasync function ownCard(id: string, context: ResolverContext, tx?: any): Promise<DashboardCard> {\n const { card, access } = await usableCard(id, context, tx)\n if (access !== 'owner') refuse(context, 'not-your-card', 'only the one who made this card changes it - copy it to make your own.')\n return card\n}\n\nasync function namesOf(userIds: string[]): Promise<Map<string, string>> {\n const ids = [...new Set(userIds.filter(Boolean))]\n if (!ids.length) return new Map()\n const users = await getRepository(User).find({ where: { id: In(ids) } as any })\n return new Map(users.map(one => [one.id, one.name || one.email || one.id]))\n}\n\n/** The cards as the viewer sees them - each with its access, whether placed, and its shares for its owner. */\nasync function itemsOf(cards: DashboardCard[], context: ResolverContext): Promise<DashboardCardItem[]> {\n const { viewer } = await viewerOf(context)\n const shares = await sharesOf(cards.map(one => one.id))\n const placed = cards.length\n ? new Set((await getRepository(DashboardCardPlace).find({ where: { domain: { id: viewer.domainId }, user: { id: viewer.userId }, card: { id: In(cards.map(one => one.id)) } } as any })).map(one => one.cardId))\n : new Set<string>()\n const names = await namesOf(cards.map(one => one.ownerId))\n return cards.flatMap(card => {\n const mine = shares.filter(one => one.cardId === card.id)\n const access = cardAccessOf(card, viewer, mine)\n if (!access) return []\n return [\n {\n id: card.id,\n name: card.name,\n description: card.description,\n version: card.version,\n definition: card.definition,\n access,\n ownerName: names.get(card.ownerId),\n copiedFromId: card.copiedFromId,\n placed: placed.has(card.id),\n ...(access === 'owner' ? { shares: mine.map(one => ({ scope: one.scope, targetId: one.targetId, targetName: one.targetName })) } : {}),\n updatedAt: card.updatedAt\n }\n ]\n })\n}\n\n/** Runs a definition as the viewer - the data's door and the data's API, the viewer's (decision 6). */\nexport async function runAsViewer(definition: CardDefinition, context: ResolverContext): Promise<CardRunResult> {\n return await runCard(definition, {\n readTargetOf,\n detailReadOf,\n passesDoor: door => toolAccessFor(context)(door),\n run: runAsCaller(context),\n today: todayIn(context.state.domain?.timezone),\n timeZone: context.state.domain?.timezone,\n words: (key, fallback) => {\n if (!key || typeof context.t !== 'function') return fallback\n const said = context.t(key)\n return said && said !== key ? String(said) : fallback\n }\n })\n}\n\n/** A definition fit to keep - its source known and every name its own. */\nfunction keepable(definition: any, context: ResolverContext): CardDefinition {\n const { source, issue } = sourceOf(definition?.source, readTargetOf, detailReadOf)\n if (!source) refuse(context, 'definition-unfit', 'the card reads nothing this application declares.', { issue: issue?.code })\n const issues = checkDefinition(definition, source)\n if (issues.length) refuse(context, 'definition-unfit', 'the card definition does not fit its source.', { issue: issues[0].code })\n return definition\n}\n\nasync function placeAtEnd(cardId: string, context: ResolverContext, tx: any): Promise<DashboardCardPlace> {\n const { domain, user } = context.state\n const repository = getRepository(DashboardCardPlace, tx)\n const existing = await repository.findOne({ where: { domain: { id: domain.id }, user: { id: user.id }, card: { id: cardId } } as any })\n if (existing) return existing\n const last = await repository.findOne({ where: { domain: { id: domain.id }, user: { id: user.id } } as any, order: { order: 'DESC' } as any })\n return await repository.save({ domain, user, card: { id: cardId }, order: (last?.order ?? -1) + 1, width: 2, height: 1, creator: user, updater: user } as any)\n}\n\n@Resolver()\nexport class DashboardCardResolver {\n @Directive(QUERY)\n @Query(returns => [DashboardPlaceItem], { description: \"The cards on the viewer's dashboard, in order - only those the viewer may still use.\" })\n async myDashboard(@Ctx() context: ResolverContext): Promise<DashboardPlaceItem[]> {\n const { domain, user } = context.state\n const places = await getRepository(DashboardCardPlace).find({ where: { domain: { id: domain.id }, user: { id: user.id } } as any, order: { order: 'ASC' } as any })\n const cards = places.length ? await getRepository(DashboardCard).find({ where: { id: In(places.map(one => one.cardId)), domain: { id: domain.id } } as any }) : []\n const items = new Map((await itemsOf(cards, context)).map(one => [one.id, one]))\n return places.flatMap(place => (items.has(place.cardId) ? [{ id: place.id, order: place.order, width: place.width, height: place.height, card: items.get(place.cardId)! }] : []))\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardCardItem], { description: \"The viewer's card library - 'mine', the cards they made, or 'shared', those shared with them.\" })\n async dashboardCards(@Arg('which', { description: \"'mine' or 'shared'.\" }) which: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem[]> {\n const { viewer } = await viewerOf(context)\n if (which === 'mine') {\n const cards = await getRepository(DashboardCard).find({ where: { domain: { id: viewer.domainId }, owner: { id: viewer.userId } } as any, order: { updatedAt: 'DESC' } as any })\n return await itemsOf(cards, context)\n }\n const shares = await getRepository(DashboardCardShare).find({\n where: [\n { domain: { id: viewer.domainId }, scope: DashboardCardShareScope.USER, targetId: viewer.userId },\n { domain: { id: viewer.domainId }, scope: DashboardCardShareScope.DOMAIN, targetId: viewer.domainId },\n ...(viewer.departmentIds.length ? [{ domain: { id: viewer.domainId }, scope: DashboardCardShareScope.DEPARTMENT, targetId: In([...viewer.departmentIds]) }] : []),\n ...(viewer.roleIds?.length ? [{ domain: { id: viewer.domainId }, scope: DashboardCardShareScope.ROLE, targetId: In([...viewer.roleIds]) }] : [])\n ] as any\n })\n const ids = [...new Set(shares.map(one => one.cardId))]\n const cards = ids.length ? await getRepository(DashboardCard).find({ where: { id: In(ids), domain: { id: viewer.domainId }, owner: { id: Not(viewer.userId) } } as any, order: { updatedAt: 'DESC' } as any }) : []\n return await itemsOf(cards, context)\n }\n\n @Directive(QUERY)\n @Query(returns => GraphQLJSON, { description: 'Draws one card as the viewer - its block, how much of the source it was drawn from, or why it cannot be drawn. No model is asked.' })\n async dashboardCardRun(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<CardRunResult> {\n const { card } = await usableCard(id, context)\n return await runAsViewer(card.definition as CardDefinition, context)\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardCardVersionItem], { description: \"A card's versions, newest first - its owner only.\" })\n async dashboardCardVersions(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DashboardCardVersionItem[]> {\n const card = await ownCard(id, context)\n const versions = await getRepository(DashboardCardVersion).find({ where: { card: { id: card.id } } as any, order: { version: 'DESC' } as any })\n const names = await namesOf(versions.map(one => one.creatorId))\n return versions.map(one => ({ version: one.version, name: one.name, definition: one.definition, creatorName: names.get(one.creatorId), createdAt: one.createdAt }))\n }\n\n @Directive(QUERY)\n @Query(returns => DashboardShareOptions, { description: 'What the viewer may share a card with - the domain, their own departments, and whether people can be looked up.' })\n async dashboardShareOptions(@Ctx() context: ResolverContext): Promise<DashboardShareOptions> {\n const { departments } = await viewerOf(context)\n const domain: any = context.state.domain\n return {\n domainId: domain.id,\n domainName: domain.name ?? domain.subdomain ?? domain.id,\n departments,\n peopleAvailable: await toolAccessFor(context)('Query.employees'),\n roles: (await domainRolesOf(context.state.domain)).map(one => ({ id: one.id, name: one.name, ...(one.description ? { note: one.description } : {}) }))\n }\n }\n\n @Directive(QUERY)\n @Query(returns => [DashboardShareChoice], { description: \"People to share a card with, found by name through the organization's own list as the viewer.\" })\n async dashboardSharePeople(@Arg('text') text: string, @Ctx() context: ResolverContext): Promise<DashboardShareChoice[]> {\n const words = (text ?? '').trim()\n if (!words) return []\n const answer = await runAsCaller(context)(\n 'query ($filters: [Filter!], $pagination: Pagination) { employees(filters: $filters, pagination: $pagination) { items { name department { name } user { id } } } }',\n { filters: [{ name: 'active', operator: 'eq', value: true }, { name: 'name', operator: 'i_like', value: words }], pagination: { page: 1, limit: 20 } }\n )\n if (answer.errors?.length) refuse(context, 'people-unavailable', 'people cannot be looked up here.')\n return (answer.data?.employees?.items ?? [])\n .filter((one: any) => one?.user?.id && one.user.id !== context.state.user.id)\n .map((one: any) => ({ id: one.user.id, name: one.name, note: one.department?.name }))\n }\n\n @Directive(QUERY)\n @Query(returns => GraphQLJSON, {\n description: \"Draws a card a conversation proposed, as the one looking at the conversation - the proposal keeps the definition, never its values.\"\n })\n async dashboardCardProposalPreview(@Arg('sessionId') sessionId: string, @Arg('proposalKey') proposalKey: string, @Ctx() context: ResolverContext): Promise<CardRunResult> {\n const { domain, user } = context.state\n const session = await getRepository(ChatSession).findOneBy({ id: sessionId, domain: { id: domain.id } } as any)\n if (!session) refuse(context, 'unknown-conversation', 'there is no such conversation.')\n const participant = await isSessionParticipant(domain.id, session.id, user?.id)\n if (!mayReadSession(session.visibility, participant)) refuse(context, 'conversation-closed', 'this conversation is not open to you.')\n const { proposal } = findCardProposal(await proposalMessages(session.id), proposalKey)\n if (!proposal) refuse(context, 'unknown-proposal', 'there is no such card in this conversation.')\n return await runAsViewer(proposal.card.definition, context)\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => GraphQLJSON, {\n description:\n \"Saves a card a conversation proposed and places it on the viewer's dashboard - the stored proposal's definition, never one the screen sends. A change of a saved card is its owner's, from the version it was read at. Pressing it again answers the same card.\"\n })\n async saveDashboardCardProposal(@Arg('sessionId') sessionId: string, @Arg('proposalKey') proposalKey: string, @Ctx() context: ResolverContext): Promise<{ cardId: string; version: number; placeId: string; again?: boolean }> {\n const { domain, user, tx } = context.state as any\n const session = await getRepository(ChatSession, tx).findOneBy({ id: sessionId, domain: { id: domain.id } } as any)\n if (!session) refuse(context, 'unknown-conversation', 'there is no such conversation.')\n await assertMayWriteSession({\n session,\n userId: user?.id,\n isParticipant: () => isSessionParticipant(domain.id, session.id, user?.id),\n t: (key, options) => (context.t ? context.t(key, options) : String(options?.defaultValue ?? key))\n })\n\n /* Saved already - the same card, whoever's request it is now asked by. */\n const saved = await getRepository(DashboardCardVersion, tx).findOne({ where: { domain: { id: domain.id }, proposalSessionId: session.id, proposalKey } as any })\n if (saved) {\n const card = await ownCard(saved.cardId, context, tx)\n const place = await placeAtEnd(card.id, context, tx)\n return { cardId: card.id, version: saved.version, placeId: place.id, again: true }\n }\n\n const { proposal, superseded, notACard } = findCardProposal(await proposalMessages(session.id, tx), proposalKey)\n if (notACard) refuse(context, 'not-a-card', 'this proposal is not a dashboard card.')\n if (!proposal) refuse(context, 'unknown-proposal', 'there is no such card in this conversation.')\n if (superseded) refuse(context, 'superseded', 'a newer card replaced this one in the conversation - save that one.')\n const definition = keepable(proposal.card.definition, context)\n /* Keeping a card one cannot read draws nothing - the data's door is the saver's too. */\n const { source } = sourceOf(definition.source, readTargetOf, detailReadOf)\n if (!(await toolAccessFor(context)(rootFieldOf(source!.query, 'query')))) refuse(context, 'data-closed', 'you may not read the data this card draws.')\n const name = cardNameOf(proposal.card.name, context) || String(context.t ? context.t('ai-dashboard.text.untitled-card') : 'Untitled card')\n const description = proposal.card.description ? String(proposal.card.description).slice(0, 300) : null\n\n let card: DashboardCard\n let version: number\n if (proposal.card.cardId) {\n card = await ownCard(proposal.card.cardId, context, tx)\n if (proposal.card.baseVersion !== card.version) refuse(context, 'stale-version', 'the card changed since this proposal (now version {version}) - ask for the change again.', { version: card.version })\n version = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name, description, version, definitionJson: JSON.stringify(definition), updater: user } as any)\n } else {\n version = 1\n card = await getRepository(DashboardCard, tx).save({ domain, name, description, owner: user, version, definitionJson: JSON.stringify(definition), creator: user, updater: user } as any)\n }\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version, name, definitionJson: JSON.stringify(definition), proposalSessionId: session.id, proposalKey, creator: user, updater: user } as any)\n const place = await placeAtEnd(card.id, context, tx)\n return { cardId: card.id, version, placeId: place.id }\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Renames one's own card - a new version.\" })\n async renameDashboardCard(@Arg('id') id: string, @Arg('name') name: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const given = cardNameOf(name, context)\n if (!given) refuse(context, 'no-name', 'a card needs a name.')\n const version = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name: given, version, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version, name: given, definitionJson: card.definitionJson, creator: user, updater: user } as any)\n return (await itemsOf([await getRepository(DashboardCard, tx).findOneBy({ id: card.id })], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Brings back an earlier version of one's own card - its definition and name become a new version.\" })\n async restoreDashboardCardVersion(@Arg('id') id: string, @Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const earlier = await getRepository(DashboardCardVersion, tx).findOne({ where: { card: { id: card.id }, version } as any })\n if (!earlier) refuse(context, 'unknown-version', 'there is no such version.')\n keepable(earlier.definition, context)\n const next = card.version + 1\n await getRepository(DashboardCard, tx).save({ ...card, name: earlier.name, definitionJson: earlier.definitionJson, version: next, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: card.id }, version: next, name: earlier.name, definitionJson: earlier.definitionJson, creator: user, updater: user } as any)\n return (await itemsOf([await getRepository(DashboardCard, tx).findOneBy({ id: card.id })], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: 'Copies a card one may use into a card of one\\'s own, placed on one\\'s dashboard.' })\n async copyDashboardCard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const { card } = await usableCard(id, context, tx)\n const copy = await getRepository(DashboardCard, tx).save({ domain, name: card.name, description: card.description, owner: user, version: 1, definitionJson: card.definitionJson, copiedFromId: card.id, creator: user, updater: user } as any)\n await getRepository(DashboardCardVersion, tx).save({ domain, card: { id: copy.id }, version: 1, name: copy.name, definitionJson: copy.definitionJson, creator: user, updater: user } as any)\n await placeAtEnd(copy.id, context, tx)\n return (await itemsOf([copy], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Deletes one's own card - its versions, shares and every place it was put.\" })\n async deleteDashboardCard(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx } = context.state as any\n const card = await ownCard(id, context, tx)\n for (const entity of [DashboardCardPlace, DashboardCardShare, DashboardCardVersion] as any[]) {\n const rows = await getRepository(entity, tx).find({ where: { card: { id: card.id } } as any })\n if (rows.length) await getRepository(entity, tx).softRemove(rows)\n }\n await getRepository(DashboardCard, tx).softRemove(card)\n return true\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardCardItem, { description: \"Sets who one's own card is shared with - the whole list; none keeps it to oneself. A share gives the definition, never the data.\" })\n async shareDashboardCard(@Arg('id') id: string, @Arg('shares', type => [DashboardCardShareInput]) shares: DashboardCardShareInput[], @Ctx() context: ResolverContext): Promise<DashboardCardItem> {\n const { domain, user, tx } = context.state as any\n const card = await ownCard(id, context, tx)\n const roleIds = (shares ?? []).some(one => one.scope === DashboardCardShareScope.ROLE) ? (await domainRolesOf(domain, undefined, tx)).map(one => one.id) : []\n const departmentIds = (shares ?? []).some(one => one.scope === DashboardCardShareScope.DEPARTMENT) ? [...(await departmentTreeOf(domain, tx)).keys()] : []\n const wanted = new Map<string, DashboardCardShareInput>()\n for (const share of shares ?? []) {\n const refusal = audienceTargetRefusal(share, { domainId: domain.id, departmentIds, roleIds })\n if (refusal) refuse(context, `share-${refusal}`, 'this share cannot be given ({code}).', { code: refusal })\n if (share.scope === DashboardCardShareScope.USER && share.targetId === user.id) continue\n wanted.set(`${share.scope}:${share.targetId}`, share)\n }\n const repository = getRepository(DashboardCardShare, tx)\n const current = await repository.find({ where: { card: { id: card.id } } as any })\n const gone = current.filter(one => !wanted.has(`${one.scope}:${one.targetId}`))\n if (gone.length) await repository.softRemove(gone)\n for (const [key, share] of wanted) {\n if (current.some(one => `${one.scope}:${one.targetId}` === key)) continue\n await repository.save({ domain, card: { id: card.id }, scope: share.scope, targetId: share.targetId, targetName: share.targetName?.slice(0, 100), creator: user, updater: user } as any)\n }\n return (await itemsOf([card], context))[0]\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => DashboardPlaceItem, { description: \"Places a card one may use at the end of one's dashboard.\" })\n async placeDashboardCard(@Arg('cardId') cardId: string, @Ctx() context: ResolverContext): Promise<DashboardPlaceItem> {\n const { tx } = context.state as any\n const { card } = await usableCard(cardId, context, tx)\n const place = await placeAtEnd(card.id, context, tx)\n return { id: place.id, order: place.order, width: place.width, height: place.height, card: (await itemsOf([card], context))[0] }\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Takes a card off one's dashboard - the card stays in the library.\" })\n async removeDashboardPlace(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state as any\n const place = await getRepository(DashboardCardPlace, tx).findOne({ where: { id, domain: { id: domain.id }, user: { id: user.id } } as any })\n if (!place) refuse(context, 'unknown-place', 'that card is not on your dashboard.')\n await getRepository(DashboardCardPlace, tx).softRemove(place)\n return true\n }\n\n @Directive(MUTATION)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: \"Sets the order and size of the cards on one's dashboard.\" })\n async arrangeDashboard(@Arg('places', type => [DashboardPlaceInput]) places: DashboardPlaceInput[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state as any\n const repository = getRepository(DashboardCardPlace, tx)\n const mine = await repository.find({ where: { domain: { id: domain.id }, user: { id: user.id } } as any })\n for (const given of places ?? []) {\n const place = mine.find(one => one.id === given.id)\n if (!place) refuse(context, 'unknown-place', 'that card is not on your dashboard.')\n if (!(given.width >= 1 && given.width <= MAX_WIDTH && given.height >= 1 && given.height <= MAX_HEIGHT)) refuse(context, 'size-out-of-range', 'a card spans 1 to 4 columns and 1 to 2 rows.')\n await repository.save({ ...place, order: given.order, width: given.width, height: given.height, updater: user } as any)\n }\n return true\n }\n}\n\n/** The conversation's messages that carry proposals, oldest first. */\nasync function proposalMessages(sessionId: string, tx?: any): Promise<{ proposals: any[] }[]> {\n const carrying = await getRepository(ChatMessage, tx).find({\n select: ['id', 'proposals', 'createdAt'] as any,\n where: { session: { id: sessionId } as any, proposals: Not(IsNull()) } as any,\n order: { createdAt: 'ASC' } as any\n })\n return carrying.map((message: any) => ({ proposals: message.proposalsJson ?? [] }))\n}\n\nexport { CARD_SCHEMA_VERSION }\n"]}
@@ -99,9 +99,11 @@ const cardInDomain = (context) => async (id) => {
99
99
  return card ? { ownerId: card.ownerId, version: card.version } : undefined;
100
100
  };
101
101
  async function proposeDashboardCard(args, context, deps = {}) {
102
- const name = typeof args?.name === 'string' ? args.name.trim().slice(0, 100) : '';
102
+ const name = typeof args?.name === 'string' ? args.name.trim() : '';
103
103
  if (!name)
104
104
  return { rejected: true, error: 'no-name', message: 'give the card a short name in the person\'s language.' };
105
+ if (name.length > card_names_js_1.CARD_NAME_MAX)
106
+ return { rejected: true, error: 'name-too-long', message: `the card name has ${name.length} characters - give one of at most ${card_names_js_1.CARD_NAME_MAX} and call again now.` };
105
107
  const where = withoutEmpty(args?.source?.where);
106
108
  const rows = withoutEmpty(args?.rows);
107
109
  /* One value, or the list `in` and `not_in` take - kept as the match's value either way. */
@@ -1 +1 @@
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,MAAM,CAAC,GAAG;QAChB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,kHAAkH;QAClH,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,uEAAuE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzG,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,E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,CAAC;IACjC,WAAW,EAAE,0HAA0H;IACvI,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;IACnI,OAAO,EAAE,CAAC,IAAS,EAAE,OAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;CAC3D,CAAA;AAEA,QAAA,YAAY,GAAiB;IACxC,IAAI,EAAE,6BAAa;IACnB,WAAW,EAAE,sFAAsF;IACnG,QAAQ,EAAE;QACR,2KAA2K,yBAAS,kFAAkF;QACtQ,4MAA4M;QAC5M,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 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"]}
1
+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IACzB,KAAK,EAAE,CAAC,wBAAwB,CAAC;IACjC,WAAW,EAAE,0HAA0H;IACvI,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;IACnI,OAAO,EAAE,CAAC,IAAS,EAAE,OAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;CAC3D,CAAA;AAEA,QAAA,YAAY,GAAiB;IACxC,IAAI,EAAE,6BAAa;IACnB,WAAW,EAAE,sFAAsF;IACnG,QAAQ,EAAE;QACR,2KAA2K,yBAAS,kFAAkF;QACtQ,4MAA4M;QAC5M,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_NAME_MAX, 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() : ''\n if (!name) return { rejected: true, error: 'no-name', message: 'give the card a short name in the person\\'s language.' }\n if (name.length > CARD_NAME_MAX) return { rejected: true, error: 'name-too-long', message: `the card name has ${name.length} characters - give one of at most ${CARD_NAME_MAX} and call again now.` }\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"]}