@aiquants/daily-report 0.20.0 → 0.21.0

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 (116) hide show
  1. package/README.md +229 -8
  2. package/dist/client.d.mts +201 -739
  3. package/dist/client.d.ts +201 -739
  4. package/dist/client.js +5 -6
  5. package/dist/client.mjs +5 -6
  6. package/dist/index.d.mts +5 -197
  7. package/dist/index.d.ts +5 -197
  8. package/dist/index.js +1 -2
  9. package/dist/index.mjs +1 -2
  10. package/dist/logger-D3krZrNK.d.mts +0 -14
  11. package/dist/logger-D3krZrNK.d.ts +0 -14
  12. package/dist/server.d.mts +114 -744
  13. package/dist/server.d.ts +114 -744
  14. package/dist/server.js +1 -2
  15. package/dist/server.mjs +1 -2
  16. package/dist/{sse-schema-ChSFm-4q.d.mts → sse-schema-DCxpdETM.d.mts} +1106 -1090
  17. package/dist/{sse-schema-BdUGThiz.d.ts → sse-schema-DoQw8_om.d.ts} +1106 -1090
  18. package/dist/types-CqgYQgbH.d.mts +0 -34
  19. package/dist/types-CqgYQgbH.d.ts +0 -34
  20. package/package.json +9 -10
  21. package/dist/client.js.map +0 -1
  22. package/dist/client.mjs.map +0 -1
  23. package/dist/index.js.map +0 -1
  24. package/dist/index.mjs.map +0 -1
  25. package/dist/server.js.map +0 -1
  26. package/dist/server.mjs.map +0 -1
  27. package/src/client/components/business-day-thumb-overlay.tsx +0 -19
  28. package/src/client/components/daily-report-attachment-indicator.spec.tsx +0 -51
  29. package/src/client/components/daily-report-attachment-indicator.tsx +0 -45
  30. package/src/client/components/daily-report-attachment-list.spec.tsx +0 -94
  31. package/src/client/components/daily-report-attachment-list.tsx +0 -112
  32. package/src/client/components/daily-report-comment-item.tsx +0 -89
  33. package/src/client/components/daily-report-comment-section.tsx +0 -166
  34. package/src/client/components/daily-report-detail-list.tsx +0 -842
  35. package/src/client/components/daily-report-edit-form.tsx +0 -87
  36. package/src/client/components/daily-report-ids-stream-status.spec.tsx +0 -93
  37. package/src/client/components/daily-report-ids-stream-status.tsx +0 -67
  38. package/src/client/components/daily-report-list.tsx +0 -1232
  39. package/src/client/components/daily-report-page.spec.tsx +0 -119
  40. package/src/client/components/daily-report-page.tsx +0 -140
  41. package/src/client/components/daily-report-resize-panels.spec.tsx +0 -307
  42. package/src/client/components/daily-report-resolved-content.tsx +0 -207
  43. package/src/client/components/daily-report-scroll-restoration.spec.tsx +0 -422
  44. package/src/client/components/report-views.spec.tsx +0 -375
  45. package/src/client/components/unread-indicator.tsx +0 -13
  46. package/src/client/config-context.tsx +0 -184
  47. package/src/client/contexts/daily-report-action-context.spec.tsx +0 -433
  48. package/src/client/contexts/daily-report-action-context.tsx +0 -1147
  49. package/src/client/contexts/daily-report-error-context.spec.tsx +0 -66
  50. package/src/client/contexts/daily-report-error-context.tsx +0 -98
  51. package/src/client/hooks/use-animated-number.spec.ts +0 -103
  52. package/src/client/hooks/use-animated-number.ts +0 -69
  53. package/src/client/hooks/use-daily-report-comments.ts +0 -73
  54. package/src/client/hooks/use-daily-report-sse-connection.ts +0 -86
  55. package/src/client/hooks/use-daily-report.spec.ts +0 -546
  56. package/src/client/hooks/use-daily-report.ts +0 -549
  57. package/src/client/hooks/use-dynamic-viewport-height.ts +0 -127
  58. package/src/client/hooks/use-responsive-layout.spec.ts +0 -74
  59. package/src/client/hooks/use-responsive-layout.ts +0 -63
  60. package/src/client/route-helpers.spec.ts +0 -100
  61. package/src/client/route-helpers.ts +0 -61
  62. package/src/client/streaming/daily-report-ids-stream-client.spec.ts +0 -910
  63. package/src/client/streaming/daily-report-ids-stream-client.ts +0 -730
  64. package/src/client/streaming/daily-report-ids-stream-session.spec.ts +0 -401
  65. package/src/client/streaming/daily-report-ids-stream-session.ts +0 -319
  66. package/src/client/ui/button.tsx +0 -42
  67. package/src/client/ui/cn.ts +0 -14
  68. package/src/client/ui/input.tsx +0 -21
  69. package/src/client/ui/label.tsx +0 -16
  70. package/src/client/ui/switch.tsx +0 -19
  71. package/src/client/ui/tabs.tsx +0 -40
  72. package/src/client/ui/textarea.tsx +0 -19
  73. package/src/client/utils/constants.spec.ts +0 -96
  74. package/src/client/utils/constants.ts +0 -84
  75. package/src/client.ts +0 -28
  76. package/src/index.ts +0 -11
  77. package/src/lucide-icons.d.ts +0 -6
  78. package/src/server/authz.spec.ts +0 -57
  79. package/src/server/authz.ts +0 -99
  80. package/src/server/cache.spec.ts +0 -556
  81. package/src/server/cache.ts +0 -303
  82. package/src/server/etag.ts +0 -18
  83. package/src/server/external-source.ts +0 -60
  84. package/src/server/handlers.action.spec.ts +0 -44
  85. package/src/server/handlers.attachment.spec.ts +0 -470
  86. package/src/server/handlers.ids-stream.spec.ts +0 -618
  87. package/src/server/handlers.ts +0 -1638
  88. package/src/server/handlers.unauthorized-cookie.spec.ts +0 -187
  89. package/src/server/handlers.visibility.spec.ts +0 -774
  90. package/src/server/ports.ts +0 -222
  91. package/src/server/response.ts +0 -37
  92. package/src/server/schema.spec.ts +0 -30
  93. package/src/server/schema.ts +0 -344
  94. package/src/server/service.spec.ts +0 -1130
  95. package/src/server/service.ts +0 -2045
  96. package/src/server/sse-reader.spec.ts +0 -302
  97. package/src/server/sse-reader.ts +0 -267
  98. package/src/server/test-helpers/handlers-config.ts +0 -321
  99. package/src/server/transaction-retry.spec.ts +0 -63
  100. package/src/server/visibility.spec.ts +0 -403
  101. package/src/server/visibility.ts +0 -373
  102. package/src/server.spec.ts +0 -160
  103. package/src/server.ts +0 -131
  104. package/src/shared/business-date.spec.ts +0 -82
  105. package/src/shared/business-date.ts +0 -104
  106. package/src/shared/comment-adapter.spec.ts +0 -38
  107. package/src/shared/comment-adapter.ts +0 -80
  108. package/src/shared/ids-stream.spec.ts +0 -154
  109. package/src/shared/ids-stream.ts +0 -279
  110. package/src/shared/logger.ts +0 -47
  111. package/src/shared/sse-schema.spec.ts +0 -50
  112. package/src/shared/sse-schema.ts +0 -198
  113. package/src/shared/text-utils.spec.ts +0 -42
  114. package/src/shared/text-utils.ts +0 -65
  115. package/src/shared/types.ts +0 -109
  116. package/src/styles/standalone.entry.css +0 -51
@@ -1,84 +0,0 @@
1
- import { type ScrollBarTapCircleOptions, type ScrollPaneInertiaOptions, tapScrollCircleSampleVisual } from "@aiquants/virtualscroll"
2
- import type { DailyReportItem } from "../../shared/types"
3
- import type { DailyReportDetailResource } from "../hooks/use-daily-report"
4
-
5
- /**
6
- * Shared constants for Daily Report data fetching parameters.
7
- * 日報データ取得で利用する共通パラメーター。
8
- */
9
- export const DAILY_REPORT_FETCH_DEBOUNCE_MS = 120
10
-
11
- /**
12
- * Delay before the provider auto-connects SSE, freeing a browser connection slot for first paint.
13
- * SSE を自動接続するまでの遅延。初回描画とその中身フェッチへ接続枠を譲るための猶予。
14
- *
15
- * HTTP/1.1 のオリジン当たり 6 接続のうち、ids ストリームと SSE で 2 枠を常時占有する。
16
- * SSE 接続を初回描画直後まで遅らせ、その 1 枠を初回の中身フェッチ (`/business-date`) に回す。
17
- * リアルタイム更新の初動がこの分だけ遅れるが、その間の状態はストリーム / SWR が担保する。
18
- */
19
- export const SSE_INITIAL_CONNECT_DEFER_MS = 1000
20
-
21
- export const DEFAULT_ITEM_HEIGHT = 160
22
- export const ITEM_VERTICAL_PADDING = 6
23
- export const ITEM_CONTAINER_HEIGHT = DEFAULT_ITEM_HEIGHT - ITEM_VERTICAL_PADDING
24
- export const FAST_SCROLL_WHEEL_MULTIPLIER = 0.8
25
- export const FAST_SCROLL_INERTIA_OPTIONS: ScrollPaneInertiaOptions = { maxVelocity: 18, deceleration: 0.0018, startVelocityThreshold: 0.03 }
26
- export const PREFETCH_LOOKAHEAD = 20
27
- export const PREFETCH_MAX_DATES = 6
28
- export const EMPTY_ITEM: DailyReportItem = { reportHubId: -1, businessDate: null }
29
- export const EMPTY_DETAIL: DailyReportDetailResource = { report: null, error: null, isLoading: false, isRefetching: false }
30
- export const WHEEL_RESET_TIMEOUT_MS = 240
31
- export const VIRTUAL_SCROLL_OVERSCAN_COUNT = 15
32
- export const SCROLL_BAR_WIDTH = 8
33
- export const MAX_PREVIEW_LINES = 3
34
-
35
- /**
36
- * Tap-scroll circle tuning shared by every daily-report list.
37
- * 日報のすべての一覧が共有するタップスクロールサークルの調整値。
38
- *
39
- * ❗ **List タブと DetailList タブで同じ値を使うこと。** 片方だけ独自定義にすると、
40
- * 同じ指の位置でタブごとに速度が何十倍も違う (実測で最大 77 倍) という事故になる。
41
- *
42
- * 値の根拠 (ビューポート 800px で実測):
43
- *
44
- * | 引き距離 | 速度 | List (行 160px) |
45
- * | --- | --- | --- |
46
- * | 0 | 160 px/s | 1 行/秒 |
47
- * | 1/4 | 525 px/s | 3.3 行/秒 |
48
- * | 1/2 | 1,298 px/s | 8 行/秒 |
49
- * | 最大 | 6,400 px/s | 40 行/秒 (0.67 行/フレーム) |
50
- *
51
- * - `exponentialSteepness: 3` — 引き幅の前半をゆっくりにして微速の分解能を確保する。
52
- * 大きくしすぎると低速域が最小速度へ張り付いて**引いても動かない死角**になる
53
- * (旧値 7.5 では引き幅の 43.85% が死角だった)。
54
- * - `exponentialScale: 8` — 最高速の上限 (ビューポート比)。`maxSpeedMultiplier` と揃えて
55
- * 上限がどちらで決まるかを一意にする。1 フレームあたりの移動をオーバースキャン
56
- * (`VIRTUAL_SCROLL_OVERSCAN_COUNT`) の行数より十分小さく保つ値にすること。
57
- * - `easedOffset` は使わない。最小速度 160 px/s で十分に遅く、下駄を履かせると
58
- * 低速域の分解能がその分だけ失われる。
59
- *
60
- * 長距離の移動はタップスクロールではなくスクロールバーのつまみ (と
61
- * `BusinessDayThumbOverlay` の日付表示) が担う。ここを速くして解こうとしない。
62
- */
63
- export const TAP_SCROLL_CIRCLE_OPTIONS: ScrollBarTapCircleOptions = {
64
- enabled: true,
65
- renderVisual: tapScrollCircleSampleVisual,
66
- maxSpeedCurve: { exponentialSteepness: 3, exponentialScale: 8 },
67
- maxSpeedMultiplier: 8,
68
- }
69
-
70
- /**
71
- * Pointer types allowed to drag-scroll the list content.
72
- * 一覧のコンテンツ領域をドラッグしてスクロールできるポインタ種別。
73
- *
74
- * ❗ **`enablePointerDrag` を丸ごと切ってはならない。** `ScrollPane` はコンテンツを
75
- * transform で動かしておりネイティブのスクロール領域を持たない
76
- * (`.aqvs-scroll-pane-content` は `overflow: hidden`) ため、切るとタッチ端末から
77
- * スクロール手段が消える (一度そうしてしまい、モバイルで一切スクロールできなくなった)。
78
- *
79
- * マウスのドラッグだけを外す。行のタップ判定 (`useTapClick`) ・テキスト選択と競合するため。
80
- * 画面幅のメディアクエリで切り替える案は採らなかった。画面幅は入力手段を表さないので
81
- * 「主入力がマウスのタッチ対応ノート」のような端末を取りこぼす。判定は**イベントの
82
- * ポインタ種別**で行うため、同一端末でマウスと指を使い分けても常に正しく振る舞う。
83
- */
84
- export const CONTENT_DRAG_POINTER_INPUTS = ["pen", "touch"] as const
package/src/client.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Client entry of @aiquants/daily-report: React components, hooks, and route helpers.
3
- * @aiquants/daily-report の client エントリ。React コンポーネント・フック・ルートヘルパーを公開。
4
- */
5
- export * from "./client/components/business-day-thumb-overlay"
6
- export * from "./client/components/daily-report-attachment-indicator"
7
- export * from "./client/components/daily-report-attachment-list"
8
- export * from "./client/components/daily-report-comment-item"
9
- export * from "./client/components/daily-report-comment-section"
10
- export * from "./client/components/daily-report-detail-list"
11
- export * from "./client/components/daily-report-edit-form"
12
- export * from "./client/components/daily-report-ids-stream-status"
13
- export * from "./client/components/daily-report-list"
14
- export * from "./client/components/daily-report-page"
15
- export * from "./client/components/daily-report-resolved-content"
16
- export * from "./client/components/unread-indicator"
17
- export * from "./client/config-context"
18
- export * from "./client/contexts/daily-report-action-context"
19
- export * from "./client/contexts/daily-report-error-context"
20
- export * from "./client/hooks/use-animated-number"
21
- export * from "./client/hooks/use-daily-report"
22
- export * from "./client/hooks/use-daily-report-comments"
23
- export * from "./client/hooks/use-daily-report-sse-connection"
24
- export * from "./client/hooks/use-dynamic-viewport-height"
25
- export * from "./client/route-helpers"
26
- export * from "./client/streaming/daily-report-ids-stream-client"
27
- export * from "./client/streaming/daily-report-ids-stream-session"
28
- export * from "./client/utils/constants"
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Shared (isomorphic) entry of @aiquants/daily-report: types, SSE schemas, and pure utilities.
3
- * @aiquants/daily-report の共有 (isomorphic) エントリ。型・SSE スキーマ・純粋ユーティリティを公開。
4
- */
5
- export * from "./shared/business-date"
6
- export * from "./shared/comment-adapter"
7
- export * from "./shared/ids-stream"
8
- export * from "./shared/logger"
9
- export * from "./shared/sse-schema"
10
- export * from "./shared/text-utils"
11
- export * from "./shared/types"
@@ -1,6 +0,0 @@
1
- declare module "lucide-react/dist/esm/icons/*" {
2
- import type { LucideIcon } from "lucide-react"
3
-
4
- const component: LucideIcon
5
- export default component
6
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Unit tests for defineDailyReportAuthzResources & seedDailyReportAuthzResources in @aiquants/daily-report/server.
3
- */
4
- import { describe, expect, it } from "vitest"
5
- import { defineDailyReportAuthzResources, seedDailyReportAuthzResources } from "./authz"
6
-
7
- describe("defineDailyReportAuthzResources", () => {
8
- it("generates neutral default resources when no sources specified", () => {
9
- const res = defineDailyReportAuthzResources()
10
- expect(res).toHaveLength(4) // internal + internal_comment + external + external_comment
11
- expect(res[0].resourceKey).toBe("daily_report_internal")
12
- expect(res[1].resourceKey).toBe("daily_report_internal_comment")
13
- })
14
-
15
- it("generates custom resources from source inputs without domain hardcoding", () => {
16
- const res = defineDailyReportAuthzResources([
17
- { key: "ORG", name: "Original", description: "Original daily reports" },
18
- { key: "NI", name: "NI", description: "NI daily reports", includeCommentResource: false },
19
- ])
20
- expect(res).toHaveLength(3) // ORG + ORG_comment + NI (no comment)
21
- expect(res[0].resourceKey).toBe("daily_report_org")
22
- expect(res[1].resourceKey).toBe("daily_report_org_comment")
23
- expect(res[2].resourceKey).toBe("daily_report_ni")
24
- })
25
- })
26
-
27
- describe("seedDailyReportAuthzResources", () => {
28
- it("idempotently seeds resources into TMResource table", async () => {
29
- const seeded: Record<string, unknown>[] = []
30
-
31
- const fakeDb = {
32
- select: () => ({
33
- from: () => ({
34
- where: async () => [],
35
- }),
36
- }),
37
- insert: () => ({
38
- values: async (v: unknown) => {
39
- seeded.push(v as Record<string, unknown>)
40
- },
41
- }),
42
- }
43
-
44
- const fakeAuthzTables = {
45
- TMResource: { appKey: "appKey", resourceKey: "resourceKey" },
46
- }
47
-
48
- await seedDailyReportAuthzResources(fakeDb, fakeAuthzTables, {
49
- appKey: "quants",
50
- sources: [{ key: "sales", name: "Sales" }],
51
- })
52
-
53
- expect(seeded.length).toBe(2)
54
- expect(seeded[0].appKey).toBe("quants")
55
- expect(seeded[0].resourceKey).toBe("daily_report_sales")
56
- })
57
- })
@@ -1,99 +0,0 @@
1
- /**
2
- * Authz helper utilities for @aiquants/daily-report: standard resource definitions & auto-seeding.
3
- * @aiquants/daily-report 用の認可ヘルパー。標準リソース定義および自動シード機能を提供。
4
- */
5
- import { and, eq } from "drizzle-orm"
6
-
7
- export type AuthzResourceItem = {
8
- resourceKey: string
9
- name: string
10
- description?: string | null
11
- }
12
-
13
- export type DailyReportSourceTypeInput = {
14
- key: string
15
- name: string
16
- description?: string | null
17
- includeCommentResource?: boolean
18
- }
19
-
20
- /**
21
- * Dynamically builds neutral Authz resource definitions from provided source type inputs.
22
- * 指定されたソース種別定義から中立な認可リソース定義リストを生成するファクトリ。
23
- */
24
- export function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[] {
25
- const list: AuthzResourceItem[] = []
26
- const targetSources =
27
- sources && sources.length > 0
28
- ? sources
29
- : [
30
- { key: "internal", name: "Internal", description: "Internal daily reports" },
31
- { key: "external", name: "External", description: "External daily reports" },
32
- ]
33
-
34
- for (const src of targetSources) {
35
- const keyLower = src.key.toLowerCase().replace(/[^a-z0-9_]/g, "_")
36
- const resourceKey = `daily_report_${keyLower}`
37
- list.push({
38
- resourceKey,
39
- name: src.name,
40
- description: src.description ?? `${src.name} daily report access`,
41
- })
42
-
43
- if (src.includeCommentResource !== false) {
44
- list.push({
45
- resourceKey: `${resourceKey}_comment`,
46
- name: `${src.name} Comment`,
47
- description: `${src.name} daily report comment access`,
48
- })
49
- }
50
- }
51
-
52
- return list
53
- }
54
-
55
- type DbSelectChain = {
56
- from(t: unknown): DbSelectChain
57
- where(cond: unknown): PromiseLike<unknown[]>
58
- }
59
- type DbInsertChain = {
60
- values(v: unknown): PromiseLike<unknown>
61
- }
62
- type LooseDb = {
63
- select(fields?: unknown): DbSelectChain
64
- insert(t: unknown): DbInsertChain
65
- }
66
-
67
- /**
68
- * Ensures all daily-report standard resources exist in the authz TMResource table idempotently.
69
- * authz データベース内に日報機能の標準認可リソースが存在することを自動保証(冪等シード)する処理。
70
- */
71
- export async function seedDailyReportAuthzResources(db: unknown, authzTables: { TMResource: unknown }, opts: { appKey: string; actor?: string; sources?: DailyReportSourceTypeInput[]; resources?: AuthzResourceItem[] }): Promise<void> {
72
- const d = db as LooseDb
73
- const TMResource = authzTables.TMResource as Record<string, unknown>
74
- const appKey = opts.appKey
75
- const actor = opts.actor ?? "system:daily-report"
76
- const now = new Date()
77
-
78
- const resourceList = opts.resources ?? defineDailyReportAuthzResources(opts.sources)
79
-
80
- for (const res of resourceList) {
81
- const existing = await d
82
- .select()
83
- .from(TMResource)
84
- .where(and(eq(TMResource.appKey as never, appKey as never), eq(TMResource.resourceKey as never, res.resourceKey as never)))
85
-
86
- if (!existing || existing.length === 0) {
87
- await d.insert(TMResource).values({
88
- appKey,
89
- resourceKey: res.resourceKey,
90
- name: res.name,
91
- description: res.description ?? null,
92
- createdAt: now,
93
- createdBy: actor,
94
- updatedAt: now,
95
- updatedBy: actor,
96
- })
97
- }
98
- }
99
- }