@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.
- package/README.md +38 -2
- package/dist/module.d.mts +25 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +208 -0
- package/dist/runtime/shared/schemas/user.d.ts +40 -0
- package/dist/runtime/shared/schemas/user.js +21 -0
- package/dist/runtime/tasks-catalog.d.ts +6 -0
- package/dist/runtime/tasks-catalog.js +7 -0
- package/dist/types.d.mts +9 -0
- package/package.json +120 -3
- package/scripts/bakusoku-dev.mjs +387 -0
- package/scripts/dev-log-relay.mjs +96 -0
- package/scripts/predeploy.mjs +24 -0
- package/scripts/prepare-firebase-artifact.mjs +43 -0
- package/scripts/setup-worktree.sh +59 -0
- package/scripts/verify-firebase-artifacts.mjs +70 -0
- package/src/layer/app/components/admin/AdminExecutionHistory.vue +137 -0
- package/src/layer/app/components/admin/TaskRunDialog.vue +162 -0
- package/src/layer/app/components/admin/UserManagementPage.vue +342 -0
- package/src/layer/app/components/debug/DebugApplicationLogs.vue +87 -0
- package/src/layer/app/components/debug/DebugErrorLogs.vue +47 -0
- package/src/layer/app/components/debug/DebugFirestoreOperations.vue +48 -0
- package/src/layer/app/components/debug/DebugHttpRequests.vue +86 -0
- package/src/layer/app/components/debug/DebugNavigation.vue +60 -0
- package/src/layer/app/components/debug/DebugNowControl.vue +243 -0
- package/src/layer/app/components/debug/DebugPublicConfig.vue +24 -0
- package/src/layer/app/components/debug/DebugTestAdmin.vue +67 -0
- package/src/layer/app/components/demo/DemoDebug.vue +266 -0
- package/src/layer/app/components/demo/DemoHome.vue +347 -0
- package/src/layer/app/components/demo/DemoLogin.vue +391 -0
- package/src/layer/app/components/demo/DemoPassword.vue +224 -0
- package/src/layer/app/components/demo/DemoRegister.vue +148 -0
- package/src/layer/app/components/home/HomePage.vue +77 -0
- package/src/layer/app/layouts/dashboard.vue +126 -0
- package/src/layer/app/layouts/default.vue +3 -0
- package/src/layer/app/middleware/admin.ts +15 -0
- package/src/layer/app/middleware/authenticated.ts +19 -0
- package/src/layer/app/pages/admin/migrations.vue +463 -0
- package/src/layer/app/pages/admin/tasks/[id].vue +276 -0
- package/src/layer/app/pages/admin/tasks/index.vue +220 -0
- package/src/layer/app/pages/admin/users.vue +17 -0
- package/src/layer/app/pages/bakusoku-devtools.vue +294 -0
- package/src/layer/app/plugins/auth-init.ts +36 -0
- package/src/layer/app/plugins/debug-devtools.client.ts +20 -0
- package/src/layer/app/plugins/debug-errors.client.ts +78 -0
- package/src/layer/app/plugins/debug-http.client.ts +154 -0
- package/src/layer/app/plugins/debug-nav.client.ts +28 -0
- package/src/layer/app/plugins/vuefire-inspect.ts +18 -0
- package/src/layer/app/stores/auth.ts +462 -0
- package/src/layer/app/stores/datetime.ts +41 -0
- package/src/layer/app/stores/debug.ts +235 -0
- package/src/layer/app/stores/user.ts +170 -0
- package/src/layer/app/utils/admin-execution.ts +48 -0
- package/src/layer/app/utils/dashboard-heading.ts +36 -0
- package/src/layer/app/utils/debug-bridge.ts +270 -0
- package/src/layer/app/utils/debug-firestore.ts +38 -0
- package/src/layer/app/utils/debug-format.ts +19 -0
- package/src/layer/app/utils/execution-refresh.ts +66 -0
- package/src/layer/app/utils/framework-version.ts +4 -0
- package/src/layer/app/utils/inspect-nuxt-vuefire.ts +288 -0
- package/src/layer/app/utils/is-debug-enabled.ts +13 -0
- package/src/layer/app/utils/logger.ts +235 -0
- package/src/layer/app/utils/map-auth-error.ts +11 -0
- package/src/layer/app/utils/mask-secrets.ts +100 -0
- package/src/layer/app/utils/resolve-auth-user.ts +53 -0
- package/src/layer/app/utils/resolve-firestore.ts +20 -0
- package/src/layer/app/utils/task-run.ts +15 -0
- package/src/layer/build-credentials.mjs +33 -0
- package/src/layer/nuxt.config.ts +86 -0
- package/src/layer/package.json +5 -0
- package/src/layer/server/api/debug/test-admin.post.ts +38 -0
- package/src/layer/server/api/tasks/executions/cancel.post.ts +21 -0
- package/src/layer/server/api/tasks/executions/index.get.ts +22 -0
- package/src/layer/server/api/tasks/executions/index.post.ts +25 -0
- package/src/layer/server/api/tasks/index.get.ts +70 -0
- package/src/layer/server/api/tasks/migrations/index.post.ts +27 -0
- package/src/layer/server/api/tasks/migrations/recovery.post.ts +20 -0
- package/src/layer/server/api/users/[id].delete.ts +57 -0
- package/src/layer/server/api/users/[id].put.ts +110 -0
- package/src/layer/server/api/users/index.post.ts +232 -0
- package/src/layer/server/utils/admin-access.ts +32 -0
- package/src/layer/server/utils/debug-test-admin.ts +17 -0
- package/src/layer/server/utils/firebase-admin.ts +22 -0
- package/src/layer/server/utils/logger.ts +172 -0
- package/src/layer/server/utils/tasks-gateway.ts +57 -0
- package/src/layer/server/utils/user-mutations.ts +103 -0
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @enlt-bakusoku/nuxt4
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## ユーザー管理で保存に失敗したとき
|
|
4
|
+
|
|
5
|
+
- 登録時にプロフィールを保存できなかった場合は、その登録用に作成した Firebase Auth アカウントを取り消します。取り消しにも失敗して登録を再試行できない場合は、サーバーログの `Failed to create user` に記録された UID を使って Auth と Firestore の両方を照合してください。中断した登録の残存データと確認できれば、管理者セッションで `DELETE /api/users/:id` を実行してから登録をやり直せます。
|
|
6
|
+
- 編集の保存に失敗した場合は、同じ編集内容で再試行できます。プロフィールには同期時点の Auth の値を反映します。
|
|
7
|
+
- 削除が中断された場合、プロフィールの権限を外して「削除待ち」として一覧に残します。管理者は一覧の「削除を再試行」から続行できます。
|
|
8
|
+
- 編集で Auth の更新後にプロフィール保存が失敗した場合は、Auth を更新前のメールアドレス、表示名、無効化状態に戻します。パスワードはプロフィール保存の後に変更します。
|
|
9
|
+
- 最後の有効な管理者は、無効化、管理者以外への変更、削除ができません。
|
|
10
|
+
|
|
11
|
+
## 公開登録
|
|
12
|
+
|
|
13
|
+
ログインしていない作成は `role=user` だけで、メール未確認のアカウントになります。確認メールのリンクを開くまでログインできません。未確認のパスワードアカウントは、同じメールアドレスでの再登録がパスワードを引き取ります。確認済みのアカウントはパスワードを変えません。プロフィールが無い確認済みアカウントは、そのパスワードでログインしたときにプロフィールを作ります。
|
|
14
|
+
|
|
15
|
+
管理者がログイン中に作成したアカウントは確認済みです。無効な管理者と削除待ちの利用者は、管理画面と Firestore の利用者一覧を使えません。Firestore のルールは、利用側の `firestore.rules` に書きます。
|
|
16
|
+
|
|
17
|
+
## ローカル開発
|
|
18
|
+
|
|
19
|
+
Nuxt と Firebase Emulator をローカルで起動する開発用コマンドです。Node.js 22 以上、Linux(WSL を含む)または macOS で使えます。開発対象のアプリに Firebase CLI と pnpm を用意してください。
|
|
20
|
+
|
|
21
|
+
`bakusoku-dev` はこのパッケージに同梱されています。アプリの `package.json` の `scripts` に必要なコマンドを設定します。
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"dev:all": "bakusoku-dev all",
|
|
26
|
+
"dev:backend": "bakusoku-dev backend",
|
|
27
|
+
"emulators:start": "bakusoku-dev emulators:start",
|
|
28
|
+
"emulators:stop": "bakusoku-dev emulators:stop",
|
|
29
|
+
"functions:shell": "bakusoku-dev functions:shell"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `pnpm dev:all` は Emulator の起動を待ってから `pnpm dev` を実行します。Nuxt には Firebase のプロジェクト ID と Cloud Tasks Emulator の接続先を渡します。
|
|
34
|
+
- `pnpm dev:backend` はバックエンドを立ち上げます。両方の開発コマンドで、`functions/package.json` に `build:watch` があれば実行します。
|
|
35
|
+
- `pnpm emulators:start` は Emulator を単独で起動します。開発コマンドと同様に `./data` からインポートし、終了時にエクスポートします。
|
|
36
|
+
- `pnpm emulators:stop` は、そのアプリでこのパッケージが起動した Emulator を終了させ、エクスポートの完了を待ちます。
|
|
37
|
+
- `pnpm functions:shell` は Functions の対話シェルを開きます。
|
|
38
|
+
|
|
39
|
+
`firebase.json` と `package.json` があるディレクトリがアプリのルートです。起動時はルートの `.env` を読み込みます。環境変数がすでに設定されていれば、その値が優先されます。停止以外のコマンドには `NUXT_PUBLIC_FIREBASE_PROJECT_ID` が必要です。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
declare module '@nuxt/schema' {
|
|
4
|
+
interface NitroConfigFallback {
|
|
5
|
+
alias?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* bakusoku のオプション
|
|
10
|
+
*/
|
|
11
|
+
interface BakusokuModuleOptions {
|
|
12
|
+
firebase?: Record<string, string>;
|
|
13
|
+
/** 利用側の shared/schemas/user へのパス(rootDir 相対)。未指定時はフレームワーク標準スタブ。 */
|
|
14
|
+
userSchemas?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* bakusoku のモジュール定義
|
|
18
|
+
*
|
|
19
|
+
* UI / VueFire / stores / plugins / middleware / server は Layer。
|
|
20
|
+
* 本モジュールはユーザースキーマとタスクカタログのエイリアスを設定する。
|
|
21
|
+
*/
|
|
22
|
+
declare const _default: _nuxt_schema.NuxtModule<BakusokuModuleOptions, BakusokuModuleOptions, false>;
|
|
23
|
+
|
|
24
|
+
export { _default as default };
|
|
25
|
+
export type { BakusokuModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { createResolver, defineNuxtModule } from '@nuxt/kit';
|
|
5
|
+
import { createConnection } from 'node:net';
|
|
6
|
+
import { createInterface } from 'node:readline';
|
|
7
|
+
|
|
8
|
+
function receiveDevLogs(path) {
|
|
9
|
+
const socket = createConnection(path);
|
|
10
|
+
socket.unref();
|
|
11
|
+
const lines = createInterface({ input: socket });
|
|
12
|
+
socket.on("error", () => socket.destroy());
|
|
13
|
+
lines.on("line", (line) => {
|
|
14
|
+
let entry;
|
|
15
|
+
try {
|
|
16
|
+
entry = JSON.parse(line);
|
|
17
|
+
} catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (typeof entry?.message !== "string") return;
|
|
21
|
+
if (entry.stderr) console.error(entry.message);
|
|
22
|
+
else console.log(entry.message);
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
lines.close();
|
|
26
|
+
socket.destroy();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function resolveTasksEmulatorHost(input) {
|
|
31
|
+
if (input.currentHost) {
|
|
32
|
+
return input.currentHost;
|
|
33
|
+
}
|
|
34
|
+
if (!input.dev || !input.emulatorsEnabled) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
const body = await input.fetchHub(`http://${input.hubHost}:4400/emulators`);
|
|
38
|
+
const port = body?.tasks?.port;
|
|
39
|
+
if (!port) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
const host = body?.tasks?.host;
|
|
43
|
+
const reachable = !host || host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
|
|
44
|
+
return `${reachable}:${port}`;
|
|
45
|
+
}
|
|
46
|
+
async function enableTasksEmulator(options) {
|
|
47
|
+
const host = await resolveTasksEmulatorHost({
|
|
48
|
+
...options,
|
|
49
|
+
currentHost: process.env.CLOUD_TASKS_EMULATOR_HOST,
|
|
50
|
+
fetchHub: fetchEmulatorHub
|
|
51
|
+
});
|
|
52
|
+
if (!host || process.env.CLOUD_TASKS_EMULATOR_HOST) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
process.env.CLOUD_TASKS_EMULATOR_HOST = host;
|
|
56
|
+
console.info(`[@enlt-bakusoku/nuxt4] Enabling tasks emulator at ${host}`);
|
|
57
|
+
}
|
|
58
|
+
async function fetchEmulatorHub(url) {
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(url);
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return await response.json();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const code = error.cause?.code;
|
|
67
|
+
if (code !== "ECONNREFUSED") {
|
|
68
|
+
console.error("[@enlt-bakusoku/nuxt4] Error fetching emulators", error);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const resolver = createResolver(import.meta.url);
|
|
75
|
+
const module$1 = defineNuxtModule({
|
|
76
|
+
meta: {
|
|
77
|
+
name: "@enlt-bakusoku/nuxt4",
|
|
78
|
+
configKey: "bakusoku"
|
|
79
|
+
},
|
|
80
|
+
defaults: {},
|
|
81
|
+
/** Nuxt レイヤーと機能オプションを読み込み、必要な設定とフックを登録する。 */
|
|
82
|
+
async setup(options, nuxt) {
|
|
83
|
+
const logSocket = process.env.BAKUSOKU_DEV_LOG_SOCKET;
|
|
84
|
+
if (nuxt.options.dev && logSocket) {
|
|
85
|
+
nuxt.hook("close", receiveDevLogs(logSocket));
|
|
86
|
+
}
|
|
87
|
+
registerDevtoolsTab(nuxt);
|
|
88
|
+
warnIfUiLayerMissing(nuxt);
|
|
89
|
+
const emulators = readVuefireEmulators(nuxt);
|
|
90
|
+
await enableTasksEmulator({
|
|
91
|
+
dev: nuxt.options.dev,
|
|
92
|
+
emulatorsEnabled: emulators.enabled,
|
|
93
|
+
hubHost: emulators.host
|
|
94
|
+
});
|
|
95
|
+
const baseUserSchemasPath = resolver.resolve("./runtime/shared/schemas/user");
|
|
96
|
+
const userSchemasPath = options.userSchemas ? createResolver(nuxt.options.rootDir).resolve(options.userSchemas) : baseUserSchemasPath;
|
|
97
|
+
applyUserSchemasAlias(nuxt, userSchemasPath, baseUserSchemasPath);
|
|
98
|
+
applyTasksCatalogAlias(nuxt, resolveTasksCatalog(nuxt.options.rootDir));
|
|
99
|
+
nuxt.hook("nitro:init", (nitro) => {
|
|
100
|
+
if (nitro.options.preset === "firebase") {
|
|
101
|
+
nitro.hooks.hook("compiled", () => {
|
|
102
|
+
execFileSync(process.execPath, [
|
|
103
|
+
resolver.resolve("../scripts/prepare-firebase-artifact.mjs"),
|
|
104
|
+
nitro.options.output.serverDir
|
|
105
|
+
], { cwd: nuxt.options.rootDir, stdio: "inherit" });
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
function readVuefireEmulators(nuxt) {
|
|
112
|
+
const vuefire = nuxt.options.vuefire;
|
|
113
|
+
const emulators = vuefire?.emulators;
|
|
114
|
+
if (emulators === false) {
|
|
115
|
+
return { enabled: false, host: "127.0.0.1" };
|
|
116
|
+
}
|
|
117
|
+
if (typeof emulators !== "object" || emulators === null) {
|
|
118
|
+
return { enabled: nuxt.options.dev, host: "127.0.0.1" };
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
enabled: emulators.enabled ?? nuxt.options.dev,
|
|
122
|
+
host: emulators.host || "127.0.0.1"
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function registerDevtoolsTab(nuxt) {
|
|
126
|
+
if (!nuxt.options.dev || process.env.NUXT_PUBLIC_ENABLE_DEBUG === "false") {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const hooks = nuxt.hooks;
|
|
130
|
+
hooks.hook("devtools:ready", (ctx) => {
|
|
131
|
+
ctx.docks.register({
|
|
132
|
+
id: "bakusoku",
|
|
133
|
+
title: "Bakusoku",
|
|
134
|
+
icon: "carbon:debug",
|
|
135
|
+
type: "iframe",
|
|
136
|
+
url: "/bakusoku-devtools",
|
|
137
|
+
groupId: "nuxt",
|
|
138
|
+
category: "modules"
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
hooks.hook("devtools:customTabs", (tabs) => {
|
|
142
|
+
if (isViteDevtools(nuxt) || tabs.some((tab) => tab.name === "bakusoku")) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
tabs.push({
|
|
146
|
+
name: "bakusoku",
|
|
147
|
+
title: "Bakusoku",
|
|
148
|
+
icon: "carbon:debug",
|
|
149
|
+
view: {
|
|
150
|
+
type: "iframe",
|
|
151
|
+
src: "/bakusoku-devtools"
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function isViteDevtools(nuxt) {
|
|
157
|
+
const devtools = nuxt.devtools;
|
|
158
|
+
return !!devtools && "devtoolsKit" in devtools;
|
|
159
|
+
}
|
|
160
|
+
function resolveTasksCatalog(rootDir) {
|
|
161
|
+
const generated = resolve(rootDir, "functions/src/v1/catalog.generated.ts");
|
|
162
|
+
return existsSync(generated) ? generated : resolver.resolve("./runtime/tasks-catalog");
|
|
163
|
+
}
|
|
164
|
+
function applyTasksCatalogAlias(nuxt, tasksCatalogPath) {
|
|
165
|
+
nuxt.options.alias["#bakusoku/tasks-catalog"] = tasksCatalogPath;
|
|
166
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
167
|
+
nitroConfig.alias = nitroConfig.alias ?? {};
|
|
168
|
+
nitroConfig.alias["#bakusoku/tasks-catalog"] = tasksCatalogPath;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function applyUserSchemasAlias(nuxt, userSchemasPath, baseUserSchemasPath) {
|
|
172
|
+
nuxt.options.alias["#bakusoku/user-schemas"] = userSchemasPath;
|
|
173
|
+
nuxt.options.alias["#bakusoku/user-schemas-base"] = baseUserSchemasPath;
|
|
174
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
175
|
+
nitroConfig.alias = nitroConfig.alias ?? {};
|
|
176
|
+
nitroConfig.alias["#bakusoku/user-schemas"] = userSchemasPath;
|
|
177
|
+
nitroConfig.alias["#bakusoku/user-schemas-base"] = baseUserSchemasPath;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function warnIfUiLayerMissing(nuxt) {
|
|
181
|
+
const modulePkgRoot = resolver.resolve("..").replace(/\\/g, "/");
|
|
182
|
+
const rootDir = nuxt.options.rootDir.replace(/\\/g, "/");
|
|
183
|
+
if (rootDir === modulePkgRoot) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const hasUiLayer = nuxt.options._layers.some((layer) => {
|
|
187
|
+
const metaName = String(layer.meta?.name ?? "");
|
|
188
|
+
if (metaName === "@enlt-bakusoku/nuxt4-layer" || metaName === "@enlt-bakusoku/nuxt4/layer") {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
const haystack = [
|
|
192
|
+
layer.cwd,
|
|
193
|
+
layer.configFile,
|
|
194
|
+
// c12 / Nuxt が保持する解決元(workspace・exports 経由の検出用)
|
|
195
|
+
layer.source,
|
|
196
|
+
layer._configFile,
|
|
197
|
+
metaName
|
|
198
|
+
].map((value) => String(value ?? "").replace(/\\/g, "/")).join("\n");
|
|
199
|
+
return /@enlt-bakusoku\/nuxt4(-layer|(\/src)?\/layer)\b/.test(haystack) || /\/packages\/nuxt4(\/src)?\/layer\b/.test(haystack) || /\/packages\/nuxt(\/src)?\/layer\b/.test(haystack) || /\/alpha-framework(\/src)?\/layer\b/.test(haystack);
|
|
200
|
+
});
|
|
201
|
+
if (!hasUiLayer) {
|
|
202
|
+
console.warn(
|
|
203
|
+
"[@enlt-bakusoku/nuxt4] UI Layer \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 nuxt.config \u306B extends: ['@enlt-bakusoku/nuxt4/layer'] \u3092\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* フレームワーク標準のユーザースキーマ(スタブ)
|
|
3
|
+
* 利用側は bakusoku.userSchemas で差し替え、shared/schemas/user から #bakusoku/user-schemas-base を extend する。
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/** 認証・Firestore 連携に必要な最小フィールド */
|
|
7
|
+
export declare const bakusokuUserCoreSchema: z.ZodObject<{
|
|
8
|
+
displayName: z.ZodString;
|
|
9
|
+
email: z.ZodString;
|
|
10
|
+
password: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const createUserSchema: z.ZodObject<{
|
|
13
|
+
displayName: z.ZodString;
|
|
14
|
+
email: z.ZodString;
|
|
15
|
+
password: z.ZodString;
|
|
16
|
+
role: z.ZodDefault<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export declare const updateUserSchema: z.ZodObject<{
|
|
19
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
20
|
+
email: z.ZodOptional<z.ZodString>;
|
|
21
|
+
password: z.ZodOptional<z.ZodString>;
|
|
22
|
+
role: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
23
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
/** パスワード変更フォーム(現在・新規・確認) */
|
|
26
|
+
export declare const changePasswordSchema: z.ZodObject<{
|
|
27
|
+
currentPassword: z.ZodString;
|
|
28
|
+
newPassword: z.ZodString;
|
|
29
|
+
confirmPassword: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/** フレームワークが想定するユーザーの最小形(利用側で拡張可能) */
|
|
32
|
+
export type BakusokuUserBase = {
|
|
33
|
+
uid: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
email: string;
|
|
36
|
+
role?: string;
|
|
37
|
+
};
|
|
38
|
+
export type CreateUserInput = z.infer<typeof createUserSchema>;
|
|
39
|
+
export type UpdateUserInput = z.infer<typeof updateUserSchema>;
|
|
40
|
+
export type ChangePasswordInput = z.infer<typeof changePasswordSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const bakusokuUserCoreSchema = z.object({
|
|
3
|
+
displayName: z.string().min(1, "\u8868\u793A\u540D\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002").trim().max(100, "\u8868\u793A\u540D\u306F100\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),
|
|
4
|
+
email: z.string().min(1, "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002").trim().toLowerCase().email("\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002"),
|
|
5
|
+
password: z.string().min(6, "\u30D1\u30B9\u30EF\u30FC\u30C9\u306F6\u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002").max(128, "\u30D1\u30B9\u30EF\u30FC\u30C9\u306F128\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002")
|
|
6
|
+
});
|
|
7
|
+
export const createUserSchema = bakusokuUserCoreSchema.extend({
|
|
8
|
+
role: z.string().default("user")
|
|
9
|
+
});
|
|
10
|
+
export const updateUserSchema = createUserSchema.partial().extend({
|
|
11
|
+
/** Firebase Auth の disabled と Firestore users.disabled を同時に更新する */
|
|
12
|
+
disabled: z.boolean().optional()
|
|
13
|
+
});
|
|
14
|
+
export const changePasswordSchema = z.object({
|
|
15
|
+
currentPassword: z.string().min(1, "\u73FE\u5728\u306E\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"),
|
|
16
|
+
newPassword: bakusokuUserCoreSchema.shape.password,
|
|
17
|
+
confirmPassword: z.string().min(1, "\u78BA\u8A8D\u7528\u306E\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002")
|
|
18
|
+
}).refine((data) => data.newPassword === data.confirmPassword, {
|
|
19
|
+
message: "\u65B0\u3057\u3044\u30D1\u30B9\u30EF\u30FC\u30C9\u304C\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002",
|
|
20
|
+
path: ["confirmPassword"]
|
|
21
|
+
});
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type BakusokuModuleOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,123 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enlt-bakusoku/nuxt4",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/enlt-bakusoku/frameworks.git",
|
|
8
|
+
"directory": "packages/nuxt4"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"registry": "https://registry.npmjs.org/",
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types.d.mts",
|
|
17
|
+
"import": "./dist/module.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./layer": "./src/layer/nuxt.config.ts",
|
|
20
|
+
"./runtime/shared/*": {
|
|
21
|
+
"types": "./dist/runtime/shared/*",
|
|
22
|
+
"import": "./dist/runtime/shared/*"
|
|
23
|
+
},
|
|
24
|
+
"./components/DemoDebug.vue": "./src/layer/app/components/demo/DemoDebug.vue",
|
|
25
|
+
"./components/debug/DemoDebug.vue": "./src/layer/app/components/demo/DemoDebug.vue",
|
|
26
|
+
"./components/DemoHome.vue": "./src/layer/app/components/demo/DemoHome.vue",
|
|
27
|
+
"./components/DemoLogin.vue": "./src/layer/app/components/demo/DemoLogin.vue",
|
|
28
|
+
"./components/DemoPassword.vue": "./src/layer/app/components/demo/DemoPassword.vue",
|
|
29
|
+
"./components/DemoRegister.vue": "./src/layer/app/components/demo/DemoRegister.vue",
|
|
30
|
+
"./components/AdminExecutionHistory.vue": "./src/layer/app/components/admin/AdminExecutionHistory.vue",
|
|
31
|
+
"./components/DebugNowControl.vue": "./src/layer/app/components/debug/DebugNowControl.vue",
|
|
32
|
+
"./components/HomePage.vue": "./src/layer/app/components/home/HomePage.vue",
|
|
33
|
+
"./components/TaskRunDialog.vue": "./src/layer/app/components/admin/TaskRunDialog.vue",
|
|
34
|
+
"./components/UserManagementPage.vue": "./src/layer/app/components/admin/UserManagementPage.vue",
|
|
35
|
+
"./components/*": "./src/layer/app/components/*"
|
|
36
|
+
},
|
|
37
|
+
"main": "./dist/module.mjs",
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"*": {
|
|
40
|
+
".": [
|
|
41
|
+
"./dist/types.d.mts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"scripts",
|
|
48
|
+
"src/layer"
|
|
49
|
+
],
|
|
50
|
+
"bin": {
|
|
51
|
+
"bakusoku-dev": "./scripts/bakusoku-dev.mjs",
|
|
52
|
+
"bakusoku-predeploy": "./scripts/predeploy.mjs",
|
|
53
|
+
"bakusoku-setup-worktree": "./scripts/setup-worktree.sh",
|
|
54
|
+
"bakusoku-verify-firebase-artifacts": "./scripts/verify-firebase-artifacts.mjs"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@nuxt/kit": "^4.6.0",
|
|
58
|
+
"@pinia/nuxt": "^0.11.3",
|
|
59
|
+
"firebase-admin": "^13.6.0",
|
|
60
|
+
"h3": "^1.15.11",
|
|
61
|
+
"@enlt-bakusoku/functions": "2.1.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@floating-ui/dom": "^1.7.0",
|
|
65
|
+
"@nuxt/cli": "^4.0.0",
|
|
66
|
+
"@nuxt/devtools": "^3.4.2",
|
|
67
|
+
"@nuxt/eslint-config": "^1.15.2",
|
|
68
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
69
|
+
"@nuxt/nitro-server": "^4.6.0",
|
|
70
|
+
"@nuxt/schema": "^4.6.0",
|
|
71
|
+
"@nuxt/test-utils": "^4.0.3",
|
|
72
|
+
"@nuxt/ui": "4.10.0",
|
|
73
|
+
"@types/node": "^22.15.0",
|
|
74
|
+
"@vue/compiler-core": "^3.5.27",
|
|
75
|
+
"@vue/compiler-sfc": "^3.5.27",
|
|
76
|
+
"changelogen": "^0.6.2",
|
|
77
|
+
"embla-carousel": "8.6.0",
|
|
78
|
+
"esbuild": "^0.25.0",
|
|
79
|
+
"eslint": "^10.4.1",
|
|
80
|
+
"firebase": "^12.8.0",
|
|
81
|
+
"nuxt": "^4.6.0",
|
|
82
|
+
"nuxt-vuefire": "1.1.0",
|
|
83
|
+
"pinia": "^3.0.4",
|
|
84
|
+
"tailwindcss": "^4.1.18",
|
|
85
|
+
"typescript": "~5.9.3",
|
|
86
|
+
"unbuild": "^3.6.1",
|
|
87
|
+
"vite": "^8.3.2",
|
|
88
|
+
"vitest": "^4.1.8",
|
|
89
|
+
"vue": "^3.5.27",
|
|
90
|
+
"vue-tsc": "^3.3.3",
|
|
91
|
+
"vuefire": "^3.2.2",
|
|
92
|
+
"zod": "^4.0.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@nuxt/ui": "^4.0.0",
|
|
96
|
+
"firebase": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
97
|
+
"nuxt": "^4.2.0",
|
|
98
|
+
"nuxt-vuefire": "^1.1.0",
|
|
99
|
+
"pinia": "^3.0.0",
|
|
100
|
+
"vue": "^3.5.0",
|
|
101
|
+
"vuefire": ">=3.2.2",
|
|
102
|
+
"zod": "^4.0.0"
|
|
103
|
+
},
|
|
104
|
+
"peerDependenciesMeta": {
|
|
105
|
+
"@nuxt/ui": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"zod": {
|
|
109
|
+
"optional": true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"scripts": {
|
|
113
|
+
"dev": "pnpm run dev:prepare && nuxt dev playground",
|
|
114
|
+
"dev:build": "nuxt build playground",
|
|
115
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
116
|
+
"prepare:module": "nuxt-module-build build --stub && nuxt-module-build prepare",
|
|
117
|
+
"build": "nuxt-module-build build",
|
|
118
|
+
"lint": "eslint .",
|
|
119
|
+
"test": "vitest run",
|
|
120
|
+
"test:watch": "vitest watch",
|
|
121
|
+
"test:types": "vue-tsc --build --noEmit playground/tsconfig.json"
|
|
122
|
+
}
|
|
6
123
|
}
|