@enlt-bakusoku/nuxt4 0.0.0-stage → 2.1.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 (86) hide show
  1. package/README.md +38 -2
  2. package/dist/module.d.mts +25 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +208 -0
  5. package/dist/runtime/shared/schemas/user.d.ts +40 -0
  6. package/dist/runtime/shared/schemas/user.js +21 -0
  7. package/dist/runtime/tasks-catalog.d.ts +6 -0
  8. package/dist/runtime/tasks-catalog.js +7 -0
  9. package/dist/types.d.mts +9 -0
  10. package/package.json +120 -3
  11. package/scripts/bakusoku-dev.mjs +387 -0
  12. package/scripts/dev-log-relay.mjs +96 -0
  13. package/scripts/predeploy.mjs +24 -0
  14. package/scripts/prepare-firebase-artifact.mjs +43 -0
  15. package/scripts/setup-worktree.sh +59 -0
  16. package/scripts/verify-firebase-artifacts.mjs +70 -0
  17. package/src/layer/app/components/admin/AdminExecutionHistory.vue +137 -0
  18. package/src/layer/app/components/admin/TaskRunDialog.vue +162 -0
  19. package/src/layer/app/components/admin/UserManagementPage.vue +342 -0
  20. package/src/layer/app/components/debug/DebugApplicationLogs.vue +87 -0
  21. package/src/layer/app/components/debug/DebugErrorLogs.vue +47 -0
  22. package/src/layer/app/components/debug/DebugFirestoreOperations.vue +48 -0
  23. package/src/layer/app/components/debug/DebugHttpRequests.vue +86 -0
  24. package/src/layer/app/components/debug/DebugNavigation.vue +60 -0
  25. package/src/layer/app/components/debug/DebugNowControl.vue +243 -0
  26. package/src/layer/app/components/debug/DebugPublicConfig.vue +24 -0
  27. package/src/layer/app/components/debug/DebugTestAdmin.vue +67 -0
  28. package/src/layer/app/components/demo/DemoDebug.vue +266 -0
  29. package/src/layer/app/components/demo/DemoHome.vue +347 -0
  30. package/src/layer/app/components/demo/DemoLogin.vue +391 -0
  31. package/src/layer/app/components/demo/DemoPassword.vue +224 -0
  32. package/src/layer/app/components/demo/DemoRegister.vue +148 -0
  33. package/src/layer/app/components/home/HomePage.vue +77 -0
  34. package/src/layer/app/layouts/dashboard.vue +126 -0
  35. package/src/layer/app/layouts/default.vue +3 -0
  36. package/src/layer/app/middleware/admin.ts +15 -0
  37. package/src/layer/app/middleware/authenticated.ts +19 -0
  38. package/src/layer/app/pages/admin/migrations.vue +463 -0
  39. package/src/layer/app/pages/admin/tasks/[id].vue +276 -0
  40. package/src/layer/app/pages/admin/tasks/index.vue +220 -0
  41. package/src/layer/app/pages/admin/users.vue +17 -0
  42. package/src/layer/app/pages/bakusoku-devtools.vue +294 -0
  43. package/src/layer/app/plugins/auth-init.ts +36 -0
  44. package/src/layer/app/plugins/debug-devtools.client.ts +20 -0
  45. package/src/layer/app/plugins/debug-errors.client.ts +78 -0
  46. package/src/layer/app/plugins/debug-http.client.ts +154 -0
  47. package/src/layer/app/plugins/debug-nav.client.ts +28 -0
  48. package/src/layer/app/plugins/vuefire-inspect.ts +18 -0
  49. package/src/layer/app/stores/auth.ts +462 -0
  50. package/src/layer/app/stores/datetime.ts +41 -0
  51. package/src/layer/app/stores/debug.ts +235 -0
  52. package/src/layer/app/stores/user.ts +170 -0
  53. package/src/layer/app/utils/admin-execution.ts +48 -0
  54. package/src/layer/app/utils/dashboard-heading.ts +36 -0
  55. package/src/layer/app/utils/debug-bridge.ts +270 -0
  56. package/src/layer/app/utils/debug-firestore.ts +38 -0
  57. package/src/layer/app/utils/debug-format.ts +19 -0
  58. package/src/layer/app/utils/execution-refresh.ts +66 -0
  59. package/src/layer/app/utils/framework-version.ts +4 -0
  60. package/src/layer/app/utils/inspect-nuxt-vuefire.ts +288 -0
  61. package/src/layer/app/utils/is-debug-enabled.ts +13 -0
  62. package/src/layer/app/utils/logger.ts +235 -0
  63. package/src/layer/app/utils/map-auth-error.ts +11 -0
  64. package/src/layer/app/utils/mask-secrets.ts +100 -0
  65. package/src/layer/app/utils/resolve-auth-user.ts +53 -0
  66. package/src/layer/app/utils/resolve-firestore.ts +20 -0
  67. package/src/layer/app/utils/task-run.ts +15 -0
  68. package/src/layer/build-credentials.mjs +33 -0
  69. package/src/layer/nuxt.config.ts +86 -0
  70. package/src/layer/package.json +5 -0
  71. package/src/layer/server/api/debug/test-admin.post.ts +38 -0
  72. package/src/layer/server/api/tasks/executions/cancel.post.ts +21 -0
  73. package/src/layer/server/api/tasks/executions/index.get.ts +22 -0
  74. package/src/layer/server/api/tasks/executions/index.post.ts +25 -0
  75. package/src/layer/server/api/tasks/index.get.ts +70 -0
  76. package/src/layer/server/api/tasks/migrations/index.post.ts +27 -0
  77. package/src/layer/server/api/tasks/migrations/recovery.post.ts +20 -0
  78. package/src/layer/server/api/users/[id].delete.ts +57 -0
  79. package/src/layer/server/api/users/[id].put.ts +110 -0
  80. package/src/layer/server/api/users/index.post.ts +232 -0
  81. package/src/layer/server/utils/admin-access.ts +32 -0
  82. package/src/layer/server/utils/debug-test-admin.ts +17 -0
  83. package/src/layer/server/utils/firebase-admin.ts +22 -0
  84. package/src/layer/server/utils/logger.ts +172 -0
  85. package/src/layer/server/utils/tasks-gateway.ts +57 -0
  86. package/src/layer/server/utils/user-mutations.ts +103 -0
@@ -0,0 +1,276 @@
1
+ <template>
2
+ <div class="flex flex-col gap-6">
3
+ <UBreadcrumb
4
+ aria-label="パンくずリスト"
5
+ separator-icon="i-lucide-chevron-right"
6
+ :items="[
7
+ { label: 'タスク管理', to: '/admin/tasks' },
8
+ { label: task?.name || taskId },
9
+ ]"
10
+ />
11
+
12
+ <div v-if="!task" class="flex justify-end">
13
+ <UButton icon="i-lucide-refresh-cw" variant="outline" :loading="loading" @click="load">
14
+ 再読み込み
15
+ </UButton>
16
+ </div>
17
+
18
+ <UAlert v-if="error" color="error" variant="soft" :title="error" />
19
+ <UAlert v-if="notice" color="success" variant="soft" :title="notice" />
20
+
21
+ <UCard v-if="missing">
22
+ <p class="text-sm text-gray-500">登録されたタスクではありません。</p>
23
+ </UCard>
24
+
25
+ <UCard v-else-if="task">
26
+ <template #header>
27
+ <div class="flex flex-wrap items-center gap-3">
28
+ <h2 class="text-base font-semibold">概要</h2>
29
+ <div class="ml-auto flex flex-wrap items-center justify-end gap-2">
30
+ <UButton icon="i-lucide-play" @click="runOpen = true">
31
+ 実行
32
+ </UButton>
33
+ <UButton
34
+ v-if="canStop(task.latest?.status)"
35
+ color="neutral"
36
+ variant="outline"
37
+ icon="i-lucide-square"
38
+ :loading="acting === task.latest?.id"
39
+ @click="stopLatest"
40
+ >
41
+ 停止
42
+ </UButton>
43
+ <UButton icon="i-lucide-refresh-cw" variant="outline" :loading="loading" @click="load">
44
+ 再読み込み
45
+ </UButton>
46
+ </div>
47
+ </div>
48
+ </template>
49
+ <p v-if="task.description" class="mb-4 text-sm text-gray-500 dark:text-gray-400">
50
+ {{ task.description }}
51
+ </p>
52
+ <dl class="grid gap-4 sm:grid-cols-2">
53
+ <div>
54
+ <dt class="text-sm text-gray-500">ID</dt>
55
+ <dd class="mt-1 font-mono text-sm">{{ task.id }}</dd>
56
+ </div>
57
+ <div>
58
+ <dt class="text-sm text-gray-500">最新の状態</dt>
59
+ <dd class="mt-1">
60
+ <UBadge v-if="task.latest" :color="statusColor(task.latest.status)" variant="subtle">
61
+ {{ statusLabel(task.latest.status) }}
62
+ </UBadge>
63
+ <span v-else class="text-sm text-gray-500">未実行</span>
64
+ </dd>
65
+ </div>
66
+ <div>
67
+ <dt class="text-sm text-gray-500">引数</dt>
68
+ <dd class="mt-1">
69
+ <div v-if="task.fields.length > 0" class="flex flex-wrap gap-1">
70
+ <UBadge
71
+ v-for="field in task.fields"
72
+ :key="field.key"
73
+ color="neutral"
74
+ variant="subtle"
75
+ size="sm"
76
+ >
77
+ {{ field.label }}
78
+ </UBadge>
79
+ </div>
80
+ <span v-else class="text-sm text-gray-500">なし</span>
81
+ </dd>
82
+ </div>
83
+ <div>
84
+ <dt class="text-sm text-gray-500">スケジュール</dt>
85
+ <dd class="mt-1">
86
+ <div v-if="task.schedules.length > 0" class="flex flex-col gap-2">
87
+ <div v-for="item in task.schedules" :key="`${item.id}-${item.registrationId}`">
88
+ <p class="font-mono text-sm">{{ item.schedule }}</p>
89
+ <p class="text-xs text-gray-500">{{ item.timeZone }} · 周期 {{ item.id }}</p>
90
+ </div>
91
+ </div>
92
+ <span v-else class="text-sm text-gray-500">なし</span>
93
+ </dd>
94
+ </div>
95
+ </dl>
96
+ </UCard>
97
+
98
+ <AdminExecutionHistory
99
+ v-if="task"
100
+ :rows="executions"
101
+ :loading="loading && !historyReady"
102
+ subject-label="タスク"
103
+ :show-subject="false"
104
+ show-schedule
105
+ :acting="acting"
106
+ @cancel="cancelExecution"
107
+ />
108
+
109
+ <TaskRunDialog v-model:open="runOpen" :task="task" @done="onRan" />
110
+ </div>
111
+ </template>
112
+
113
+ <script setup lang="ts">
114
+ import AdminExecutionHistory from '../../../components/admin/AdminExecutionHistory.vue'
115
+ import TaskRunDialog from '../../../components/admin/TaskRunDialog.vue'
116
+ import { statusColor, statusLabel } from '../../../utils/admin-execution'
117
+ import { isExecutionActive, useExecutionRefresh } from '../../../utils/execution-refresh'
118
+ import { useDashboardHeading } from '../../../utils/dashboard-heading'
119
+ import type { TaskRunTarget } from '../../../utils/task-run'
120
+ import { computed, navigateTo, ref, useRoute, useRuntimeConfig, watch } from '#imports'
121
+
122
+ definePageMeta({
123
+ layout: 'dashboard',
124
+ middleware: ['authenticated', 'admin'],
125
+ })
126
+
127
+ type TaskSchedule = {
128
+ id: string
129
+ schedule: string
130
+ timeZone: string
131
+ registrationId: string
132
+ }
133
+ type LatestExecution = {
134
+ id: string
135
+ status: string
136
+ scheduleTime: string
137
+ startedAt: string
138
+ endedAt: string
139
+ }
140
+ type TaskRow = TaskRunTarget & {
141
+ schedules: TaskSchedule[]
142
+ latest: LatestExecution | null
143
+ }
144
+ type ExecutionRow = {
145
+ id: string
146
+ name: string
147
+ status: string
148
+ source: string
149
+ actorUid: string
150
+ scheduleTime: string
151
+ startedAt: string
152
+ endedAt: string
153
+ attempts: number
154
+ error: string
155
+ message: string
156
+ }
157
+
158
+ const runtimeConfig = useRuntimeConfig()
159
+ const route = useRoute()
160
+ const taskId = computed(() => String(route.params.id || ''))
161
+
162
+ const loading = ref(true)
163
+ const acting = ref('')
164
+ const error = ref('')
165
+ const notice = ref('')
166
+ const historyReady = ref(false)
167
+ const task = ref<TaskRow | null>(null)
168
+ const missing = ref(false)
169
+ const executions = ref<ExecutionRow[]>([])
170
+ const runOpen = ref(false)
171
+
172
+ useDashboardHeading(computed(() => ({
173
+ title: task.value?.name || 'タスク',
174
+ })))
175
+
176
+ /** 実行の状態から取り消し操作を表示できるか判定する。 */
177
+ function canStop(status?: string) {
178
+ return status === 'pending' || status === 'accepted'
179
+ }
180
+
181
+ /** API エラーから画面表示用のメッセージを取り出す。 */
182
+ function messageOf(err: unknown) {
183
+ if (typeof err === 'object' && err && 'data' in err) {
184
+ const data = (err as { data?: { message?: string, statusMessage?: string } }).data
185
+ if (data?.message) return data.message
186
+ if (data?.statusMessage) return data.statusMessage
187
+ }
188
+ if (err instanceof Error) return err.message
189
+ return '操作に失敗しました。'
190
+ }
191
+
192
+ const awaitingStatus = ref(false)
193
+ const tasksEnabled = runtimeConfig.public.tasksEnabled === true
194
+ const load = useExecutionRefresh(
195
+ tasksEnabled,
196
+ () => awaitingStatus.value || isExecutionActive(task.value?.latest?.status)
197
+ || executions.value.some(row => isExecutionActive(row.status)),
198
+ readTasks,
199
+ )
200
+
201
+ if (!tasksEnabled) await navigateTo('/')
202
+
203
+ watch(taskId, () => {
204
+ awaitingStatus.value = false
205
+ task.value = null
206
+ executions.value = []
207
+ missing.value = false
208
+ historyReady.value = false
209
+ void load()
210
+ })
211
+
212
+ /** タスクの定義と実行履歴を取得する。 */
213
+ async function readTasks(background: boolean, isCurrent: () => boolean) {
214
+ const id = taskId.value
215
+ if (!id) return
216
+ if (!background) {
217
+ loading.value = true
218
+ error.value = ''
219
+ }
220
+ try {
221
+ const [catalogResult, historyResult] = await Promise.allSettled([
222
+ $fetch<{ data?: { tasks?: TaskRow[], latestAvailable?: boolean } }>('/api/tasks'),
223
+ $fetch<{ data?: ExecutionRow[] }>('/api/tasks/executions', { query: { kind: 'task', subjectId: id } }),
224
+ ])
225
+ if (!isCurrent() || taskId.value !== id) return
226
+ if (!background || historyResult.status === 'fulfilled') historyReady.value = historyResult.status === 'fulfilled'
227
+ if (catalogResult.status === 'fulfilled') {
228
+ const item = catalogResult.value.data?.tasks?.find(item => item.id === id)
229
+ task.value = item && catalogResult.value.data?.latestAvailable === false
230
+ ? { ...item, latest: task.value?.latest ?? null }
231
+ : item ?? null
232
+ missing.value = task.value === null
233
+ }
234
+ if (historyResult.status === 'fulfilled') {
235
+ executions.value = historyResult.value.data ?? []
236
+ awaitingStatus.value = false
237
+ }
238
+ const failed = [catalogResult, historyResult].find(result => result.status === 'rejected')
239
+ if (!background && failed?.status === 'rejected') {
240
+ error.value = messageOf(failed.reason)
241
+ }
242
+ } finally {
243
+ if (!background && isCurrent() && taskId.value === id) loading.value = false
244
+ }
245
+ }
246
+
247
+ /** タスク実行の受付結果を表示し、画面を再読み込みする。 */
248
+ async function onRan(message: string) {
249
+ awaitingStatus.value = true
250
+ notice.value = message
251
+ await load()
252
+ }
253
+
254
+ /** 直近のタスク実行の取り消しを依頼する。 */
255
+ async function stopLatest() {
256
+ const executionId = task.value?.latest?.id
257
+ if (!executionId) return
258
+ await cancelExecution(executionId)
259
+ }
260
+
261
+ /** 指定した実行の取り消しを API に依頼し、画面を更新する。 */
262
+ async function cancelExecution(id: string) {
263
+ acting.value = id
264
+ error.value = ''
265
+ notice.value = ''
266
+ try {
267
+ await $fetch('/api/tasks/executions/cancel', { method: 'POST', body: { executionId: id } })
268
+ notice.value = '実行を停止しました。'
269
+ await load()
270
+ } catch (err) {
271
+ error.value = messageOf(err)
272
+ } finally {
273
+ acting.value = ''
274
+ }
275
+ }
276
+ </script>
@@ -0,0 +1,220 @@
1
+ <template>
2
+ <div class="flex flex-col gap-6">
3
+ <UAlert v-if="error" color="error" variant="soft" :title="error" />
4
+ <UAlert v-if="!latestAvailable && catalogReady" color="warning" variant="soft" title="最新の実行状態を読み込めませんでした。" />
5
+ <UAlert v-if="notice" color="success" variant="soft" :title="notice" />
6
+
7
+ <UCard :ui="{ body: 'p-0 sm:p-0' }">
8
+ <template #header>
9
+ <div class="flex items-center justify-between gap-3">
10
+ <h2 class="text-base font-semibold">タスク一覧</h2>
11
+ <div class="flex shrink-0 items-center gap-2">
12
+ <UBadge color="neutral" variant="subtle">
13
+ {{ tasks.length }}
14
+ </UBadge>
15
+ <UButton icon="i-lucide-refresh-cw" size="sm" variant="outline" class="whitespace-nowrap" :loading="loading" @click="load">
16
+ 再読み込み
17
+ </UButton>
18
+ </div>
19
+ </div>
20
+ </template>
21
+ <UTable
22
+ :data="tasks"
23
+ :columns="taskColumns"
24
+ :loading="loading && !catalogReady"
25
+ :on-select="openTask"
26
+ empty="登録されたタスクはありません。"
27
+ >
28
+ <template #id-cell="{ row }">
29
+ <p class="font-mono text-xs text-gray-500">{{ row.original.id }}</p>
30
+ </template>
31
+ <template #name-cell="{ row }">
32
+ <NuxtLink :to="`/admin/tasks/${row.original.id}`" class="font-medium hover:underline">
33
+ {{ row.original.name }}
34
+ </NuxtLink>
35
+ </template>
36
+ <template #schedules-cell="{ row }">
37
+ <div v-if="row.original.schedules.length > 0" class="flex flex-col gap-2">
38
+ <div v-for="item in row.original.schedules" :key="`${item.id}-${item.registrationId}`">
39
+ <p class="font-mono text-xs">{{ item.schedule }}</p>
40
+ <p class="text-xs text-gray-500">{{ item.timeZone }} · {{ item.id }}</p>
41
+ </div>
42
+ </div>
43
+ <span v-else class="text-sm text-gray-500">なし</span>
44
+ </template>
45
+ <template #latest-cell="{ row }">
46
+ <div v-if="row.original.latest" class="flex flex-col items-start gap-1">
47
+ <UBadge :color="statusColor(row.original.latest.status)" variant="subtle">
48
+ {{ statusLabel(row.original.latest.status) }}
49
+ </UBadge>
50
+ <p class="text-xs text-gray-500">
51
+ {{ formatTime(row.original.latest.endedAt || row.original.latest.startedAt || row.original.latest.scheduleTime) }}
52
+ </p>
53
+ </div>
54
+ <span v-else class="text-sm text-gray-500">未実行</span>
55
+ </template>
56
+ <template #actions-cell="{ row }">
57
+ <div class="flex justify-end gap-2">
58
+ <UButton size="xs" @click="startRun(row.original)">
59
+ 実行
60
+ </UButton>
61
+ <UButton
62
+ v-if="canStop(row.original.latest?.status)"
63
+ size="xs"
64
+ color="neutral"
65
+ variant="outline"
66
+ :loading="acting === row.original.latest?.id"
67
+ @click="stopLatest(row.original)"
68
+ >
69
+ 停止
70
+ </UButton>
71
+ </div>
72
+ </template>
73
+ </UTable>
74
+ </UCard>
75
+
76
+ <TaskRunDialog v-model:open="runOpen" :task="runTarget" @done="onRan" />
77
+ </div>
78
+ </template>
79
+
80
+ <script setup lang="ts">
81
+ import TaskRunDialog from '../../../components/admin/TaskRunDialog.vue'
82
+ import { formatTime, statusColor, statusLabel } from '../../../utils/admin-execution'
83
+ import { isExecutionActive, useExecutionRefresh } from '../../../utils/execution-refresh'
84
+ import { useDashboardHeading } from '../../../utils/dashboard-heading'
85
+ import type { TaskRunTarget } from '../../../utils/task-run'
86
+ import { navigateTo, ref, useRuntimeConfig } from '#imports'
87
+
88
+ definePageMeta({
89
+ layout: 'dashboard',
90
+ middleware: ['authenticated', 'admin'],
91
+ })
92
+
93
+ useDashboardHeading({
94
+ title: 'タスク管理',
95
+ })
96
+
97
+ type TaskSchedule = {
98
+ id: string
99
+ schedule: string
100
+ timeZone: string
101
+ registrationId: string
102
+ }
103
+ type LatestExecution = {
104
+ id: string
105
+ status: string
106
+ scheduleTime: string
107
+ startedAt: string
108
+ endedAt: string
109
+ }
110
+ type TaskRow = TaskRunTarget & {
111
+ schedules: TaskSchedule[]
112
+ latest: LatestExecution | null
113
+ }
114
+
115
+ const runtimeConfig = useRuntimeConfig()
116
+ const loading = ref(true)
117
+ const acting = ref('')
118
+ const error = ref('')
119
+ const notice = ref('')
120
+ const catalogReady = ref(false)
121
+ const latestAvailable = ref(true)
122
+ const tasks = ref<TaskRow[]>([])
123
+ const runOpen = ref(false)
124
+ const runTarget = ref<TaskRunTarget | null>(null)
125
+
126
+ const taskColumns = [
127
+ { accessorKey: 'id', header: 'ID' },
128
+ { accessorKey: 'name', header: 'タスク名' },
129
+ { id: 'schedules', header: 'スケジュール' },
130
+ { id: 'latest', header: '最新の状態' },
131
+ { id: 'actions', header: '' },
132
+ ]
133
+
134
+ /** 実行の状態から取り消し操作を表示できるか判定する。 */
135
+ function canStop(status?: string) {
136
+ return status === 'pending' || status === 'accepted'
137
+ }
138
+
139
+ /** 選択したタスクの詳細画面を開く。 */
140
+ function openTask(_event: Event, row: { original: TaskRow }) {
141
+ navigateTo(`/admin/tasks/${row.original.id}`)
142
+ }
143
+
144
+ /** 選択したタスクの実行ダイアログを開く。 */
145
+ function startRun(item: TaskRow) {
146
+ runTarget.value = item
147
+ runOpen.value = true
148
+ }
149
+
150
+ /** API エラーから画面表示用のメッセージを取り出す。 */
151
+ function messageOf(err: unknown) {
152
+ if (typeof err === 'object' && err && 'data' in err) {
153
+ const data = (err as { data?: { message?: string, statusMessage?: string } }).data
154
+ if (data?.message) return data.message
155
+ if (data?.statusMessage) return data.statusMessage
156
+ }
157
+ if (err instanceof Error) return err.message
158
+ return '操作に失敗しました。'
159
+ }
160
+
161
+ const awaitingStatus = ref(false)
162
+ const tasksEnabled = runtimeConfig.public.tasksEnabled === true
163
+ const load = useExecutionRefresh(
164
+ tasksEnabled,
165
+ () => awaitingStatus.value || tasks.value.some(item => isExecutionActive(item.latest?.status)),
166
+ readTasks,
167
+ )
168
+
169
+ if (!tasksEnabled) await navigateTo('/')
170
+
171
+ /** タスク一覧と直近の実行状態を取得する。 */
172
+ async function readTasks(background: boolean, isCurrent: () => boolean) {
173
+ if (!background) {
174
+ loading.value = true
175
+ error.value = ''
176
+ }
177
+ try {
178
+ const result = await $fetch<{
179
+ data?: { latestAvailable?: boolean, tasks?: TaskRow[] }
180
+ }>('/api/tasks')
181
+ if (!isCurrent()) return
182
+ latestAvailable.value = result.data?.latestAvailable !== false
183
+ const previous = new Map(tasks.value.map(item => [item.id, item.latest]))
184
+ tasks.value = (result.data?.tasks ?? []).map(item => latestAvailable.value
185
+ ? item
186
+ : { ...item, latest: previous.get(item.id) ?? null })
187
+ if (latestAvailable.value) awaitingStatus.value = false
188
+ catalogReady.value = true
189
+ } catch (err) {
190
+ if (!background && isCurrent()) error.value = messageOf(err)
191
+ } finally {
192
+ if (!background && isCurrent()) loading.value = false
193
+ }
194
+ }
195
+
196
+ /** タスク実行の受付結果を表示し、画面を再読み込みする。 */
197
+ async function onRan(message: string) {
198
+ awaitingStatus.value = true
199
+ notice.value = message
200
+ await load()
201
+ }
202
+
203
+ /** 直近のタスク実行の取り消しを依頼する。 */
204
+ async function stopLatest(item: TaskRow) {
205
+ const executionId = item.latest?.id
206
+ if (!executionId) return
207
+ acting.value = executionId
208
+ error.value = ''
209
+ notice.value = ''
210
+ try {
211
+ await $fetch('/api/tasks/executions/cancel', { method: 'POST', body: { executionId } })
212
+ notice.value = `${item.name}の実行を停止しました。`
213
+ await load()
214
+ } catch (err) {
215
+ error.value = messageOf(err)
216
+ } finally {
217
+ acting.value = ''
218
+ }
219
+ }
220
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <UserManagementPage />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import UserManagementPage from '../../components/admin/UserManagementPage.vue'
7
+ import { useDashboardHeading } from '../../utils/dashboard-heading'
8
+
9
+ definePageMeta({
10
+ layout: 'dashboard',
11
+ middleware: ['authenticated', 'admin'],
12
+ })
13
+
14
+ useDashboardHeading({
15
+ title: 'ユーザー管理',
16
+ })
17
+ </script>