@mostajs/setup 2.1.1 → 2.1.2

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.
@@ -102,6 +102,22 @@ function buildConfig(json, repoFactory) {
102
102
  }
103
103
  };
104
104
  }
105
+ // ── createAdmin (generic — uses repoFactory for 'user' + 'role') ──
106
+ config.createAdmin = async ({ email, hashedPassword, firstName, lastName }) => {
107
+ const getRepo = repoFactory ?? defaultRepoFactory;
108
+ const userRepo = await getRepo('user');
109
+ const roleRepo = await getRepo('role');
110
+ // Resolve admin role (seeded in RBAC step just before)
111
+ const adminRole = await roleRepo.findOne({ name: 'admin' });
112
+ await userRepo.create({
113
+ email,
114
+ password: hashedPassword,
115
+ firstName,
116
+ lastName,
117
+ status: 'active',
118
+ roles: adminRole ? [adminRole.id] : [],
119
+ });
120
+ };
105
121
  // ── optionalSeeds ──────────────────────────────────────
106
122
  if (json.seeds?.length) {
107
123
  config.optionalSeeds = json.seeds.map(seedDef => buildSeedDefinition(seedDef, repoFactory));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/setup",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Reusable setup wizard module — multi-dialect DB configuration, .env.local writer, seed runner",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "MIT",