@things-factory/worklist 10.1.243 → 10.1.245

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.
Files changed (37) hide show
  1. package/dist-client/activity-state-counts.d.ts +6 -0
  2. package/dist-client/activity-state-counts.js +23 -0
  3. package/dist-client/activity-state-counts.js.map +1 -0
  4. package/dist-client/chip-counts.d.ts +7 -0
  5. package/dist-client/chip-counts.js +11 -0
  6. package/dist-client/chip-counts.js.map +1 -0
  7. package/dist-client/chip-filters.d.ts +7 -0
  8. package/dist-client/chip-filters.js +42 -0
  9. package/dist-client/chip-filters.js.map +1 -1
  10. package/dist-client/pages/activity/activity-list-page.d.ts +2 -0
  11. package/dist-client/pages/activity/activity-list-page.js +11 -1
  12. package/dist-client/pages/activity/activity-list-page.js.map +1 -1
  13. package/dist-client/pages/todo/approval-done-list-page.d.ts +4 -0
  14. package/dist-client/pages/todo/approval-done-list-page.js +21 -10
  15. package/dist-client/pages/todo/approval-done-list-page.js.map +1 -1
  16. package/dist-client/pages/todo/approval-pending-list-page.d.ts +4 -0
  17. package/dist-client/pages/todo/approval-pending-list-page.js +21 -13
  18. package/dist-client/pages/todo/approval-pending-list-page.js.map +1 -1
  19. package/dist-client/pages/todo/done-list-calendar-page.d.ts +5 -1
  20. package/dist-client/pages/todo/done-list-calendar-page.js +33 -52
  21. package/dist-client/pages/todo/done-list-calendar-page.js.map +1 -1
  22. package/dist-client/pages/todo/pickable-list-page.d.ts +4 -0
  23. package/dist-client/pages/todo/pickable-list-page.js +21 -10
  24. package/dist-client/pages/todo/pickable-list-page.js.map +1 -1
  25. package/dist-client/pages/todo/todo-list-page.d.ts +4 -0
  26. package/dist-client/pages/todo/todo-list-page.js +20 -21
  27. package/dist-client/pages/todo/todo-list-page.js.map +1 -1
  28. package/dist-client/tsconfig.tsbuildinfo +1 -1
  29. package/dist-client/work-calendar-sources.d.ts +7 -2
  30. package/dist-client/work-calendar-sources.js +15 -6
  31. package/dist-client/work-calendar-sources.js.map +1 -1
  32. package/dist-server/service/activity/activity-query.d.ts +2 -1
  33. package/dist-server/service/activity/activity-query.js +22 -1
  34. package/dist-server/service/activity/activity-query.js.map +1 -1
  35. package/dist-server/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +13 -12
  37. package/tests/open-doors.test.ts +3 -2
@@ -4,7 +4,8 @@
4
4
  * 「내 업무 달력」 answers "what must I do on which day". The to-dos and approvals are worklist's own; a meeting I am
5
5
  * called to, a day my leave starts, are other modules' facts on the same day. A product registers a source for each:
6
6
  * it reads only the caller's own entries, through doors of its own, and says where an entry opens. worklist places
7
- * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it.
7
+ * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it, with
8
+ * how many it has on the days drawn.
8
9
  *
9
10
  * A source that fails is said as such on the calendar - never read as a day with nothing on it.
10
11
  */
@@ -75,9 +76,13 @@ export declare function applyingSources(sources: WorkCalendarSource[]): Promise<
75
76
  /**
76
77
  * Every source asked apart, for one window: one that fails leaves the others' entries, and `failed` names it - a
77
78
  * calendar that read nothing from a source must not look like a week with nothing in it.
79
+ *
80
+ * `counts` is how many each source has in the window, its chip on or off - what its chip says pressing it would show;
81
+ * `entries` leaves out the sources in `hidden`. A source that failed has no count.
78
82
  */
79
- export declare function loadWorkCalendar(loads: [key: string, entries: Promise<WorkCalendarEntry[]>][]): Promise<{
83
+ export declare function loadWorkCalendar(loads: [key: string, entries: Promise<WorkCalendarEntry[]>][], hidden?: ReadonlySet<string>): Promise<{
80
84
  entries: WorkCalendarEntry[];
85
+ counts: Map<string, number>;
81
86
  failed: string[];
82
87
  }>;
83
88
  /**
@@ -4,7 +4,8 @@
4
4
  * 「내 업무 달력」 answers "what must I do on which day". The to-dos and approvals are worklist's own; a meeting I am
5
5
  * called to, a day my leave starts, are other modules' facts on the same day. A product registers a source for each:
6
6
  * it reads only the caller's own entries, through doors of its own, and says where an entry opens. worklist places
7
- * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it.
7
+ * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it, with
8
+ * how many it has on the days drawn.
8
9
  *
9
10
  * A source that fails is said as such on the calendar - never read as a day with nothing on it.
10
11
  */
@@ -49,20 +50,28 @@ export async function applyingSources(sources) {
49
50
  /**
50
51
  * Every source asked apart, for one window: one that fails leaves the others' entries, and `failed` names it - a
51
52
  * calendar that read nothing from a source must not look like a week with nothing in it.
53
+ *
54
+ * `counts` is how many each source has in the window, its chip on or off - what its chip says pressing it would show;
55
+ * `entries` leaves out the sources in `hidden`. A source that failed has no count.
52
56
  */
53
- export async function loadWorkCalendar(loads) {
57
+ export async function loadWorkCalendar(loads, hidden = new Set()) {
54
58
  const entries = [];
59
+ const counts = new Map();
55
60
  const failed = [];
56
61
  const outcomes = await Promise.allSettled(loads.map(([, load]) => load));
57
62
  outcomes.forEach((outcome, index) => {
58
- if (outcome.status === 'fulfilled')
59
- entries.push(...outcome.value);
63
+ const key = loads[index][0];
64
+ if (outcome.status === 'fulfilled') {
65
+ counts.set(key, outcome.value.length);
66
+ if (!hidden.has(key))
67
+ entries.push(...outcome.value);
68
+ }
60
69
  else {
61
- failed.push(loads[index][0]);
70
+ failed.push(key);
62
71
  console.error(outcome.reason);
63
72
  }
64
73
  });
65
- return { entries, failed };
74
+ return { entries, counts, failed };
66
75
  }
67
76
  /**
68
77
  * One day's entries in the order they are drawn, cut to the limit **after** ordering: what is to be done that day
@@ -1 +1 @@
1
- {"version":3,"file":"work-calendar-sources.js","sourceRoot":"","sources":["../client/work-calendar-sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA+CH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,iFAAiF;CAChF,CAAA;AAEV,mCAAmC;AACnC,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,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,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;IACtI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACtC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;AAC1D,CAAC","sourcesContent":["/**\n * What else a person's work calendar shows — **the calendar is worklist's, what goes on it is not all worklist's.**\n *\n * 「내 업무 달력」 answers \"what must I do on which day\". The to-dos and approvals are worklist's own; a meeting I am\n * called to, a day my leave starts, are other modules' facts on the same day. A product registers a source for each:\n * it reads only the caller's own entries, through doors of its own, and says where an entry opens. worklist places\n * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it.\n *\n * A source that fails is said as such on the calendar - never read as a day with nothing on it.\n */\n\nexport interface WorkCalendarEntry {\n /** Unique within its source. */\n id: string\n /** What the entry is, in a line. */\n name: string\n /** When it falls - its time is shown, its day places it. */\n date: string | Date\n /**\n * 0 - to act on that day (a due item, a meeting, my own leave) · 1 - arrived that day · 2 - over (done, cancelled) ·\n * 3 - someone else's day (a colleague on leave): after everything of one's own, so a department's leave never pushes\n * one's own work past the day's limit.\n */\n rank: 0 | 1 | 2 | 3\n /** 0..3, the most urgent last - the colour of the entry. */\n priority?: number\n /** Material Symbols name drawn before it. */\n icon?: string\n /** Where it opens - none when the person may not open it; the entry is then shown, not linked. */\n href?: string\n /** What the entry's place means, for the tooltip - 「due this day」, 「meeting at 09:00」. */\n note?: string\n /** The whole day - a day of leave, a payday: no time is drawn, as none was ever set. */\n allDay?: boolean\n}\n\nexport interface WorkCalendarSource {\n /** Unique - a second registration with the same key replaces the first. */\n key: string\n /** What its filter chip says, in the reader's language - asked each time it is drawn. */\n label(): string\n /**\n * Whether the source has anything for this person at all - a department's leave for one who heads none does not.\n * Asked once when the calendar opens; a source that does not apply gets no chip. Left out, it applies.\n */\n applies?(): Promise<boolean>\n /** The caller's own entries that fall in [from, to). */\n load(from: Date, to: Date): Promise<WorkCalendarEntry[]>\n /**\n * The days in [from, to) that are not worked - weekends, holidays, days off - as local `YYYY-MM-DD`. The calendar\n * paints their cells, whether or not the source's chip is on: they are the frame the day is read through, not an\n * entry in it. Left out, the source paints nothing.\n */\n nonWorkingDays?(from: Date, to: Date): Promise<string[]>\n}\n\n/**\n * A day not worked is painted as the plant calendar paints it - one token, so every calendar of the suite shows a\n * day off alike (@operato/event-view DayState).\n */\nexport const NON_WORKING_DAY_STATE = {\n name: 'non-working',\n color: 'var(--calendar-day-state-non-working-background-color, rgba(168, 48, 110, 0.1))'\n} as const\n\n/** `YYYY-MM-DD` of a local day. */\nexport function localDayOf(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/** The grid's days that are not worked, keyed by the very Date objects the calendar drew. */\nexport function nonWorkingStates(days: readonly { date: Date }[], notWorked: ReadonlySet<string>): Map<Date, typeof NON_WORKING_DAY_STATE> {\n const states = new Map<Date, typeof NON_WORKING_DAY_STATE>()\n for (const { date } of days) if (notWorked.has(localDayOf(date))) states.set(date, NON_WORKING_DAY_STATE)\n return states\n}\n\nconst SOURCES = new Map<string, WorkCalendarSource>()\n\nexport function registerWorkCalendarSource(source: WorkCalendarSource): void {\n SOURCES.set(source.key, source)\n}\n\nexport function workCalendarSources(): WorkCalendarSource[] {\n return [...SOURCES.values()]\n}\n\n/**\n * The sources that have anything for this person - asked apart, so one that cannot answer is kept: its chip then says\n * it was not read, rather than the calendar dropping it as if it had nothing.\n */\nexport async function applyingSources(sources: WorkCalendarSource[]): Promise<WorkCalendarSource[]> {\n const answers = await Promise.allSettled(sources.map(source => (source.applies ? source.applies() : Promise.resolve(true))))\n return sources.filter((_, index) => {\n const answer = answers[index]\n return answer.status === 'rejected' || answer.value\n })\n}\n\n/**\n * Every source asked apart, for one window: one that fails leaves the others' entries, and `failed` names it - a\n * calendar that read nothing from a source must not look like a week with nothing in it.\n */\nexport async function loadWorkCalendar(loads: [key: string, entries: Promise<WorkCalendarEntry[]>][]): Promise<{ entries: WorkCalendarEntry[]; failed: string[] }> {\n const entries: WorkCalendarEntry[] = []\n const failed: string[] = []\n const outcomes = await Promise.allSettled(loads.map(([, load]) => load))\n outcomes.forEach((outcome, index) => {\n if (outcome.status === 'fulfilled') entries.push(...outcome.value)\n else {\n failed.push(loads[index][0])\n console.error(outcome.reason)\n }\n })\n return { entries, failed }\n}\n\n/**\n * One day's entries in the order they are drawn, cut to the limit **after** ordering: what is to be done that day\n * first, then what arrived that day, then what is over; within each the more urgent, then the earlier. `hidden` is\n * how many the limit left out - said as a number, never as more rows.\n */\nexport function entriesOfDay(entries: WorkCalendarEntry[], localDay: string, limit: number) {\n const ofTheDay = entries\n .filter(entry => new Date(entry.date).toLocaleDateString() == localDay)\n .sort((a, b) => a.rank - b.rank || (b.priority || 0) - (a.priority || 0) || new Date(a.date).getTime() - new Date(b.date).getTime())\n const shown = ofTheDay.slice(0, limit)\n return { shown, hidden: ofTheDay.length - shown.length }\n}\n"]}
1
+ {"version":3,"file":"work-calendar-sources.js","sourceRoot":"","sources":["../client/work-calendar-sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA+CH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,iFAAiF;CAChF,CAAA;AAEV,mCAAmC;AACnC,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,C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AAC,KAAK,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,IAAI,QAAQ,CAAC;SACtE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;IACtI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACtC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;AAC1D,CAAC","sourcesContent":["/**\n * What else a person's work calendar shows — **the calendar is worklist's, what goes on it is not all worklist's.**\n *\n * 「내 업무 달력」 answers \"what must I do on which day\". The to-dos and approvals are worklist's own; a meeting I am\n * called to, a day my leave starts, are other modules' facts on the same day. A product registers a source for each:\n * it reads only the caller's own entries, through doors of its own, and says where an entry opens. worklist places\n * them with its own on the grid, in one order, under one per-day limit, and gives each a chip to show or hide it, with\n * how many it has on the days drawn.\n *\n * A source that fails is said as such on the calendar - never read as a day with nothing on it.\n */\n\nexport interface WorkCalendarEntry {\n /** Unique within its source. */\n id: string\n /** What the entry is, in a line. */\n name: string\n /** When it falls - its time is shown, its day places it. */\n date: string | Date\n /**\n * 0 - to act on that day (a due item, a meeting, my own leave) · 1 - arrived that day · 2 - over (done, cancelled) ·\n * 3 - someone else's day (a colleague on leave): after everything of one's own, so a department's leave never pushes\n * one's own work past the day's limit.\n */\n rank: 0 | 1 | 2 | 3\n /** 0..3, the most urgent last - the colour of the entry. */\n priority?: number\n /** Material Symbols name drawn before it. */\n icon?: string\n /** Where it opens - none when the person may not open it; the entry is then shown, not linked. */\n href?: string\n /** What the entry's place means, for the tooltip - 「due this day」, 「meeting at 09:00」. */\n note?: string\n /** The whole day - a day of leave, a payday: no time is drawn, as none was ever set. */\n allDay?: boolean\n}\n\nexport interface WorkCalendarSource {\n /** Unique - a second registration with the same key replaces the first. */\n key: string\n /** What its filter chip says, in the reader's language - asked each time it is drawn. */\n label(): string\n /**\n * Whether the source has anything for this person at all - a department's leave for one who heads none does not.\n * Asked once when the calendar opens; a source that does not apply gets no chip. Left out, it applies.\n */\n applies?(): Promise<boolean>\n /** The caller's own entries that fall in [from, to). */\n load(from: Date, to: Date): Promise<WorkCalendarEntry[]>\n /**\n * The days in [from, to) that are not worked - weekends, holidays, days off - as local `YYYY-MM-DD`. The calendar\n * paints their cells, whether or not the source's chip is on: they are the frame the day is read through, not an\n * entry in it. Left out, the source paints nothing.\n */\n nonWorkingDays?(from: Date, to: Date): Promise<string[]>\n}\n\n/**\n * A day not worked is painted as the plant calendar paints it - one token, so every calendar of the suite shows a\n * day off alike (@operato/event-view DayState).\n */\nexport const NON_WORKING_DAY_STATE = {\n name: 'non-working',\n color: 'var(--calendar-day-state-non-working-background-color, rgba(168, 48, 110, 0.1))'\n} as const\n\n/** `YYYY-MM-DD` of a local day. */\nexport function localDayOf(date: Date): string {\n return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\n/** The grid's days that are not worked, keyed by the very Date objects the calendar drew. */\nexport function nonWorkingStates(days: readonly { date: Date }[], notWorked: ReadonlySet<string>): Map<Date, typeof NON_WORKING_DAY_STATE> {\n const states = new Map<Date, typeof NON_WORKING_DAY_STATE>()\n for (const { date } of days) if (notWorked.has(localDayOf(date))) states.set(date, NON_WORKING_DAY_STATE)\n return states\n}\n\nconst SOURCES = new Map<string, WorkCalendarSource>()\n\nexport function registerWorkCalendarSource(source: WorkCalendarSource): void {\n SOURCES.set(source.key, source)\n}\n\nexport function workCalendarSources(): WorkCalendarSource[] {\n return [...SOURCES.values()]\n}\n\n/**\n * The sources that have anything for this person - asked apart, so one that cannot answer is kept: its chip then says\n * it was not read, rather than the calendar dropping it as if it had nothing.\n */\nexport async function applyingSources(sources: WorkCalendarSource[]): Promise<WorkCalendarSource[]> {\n const answers = await Promise.allSettled(sources.map(source => (source.applies ? source.applies() : Promise.resolve(true))))\n return sources.filter((_, index) => {\n const answer = answers[index]\n return answer.status === 'rejected' || answer.value\n })\n}\n\n/**\n * Every source asked apart, for one window: one that fails leaves the others' entries, and `failed` names it - a\n * calendar that read nothing from a source must not look like a week with nothing in it.\n *\n * `counts` is how many each source has in the window, its chip on or off - what its chip says pressing it would show;\n * `entries` leaves out the sources in `hidden`. A source that failed has no count.\n */\nexport async function loadWorkCalendar(\n loads: [key: string, entries: Promise<WorkCalendarEntry[]>][],\n hidden: ReadonlySet<string> = new Set()\n): Promise<{ entries: WorkCalendarEntry[]; counts: Map<string, number>; failed: string[] }> {\n const entries: WorkCalendarEntry[] = []\n const counts = new Map<string, number>()\n const failed: string[] = []\n const outcomes = await Promise.allSettled(loads.map(([, load]) => load))\n outcomes.forEach((outcome, index) => {\n const key = loads[index][0]\n if (outcome.status === 'fulfilled') {\n counts.set(key, outcome.value.length)\n if (!hidden.has(key)) entries.push(...outcome.value)\n } else {\n failed.push(key)\n console.error(outcome.reason)\n }\n })\n return { entries, counts, failed }\n}\n\n/**\n * One day's entries in the order they are drawn, cut to the limit **after** ordering: what is to be done that day\n * first, then what arrived that day, then what is over; within each the more urgent, then the earlier. `hidden` is\n * how many the limit left out - said as a number, never as more rows.\n */\nexport function entriesOfDay(entries: WorkCalendarEntry[], localDay: string, limit: number) {\n const ofTheDay = entries\n .filter(entry => new Date(entry.date).toLocaleDateString() == localDay)\n .sort((a, b) => a.rank - b.rank || (b.priority || 0) - (a.priority || 0) || new Date(a.date).getTime() - new Date(b.date).getTime())\n const shown = ofTheDay.slice(0, limit)\n return { shown, hidden: ofTheDay.length - shown.length }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Role, User } from '@things-factory/auth-base';
2
- import { Domain, ListParam } from '@things-factory/shell';
2
+ import { Domain, ListParam, ListValueCount } from '@things-factory/shell';
3
3
  import { ApprovalLineItem } from '@things-factory/organization';
4
4
  import { Activity, AssigneeItem } from './activity.js';
5
5
  import { ActivityList } from './activity-type.js';
@@ -7,6 +7,7 @@ export declare class ActivityQuery {
7
7
  activity(id: string, context: ResolverContext): Promise<Activity>;
8
8
  activityByName(name: string, context: ResolverContext): Promise<Activity>;
9
9
  activities(params: ListParam, context: ResolverContext): Promise<ActivityList>;
10
+ activityStateCounts(params: ListParam, context: ResolverContext): Promise<ListValueCount[]>;
10
11
  startableActivities(params: ListParam, context: ResolverContext): Promise<ActivityList>;
11
12
  supervisableActivities(params: ListParam, context: ResolverContext): Promise<ActivityList>;
12
13
  /** The key `label` is translated from. Computed from `name`, never stored — see activityTKey. */
@@ -13,6 +13,8 @@ const approval_line_seats_js_1 = require("./approval-line-seats.js");
13
13
  const activity_js_1 = require("./activity.js");
14
14
  const activity_type_js_1 = require("./activity-type.js");
15
15
  const decision_key_declaration_js_1 = require("./decision-key-declaration.js");
16
+ /** What the activity lists find activities by, and their state counts alike. */
17
+ const ACTIVITY_SEARCHABLES = ['name', 'description', 'issuerRole', 'supervisoryRole'];
16
18
  let ActivityQuery = class ActivityQuery {
17
19
  async activity(id, context) {
18
20
  const { domain } = context.state;
@@ -33,11 +35,22 @@ let ActivityQuery = class ActivityQuery {
33
35
  params,
34
36
  repository: (0, shell_1.getRepository)(activity_js_1.Activity),
35
37
  alias: 'activity',
36
- searchables: ['name', 'description', 'issuerRole', 'supervisoryRole']
38
+ searchables: ACTIVITY_SEARCHABLES
37
39
  });
38
40
  const [items, total] = await queryBuilder.getManyAndCount();
39
41
  return { items, total };
40
42
  }
43
+ async activityStateCounts(params, context) {
44
+ const counted = await (0, shell_1.countListByField)({
45
+ domain: context.state.domain,
46
+ params,
47
+ repository: (0, shell_1.getRepository)(activity_js_1.Activity),
48
+ alias: 'activity',
49
+ searchables: ACTIVITY_SEARCHABLES,
50
+ field: 'state'
51
+ });
52
+ return Object.values(activity_js_1.ActivityStatus).map(value => ({ value, count: counted.get(value) ?? 0 }));
53
+ }
41
54
  async startableActivities(params, context) {
42
55
  var { domain, user } = context.state;
43
56
  /* 조회한 사용자가 assigner 역할을 가진 activity-instance 리스트만 반환 */
@@ -195,6 +208,14 @@ tslib_1.__decorate([
195
208
  tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
196
209
  tslib_1.__metadata("design:returntype", Promise)
197
210
  ], ActivityQuery.prototype, "activities", null);
211
+ tslib_1.__decorate([
212
+ (0, type_graphql_1.Query)(returns => [shell_1.ListValueCount], { description: 'How many activities hold each state (draft, released, deprecated), under the list conditions other than the state' }),
213
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
214
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
215
+ tslib_1.__metadata("design:type", Function),
216
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
217
+ tslib_1.__metadata("design:returntype", Promise)
218
+ ], ActivityQuery.prototype, "activityStateCounts", null);
198
219
  tslib_1.__decorate([
199
220
  (0, type_graphql_1.Query)(returns => activity_type_js_1.ActivityList, { description: 'To fetch the list of activities I can start' }),
200
221
  tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
@@ -1 +1 @@
1
- {"version":3,"file":"activity-query.js","sourceRoot":"","sources":["../../../server/service/activity/activity-query.ts"],"names":[],"mappings":";;;;AAAA,qCAA4B;AAC5B,+CAAmF;AACnF,qCAAkC;AAElC,qEAA4D;AAC5D,yDAAsD;AACtD,iDAAuG;AACvG,+DAA+D;AAC/D,qEAA4D;AAE5D,+CAA4F;AAC5F,yDAAiD;AACjD,+EAA4D;AAGrD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAElB,AAAN,KAAK,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cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;2CAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;4CAEvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;4CAEvC;wBAvNU,aAAa;IADzB,IAAA,uBAAQ,EAAC,sBAAQ,CAAC;GACN,aAAa,CAwNzB","sourcesContent":["import { In } from 'typeorm'\nimport { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Brackets } from 'typeorm'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Role, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { ApprovalLineItem } from '@things-factory/organization'\nimport { approvalLineSeats } from './approval-line-seats.js'\n\nimport { Activity, ActivityStartingType, ActivityStatus, AssigneeItem } from './activity.js'\nimport { ActivityList } from './activity-type.js'\nimport { activityTKey } from './decision-key-declaration.js'\n\n@Resolver(Activity)\nexport class ActivityQuery {\n @Query(returns => Activity!, { nullable: true, description: 'To fetch a Activity' })\n async activity(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Activity> {\n const { domain } = context.state\n\n return await getRepository(Activity).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id }\n })\n }\n\n @Query(returns => Activity!, { nullable: true, description: 'To fetch a Activity by name' })\n async activityByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Activity> {\n const { domain } = context.state\n\n return await getRepository(Activity).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, name }\n })\n }\n\n @Query(returns => ActivityList, { description: 'To fetch multiple Activities' })\n async activities(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Activity),\n alias: 'activity',\n searchables: ['name', 'description', 'issuerRole', 'supervisoryRole']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => ActivityList, { description: 'To fetch the list of activities I can start' })\n async startableActivities(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ActivityList> {\n var { domain, user } = context.state\n\n /* 조회한 사용자가 assigner 역할을 가진 activity-instance 리스트만 반환 */\n user = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)\n\n const [items, total] = await getQueryBuilderFromListParams({\n repository: getRepository(Activity),\n params,\n domain,\n alias: 'activity',\n searchables: ['name', 'description']\n })\n .andWhere(`activity.startingType IN (:...startingTypes)`, {\n startingTypes: [ActivityStartingType.Issue, ActivityStartingType.Post]\n })\n .andWhere(`activity.state = :state`, { state: ActivityStatus.Released })\n .andWhere(\n roles.length > 0\n ? new Brackets(qb => {\n qb.orWhere(`activity.issuerRole IN (:...roles)`, { roles })\n qb.orWhere(`activity.issuerRole IS NULL`)\n })\n : `activity.issuerRole IS NULL`\n )\n .getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => ActivityList, { description: 'To fetch the list of activities that I can report on' })\n async supervisableActivities(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ActivityList> {\n var { domain, user } = context.state\n\n /* 조회한 사용자가 assigner 역할을 가진 activity-instance 리스트만 반환 */\n user = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)\n\n if (!roles.length) {\n return { items: [], total: 0 }\n }\n\n const [items, total] = await getQueryBuilderFromListParams({\n repository: getRepository(Activity),\n params,\n domain,\n alias: 'activity',\n searchables: ['name', 'description']\n })\n .andWhere(`activity.supervisoryRole IN (:...roles)`, { roles })\n .getManyAndCount()\n\n return { items, total }\n }\n\n /** The key `label` is translated from. Computed from `name`, never stored — see activityTKey. */\n @FieldResolver(type => String, { description: 'i18n key the label is translated from, computed from name' })\n labelTKey(@Root() activity: Activity): string {\n return activityTKey(activity.name, 'label')\n }\n\n @FieldResolver(type => Role)\n async issuerRole(@Root() activity: Activity): Promise<Role> {\n return (\n activity.issuerRole ||\n (activity.issuerRoleId &&\n (await getRepository(Role).findOneBy({\n id: activity.issuerRoleId\n })))\n )\n }\n\n @FieldResolver(type => [Role])\n async assigneeRoles(@Root() activity: Activity): Promise<Role[]> {\n if (activity.assigneeRoles) return activity.assigneeRoles\n if (activity.assigneeRoleIds && !activity.assigneeRoleIds.length) return []\n\n return await getRepository(Activity).createQueryBuilder().relation(Activity, 'assigneeRoles').of(activity.id).loadMany()\n }\n\n @FieldResolver(type => [AssigneeItem])\n async assignees(@Root() activity: Activity, @Ctx() context: ResolverContext): Promise<AssigneeItem[]> {\n const { domain, user } = context.state\n const { assignees } = activity\n\n if (!assignees || !(assignees instanceof Array)) {\n return null\n }\n\n var assigneeItemList = []\n\n for (let item of assignees) {\n // \"value\" deprecated. to be removed\n var { type, assignee, value } = item\n var id = assignee?.id || id\n\n switch (type) {\n case 'Employee':\n assignee = id && (await getRepository('Employee').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Department':\n assignee = id && (await getRepository('Department').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Role':\n assignee = id && (await getRepository('Role').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Myself':\n assignee = user\n break\n case 'MyDepartment':\n case 'MySupervisor':\n break\n default:\n }\n\n id ? assigneeItemList.push({ type, assignee }) : assigneeItemList.push({ type })\n }\n\n return assigneeItemList\n }\n\n @FieldResolver(type => [ApprovalLineItem])\n async approvalLine(@Root() activity: Activity, @Ctx() context: ResolverContext): Promise<ApprovalLineItem[]> {\n const { domain, user } = context.state\n\n return await approvalLineSeats(activity.approvalLine, domain, user)\n }\n\n @FieldResolver(type => Role)\n async supervisoryRole(@Root() activity: Activity): Promise<Role> {\n return (\n activity.supervisoryRole ||\n (activity.supervisoryRoleId &&\n (await getRepository(Role).findOneBy({\n id: activity.supervisoryRoleId\n })))\n )\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() activity: Activity): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: activity.domainId },\n refType: Activity.name,\n refBy: activity.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() activity: Activity): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: activity.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() activity: Activity): Promise<User> {\n return await getRepository(User).findOneBy({ id: activity.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() activity: Activity): Promise<User> {\n return await getRepository(User).findOneBy({ id: activity.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"activity-query.js","sourceRoot":"","sources":["../../../server/service/activity/activity-query.ts"],"names":[],"mappings":";;;;AAAA,qCAA4B;AAC5B,+CAAmF;AACnF,qCAAkC;AAElC,qEAA4D;AAC5D,yDAAsD;AACtD,iDAAyI;AACzI,+DAA+D;AAC/D,qEAA4D;AAE5D,+CAA4F;AAC5F,yDAAiD;AACjD,+EAA4D;AAE5D,gFAAgF;AAChF,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAA;AAG9E,IAAM,aAAa,GAAnB,MAAM,aAAa;IAElB,AAAN,KAAK,CAAC,QAAQ,CAAY,EAAU,EAAS,OAAwB;QACnE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,sBAAQ,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mBAAI,GAAE,CAAA;IAAsB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAhB,sBAAQ;;8CAsCzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAgB,CAAC,CAAC;IACtB,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAsB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAhB,sBAAQ;;iDAI5C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACL,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;oDAQ/C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;8CAUzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;2CAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;4CAEvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,sBAAQ;;4CAEvC;wBApOU,aAAa;IADzB,IAAA,uBAAQ,EAAC,sBAAQ,CAAC;GACN,aAAa,CAqOzB","sourcesContent":["import { In } from 'typeorm'\nimport { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Brackets } from 'typeorm'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Role, User } from '@things-factory/auth-base'\nimport { countListByField, Domain, getQueryBuilderFromListParams, getRepository, ListParam, ListValueCount } from '@things-factory/shell'\nimport { ApprovalLineItem } from '@things-factory/organization'\nimport { approvalLineSeats } from './approval-line-seats.js'\n\nimport { Activity, ActivityStartingType, ActivityStatus, AssigneeItem } from './activity.js'\nimport { ActivityList } from './activity-type.js'\nimport { activityTKey } from './decision-key-declaration.js'\n\n/** What the activity lists find activities by, and their state counts alike. */\nconst ACTIVITY_SEARCHABLES = ['name', 'description', 'issuerRole', 'supervisoryRole']\n\n@Resolver(Activity)\nexport class ActivityQuery {\n @Query(returns => Activity!, { nullable: true, description: 'To fetch a Activity' })\n async activity(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Activity> {\n const { domain } = context.state\n\n return await getRepository(Activity).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id }\n })\n }\n\n @Query(returns => Activity!, { nullable: true, description: 'To fetch a Activity by name' })\n async activityByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Activity> {\n const { domain } = context.state\n\n return await getRepository(Activity).findOne({\n where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, name }\n })\n }\n\n @Query(returns => ActivityList, { description: 'To fetch multiple Activities' })\n async activities(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ActivityList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Activity),\n alias: 'activity',\n searchables: ACTIVITY_SEARCHABLES\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => [ListValueCount], { description: 'How many activities hold each state (draft, released, deprecated), under the list conditions other than the state' })\n async activityStateCounts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ListValueCount[]> {\n const counted = await countListByField({\n domain: context.state.domain,\n params,\n repository: getRepository(Activity),\n alias: 'activity',\n searchables: ACTIVITY_SEARCHABLES,\n field: 'state'\n })\n return Object.values(ActivityStatus).map(value => ({ value, count: counted.get(value) ?? 0 }))\n }\n\n @Query(returns => ActivityList, { description: 'To fetch the list of activities I can start' })\n async startableActivities(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ActivityList> {\n var { domain, user } = context.state\n\n /* 조회한 사용자가 assigner 역할을 가진 activity-instance 리스트만 반환 */\n user = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)\n\n const [items, total] = await getQueryBuilderFromListParams({\n repository: getRepository(Activity),\n params,\n domain,\n alias: 'activity',\n searchables: ['name', 'description']\n })\n .andWhere(`activity.startingType IN (:...startingTypes)`, {\n startingTypes: [ActivityStartingType.Issue, ActivityStartingType.Post]\n })\n .andWhere(`activity.state = :state`, { state: ActivityStatus.Released })\n .andWhere(\n roles.length > 0\n ? new Brackets(qb => {\n qb.orWhere(`activity.issuerRole IN (:...roles)`, { roles })\n qb.orWhere(`activity.issuerRole IS NULL`)\n })\n : `activity.issuerRole IS NULL`\n )\n .getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => ActivityList, { description: 'To fetch the list of activities that I can report on' })\n async supervisableActivities(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ActivityList> {\n var { domain, user } = context.state\n\n /* 조회한 사용자가 assigner 역할을 가진 activity-instance 리스트만 반환 */\n user = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)\n\n if (!roles.length) {\n return { items: [], total: 0 }\n }\n\n const [items, total] = await getQueryBuilderFromListParams({\n repository: getRepository(Activity),\n params,\n domain,\n alias: 'activity',\n searchables: ['name', 'description']\n })\n .andWhere(`activity.supervisoryRole IN (:...roles)`, { roles })\n .getManyAndCount()\n\n return { items, total }\n }\n\n /** The key `label` is translated from. Computed from `name`, never stored — see activityTKey. */\n @FieldResolver(type => String, { description: 'i18n key the label is translated from, computed from name' })\n labelTKey(@Root() activity: Activity): string {\n return activityTKey(activity.name, 'label')\n }\n\n @FieldResolver(type => Role)\n async issuerRole(@Root() activity: Activity): Promise<Role> {\n return (\n activity.issuerRole ||\n (activity.issuerRoleId &&\n (await getRepository(Role).findOneBy({\n id: activity.issuerRoleId\n })))\n )\n }\n\n @FieldResolver(type => [Role])\n async assigneeRoles(@Root() activity: Activity): Promise<Role[]> {\n if (activity.assigneeRoles) return activity.assigneeRoles\n if (activity.assigneeRoleIds && !activity.assigneeRoleIds.length) return []\n\n return await getRepository(Activity).createQueryBuilder().relation(Activity, 'assigneeRoles').of(activity.id).loadMany()\n }\n\n @FieldResolver(type => [AssigneeItem])\n async assignees(@Root() activity: Activity, @Ctx() context: ResolverContext): Promise<AssigneeItem[]> {\n const { domain, user } = context.state\n const { assignees } = activity\n\n if (!assignees || !(assignees instanceof Array)) {\n return null\n }\n\n var assigneeItemList = []\n\n for (let item of assignees) {\n // \"value\" deprecated. to be removed\n var { type, assignee, value } = item\n var id = assignee?.id || id\n\n switch (type) {\n case 'Employee':\n assignee = id && (await getRepository('Employee').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Department':\n assignee = id && (await getRepository('Department').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Role':\n assignee = id && (await getRepository('Role').findOneBy({ domain: { id: domain.id }, id }))\n break\n case 'Myself':\n assignee = user\n break\n case 'MyDepartment':\n case 'MySupervisor':\n break\n default:\n }\n\n id ? assigneeItemList.push({ type, assignee }) : assigneeItemList.push({ type })\n }\n\n return assigneeItemList\n }\n\n @FieldResolver(type => [ApprovalLineItem])\n async approvalLine(@Root() activity: Activity, @Ctx() context: ResolverContext): Promise<ApprovalLineItem[]> {\n const { domain, user } = context.state\n\n return await approvalLineSeats(activity.approvalLine, domain, user)\n }\n\n @FieldResolver(type => Role)\n async supervisoryRole(@Root() activity: Activity): Promise<Role> {\n return (\n activity.supervisoryRole ||\n (activity.supervisoryRoleId &&\n (await getRepository(Role).findOneBy({\n id: activity.supervisoryRoleId\n })))\n )\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() activity: Activity): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: activity.domainId },\n refType: Activity.name,\n refBy: activity.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() activity: Activity): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: activity.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() activity: Activity): Promise<User> {\n return await getRepository(User).findOneBy({ id: activity.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() activity: Activity): Promise<User> {\n return await getRepository(User).findOneBy({ id: activity.creatorId })\n }\n}\n"]}