@things-factory/help 10.1.298 → 10.1.302

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A period a guide runs in. `via: 'invitation'` gives days, YYYY-MM-DD, its end day included; `'announcement'` gives
3
+ * instants, ISO. No start runs from always; no end runs on.
4
+ */
5
+ export type GuidePeriod = {
6
+ guideId: string;
7
+ via: string;
8
+ startsAt?: string | null;
9
+ endsAt?: string | null;
10
+ };
11
+ /** 운영 중 - a period holds now · 운영 예정 - one starts later · 운영 종료 - all are past. */
12
+ export type GuideRunState = 'running' | 'upcoming' | 'ended';
13
+ /** A guide's state and the period it shows: the one running, else the next to start, else the last to end. */
14
+ export type GuideRun = {
15
+ state: GuideRunState;
16
+ startsOn?: string;
17
+ endsOn?: string;
18
+ };
19
+ /** What the module that carries guides calls at load. Registering again replaces it. */
20
+ export declare function registerGuidePeriods(read: () => Promise<GuidePeriod[]>): void;
21
+ /** The periods, or none when no module carries guides - or the reader is refused. */
22
+ export declare function guidePeriods(): Promise<GuidePeriod[]>;
23
+ /** Each guide's run, keyed by guide id; a guide with no period has none. Pure. */
24
+ export declare function guideRuns(periods: readonly GuidePeriod[], now?: number): Map<string, GuideRun>;
@@ -0,0 +1,48 @@
1
+ /*
2
+ * When a guide runs - the guide list's state (ADR-0212 amendment 2). help does not know what carries a guide to its
3
+ * people; a module that does (announcement - its on-screen offers and the announcements carrying a guide) registers
4
+ * where to read the periods, and the list says whether each guide runs now.
5
+ */
6
+ let reader;
7
+ /** What the module that carries guides calls at load. Registering again replaces it. */
8
+ export function registerGuidePeriods(read) {
9
+ reader = read;
10
+ }
11
+ /** The periods, or none when no module carries guides - or the reader is refused. */
12
+ export async function guidePeriods() {
13
+ try {
14
+ return reader ? await reader() : [];
15
+ }
16
+ catch {
17
+ return [];
18
+ }
19
+ }
20
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
21
+ const dayOf = (instant) => new Intl.DateTimeFormat('en-CA').format(new Date(instant));
22
+ const localMidnight = (day) => new Date(`${day}T00:00:00`).getTime();
23
+ /** A period as instants on the viewer's clock - a day runs from its midnight to the next. */
24
+ function span(period) {
25
+ const start = !period.startsAt ? -Infinity : DAY.test(period.startsAt) ? localMidnight(period.startsAt) : new Date(period.startsAt).getTime();
26
+ const end = !period.endsAt ? Infinity : DAY.test(period.endsAt) ? localMidnight(period.endsAt) + 86_400_000 : new Date(period.endsAt).getTime();
27
+ return { start, end };
28
+ }
29
+ /** Each guide's run, keyed by guide id; a guide with no period has none. Pure. */
30
+ export function guideRuns(periods, now = Date.now()) {
31
+ const byGuide = new Map();
32
+ for (const period of periods)
33
+ byGuide.set(period.guideId, [...(byGuide.get(period.guideId) ?? []), span(period)]);
34
+ const runs = new Map();
35
+ for (const [guideId, spans] of byGuide) {
36
+ const running = spans.filter(one => one.start <= now && now < one.end).sort((a, b) => b.end - a.end)[0];
37
+ const upcoming = spans.filter(one => one.start > now).sort((a, b) => a.start - b.start)[0];
38
+ const ended = [...spans].sort((a, b) => b.end - a.end)[0];
39
+ const [state, shown] = running ? ['running', running] : upcoming ? ['upcoming', upcoming] : ['ended', ended];
40
+ runs.set(guideId, {
41
+ state,
42
+ startsOn: Number.isFinite(shown.start) ? dayOf(shown.start) : undefined,
43
+ endsOn: Number.isFinite(shown.end) ? dayOf(shown.end - 1) : undefined
44
+ });
45
+ }
46
+ return runs;
47
+ }
48
+ //# sourceMappingURL=guide-periods.js.map
@@ -4,3 +4,4 @@ export { brokenSteps, type GuideItem, type GuideStep } from './guide/guide-progr
4
4
  export { registerGuideFinisher, startGuide, stopGuide, guideRunning, offerGuide, GUIDE_STARTED, GUIDE_STOPPED, type GuideFinisher, type GuideOrigin, type GuideStarted, type GuideStopped } from './guide/guide-runner.js';
5
5
  export { registerGuideEditorSection, type GuideEditorSection } from './guide/guide-editor-sections.js';
6
6
  export { guideApi, type GuideRow } from './guide/guide-api.js';
7
+ export { registerGuidePeriods, guideRuns, type GuidePeriod, type GuideRun, type GuideRunState } from './guide/guide-periods.js';
@@ -4,4 +4,5 @@ export { brokenSteps } from './guide/guide-progress.js';
4
4
  export { registerGuideFinisher, startGuide, stopGuide, guideRunning, offerGuide, GUIDE_STARTED, GUIDE_STOPPED } from './guide/guide-runner.js';
5
5
  export { registerGuideEditorSection } from './guide/guide-editor-sections.js';
6
6
  export { guideApi } from './guide/guide-api.js';
7
+ export { registerGuidePeriods, guideRuns } from './guide/guide-periods.js';
7
8
  //# sourceMappingURL=index.js.map
@@ -3,7 +3,7 @@ import { PageView } from '@operato/shell';
3
3
  declare const GuideList_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
4
4
  /**
5
5
  * 화면 안내 — the guides of the domain for their writers (ADR-0212 decision 7). A row opens in the editor; an
6
- * announcement carries one to its people.
6
+ * announcement or an on-screen offer carries one to its people, and the row says whether it runs now (amendment 2).
7
7
  */
8
8
  export declare class GuideList extends GuideList_base {
9
9
  static styles: import("lit").CSSResult[];
@@ -28,6 +28,9 @@ export declare class GuideList extends GuideList_base {
28
28
  fetchHandler(): Promise<{
29
29
  total: number;
30
30
  records: {
31
+ runState: string;
32
+ runStartsOn: string;
33
+ runEndsOn: string;
31
34
  stepCount: number;
32
35
  conditionLabel: string;
33
36
  id: string;
@@ -8,10 +8,11 @@ import { navigate, PageView } from '@operato/shell';
8
8
  import { CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
9
9
  import { isMobileDevice } from '@operato/utils';
10
10
  import { guideApi } from '../guide/guide-api.js';
11
+ import { guidePeriods, guideRuns } from '../guide/guide-periods.js';
11
12
  import { t } from '../guide/guide-words.js';
12
13
  /**
13
14
  * 화면 안내 — the guides of the domain for their writers (ADR-0212 decision 7). A row opens in the editor; an
14
- * announcement carries one to its people.
15
+ * announcement or an on-screen offer carries one to its people, and the row says whether it runs now (amendment 2).
15
16
  */
16
17
  let GuideList = class GuideList extends localize(i18next)(PageView) {
17
18
  static { this.styles = [WorkSurfacePageStyles, CommonGristStyles, ScrollbarStyles]; }
@@ -36,9 +37,14 @@ let GuideList = class GuideList extends localize(i18next)(PageView) {
36
37
  rows: { appendable: false, selectable: false, handlers: { click: (_c, _d, _col, record) => record?.id && navigate(`guide-editor?id=${record.id}`) } },
37
38
  pagination: { infinite: true },
38
39
  emptyNote: { title: t('guide.text.list-empty'), description: t('guide.text.list-empty-description') },
39
- list: { fields: ['name', 'opening'], details: ['stepCount', 'conditionLabel'] },
40
+ list: { fields: ['name', 'runState'], details: ['runStartsOn', 'runEndsOn', 'conditionLabel'] },
40
41
  columns: [
41
42
  readonly('string', 'name', t('guide.field.name'), 240),
43
+ readonly('string', 'runState', t('guide.field.run-state'), 100, {
44
+ record: { renderer: (value) => (value ? value === 'running' ? html `<strong style="color: var(--ui-accent, var(--md-sys-color-primary))">${t('guide.text.run-running')}</strong>` : t(`guide.text.run-${value}`) : '') }
45
+ }),
46
+ readonly('string', 'runStartsOn', t('guide.field.run-starts-on'), 110),
47
+ readonly('string', 'runEndsOn', t('guide.field.run-ends-on'), 110),
42
48
  readonly('string', 'opening', t('guide.field.opening'), 360),
43
49
  readonly('integer', 'stepCount', t('guide.field.step-count'), 80, { record: { align: 'right' } }),
44
50
  readonly('string', 'conditionLabel', t('guide.field.condition'), 280),
@@ -49,10 +55,14 @@ let GuideList = class GuideList extends localize(i18next)(PageView) {
49
55
  };
50
56
  }
51
57
  async fetchHandler() {
52
- const [rows, conditions] = await Promise.all([guideApi.list(), guideApi.conditions()]);
58
+ const [rows, conditions, periods] = await Promise.all([guideApi.list(), guideApi.conditions(), guidePeriods()]);
53
59
  const labels = new Map(conditions.map(one => [one.id, one.label]));
60
+ const runs = guideRuns(periods);
54
61
  const records = rows.map(row => ({
55
62
  ...row,
63
+ runState: runs.get(row.id)?.state ?? '',
64
+ runStartsOn: runs.get(row.id)?.startsOn ?? '',
65
+ runEndsOn: runs.get(row.id)?.endsOn ?? '',
56
66
  stepCount: row.steps?.length ?? 0,
57
67
  conditionLabel: row.condition ? (labels.get(row.condition) ?? row.condition) : t('guide.text.no-condition')
58
68
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/help",
3
- "version": "10.1.298",
3
+ "version": "10.1.302",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -55,11 +55,11 @@
55
55
  "@operato/shell": "^10.29.69",
56
56
  "@operato/styles": "^10.29.1",
57
57
  "@operato/utils": "^10.0.0",
58
- "@things-factory/auth-base": "^10.1.298",
59
- "@things-factory/shell": "^10.1.298",
58
+ "@things-factory/auth-base": "^10.1.302",
59
+ "@things-factory/shell": "^10.1.302",
60
60
  "graphql-scalars": "^1.22.0",
61
61
  "graphql-tag": "^2.12.6",
62
62
  "lit": "^3.1.2"
63
63
  },
64
- "gitHead": "5b5dce33c891a02896ef3a9cb3974abefc3f53d6"
64
+ "gitHead": "2e754aaeafcd39f5c6f4b7c8847a6c60ffe0789c"
65
65
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "The screen guide cannot be found.",
74
74
  "task.guide.writing.name": "Screen guides - writing",
75
75
  "task.guide.writing.description": "Records, writes, changes and deletes screen guides.",
76
- "guide.text.finished": "Guide finished."
76
+ "guide.text.finished": "Guide finished.",
77
+ "guide.field.run-state": "State",
78
+ "guide.field.run-starts-on": "Starts",
79
+ "guide.field.run-ends-on": "Ends",
80
+ "guide.text.run-running": "Running",
81
+ "guide.text.run-upcoming": "Upcoming",
82
+ "guide.text.run-ended": "Ended"
77
83
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "No se encuentra la guía de pantalla.",
74
74
  "task.guide.writing.name": "Guías de pantalla - redacción",
75
75
  "task.guide.writing.description": "Graba, redacta, modifica y elimina guías de pantalla.",
76
- "guide.text.finished": "Guía terminada."
76
+ "guide.text.finished": "Guía terminada.",
77
+ "guide.field.run-state": "Estado",
78
+ "guide.field.run-starts-on": "Inicio",
79
+ "guide.field.run-ends-on": "Fin",
80
+ "guide.text.run-running": "En curso",
81
+ "guide.text.run-upcoming": "Programada",
82
+ "guide.text.run-ended": "Finalizada"
77
83
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "画面ガイドが見つかりません。",
74
74
  "task.guide.writing.name": "画面ガイドの作成",
75
75
  "task.guide.writing.description": "画面ガイドを録画・作成・変更・削除できます。",
76
- "guide.text.finished": "ガイドを終えました。"
76
+ "guide.text.finished": "ガイドを終えました。",
77
+ "guide.field.run-state": "状態",
78
+ "guide.field.run-starts-on": "開始日",
79
+ "guide.field.run-ends-on": "終了日",
80
+ "guide.text.run-running": "運用中",
81
+ "guide.text.run-upcoming": "運用予定",
82
+ "guide.text.run-ended": "運用終了"
77
83
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "화면 안내를 찾을 수 없습니다.",
74
74
  "task.guide.writing.name": "화면 안내 작성",
75
75
  "task.guide.writing.description": "화면 안내를 녹화·작성·수정·삭제할 수 있습니다.",
76
- "guide.text.finished": "안내를 마쳤습니다."
76
+ "guide.text.finished": "안내를 마쳤습니다.",
77
+ "guide.field.run-state": "상태",
78
+ "guide.field.run-starts-on": "시작일",
79
+ "guide.field.run-ends-on": "종료일",
80
+ "guide.text.run-running": "운영 중",
81
+ "guide.text.run-upcoming": "운영 예정",
82
+ "guide.text.run-ended": "운영 종료"
77
83
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "Panduan skrin tidak ditemui.",
74
74
  "task.guide.writing.name": "Panduan skrin - penulisan",
75
75
  "task.guide.writing.description": "Merakam, menulis, mengubah dan memadam panduan skrin.",
76
- "guide.text.finished": "Panduan selesai."
76
+ "guide.text.finished": "Panduan selesai.",
77
+ "guide.field.run-state": "Status",
78
+ "guide.field.run-starts-on": "Mula",
79
+ "guide.field.run-ends-on": "Tamat",
80
+ "guide.text.run-running": "Sedang berjalan",
81
+ "guide.text.run-upcoming": "Dijadualkan",
82
+ "guide.text.run-ended": "Tamat"
77
83
  }
@@ -73,5 +73,11 @@
73
73
  "guide.refusal.unknown-guide": "找不到界面引导。",
74
74
  "task.guide.writing.name": "编写界面引导",
75
75
  "task.guide.writing.description": "可以录制、编写、修改和删除界面引导。",
76
- "guide.text.finished": "引导已结束。"
76
+ "guide.text.finished": "引导已结束。",
77
+ "guide.field.run-state": "状态",
78
+ "guide.field.run-starts-on": "开始日期",
79
+ "guide.field.run-ends-on": "结束日期",
80
+ "guide.text.run-running": "运行中",
81
+ "guide.text.run-upcoming": "计划运行",
82
+ "guide.text.run-ended": "已结束"
77
83
  }