@constructive-io/seeder 0.5.2 → 0.5.3
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/dist/bin.js +13 -20
- package/dist/bin.js.map +1 -1
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -22,7 +22,7 @@ import { z } from 'zod';
|
|
|
22
22
|
|
|
23
23
|
// package.json
|
|
24
24
|
var package_default = {
|
|
25
|
-
version: "0.5.
|
|
25
|
+
version: "0.5.3"};
|
|
26
26
|
|
|
27
27
|
// src/blueprints/base.ts
|
|
28
28
|
function getProvisionedTableNames(blueprint) {
|
|
@@ -20142,22 +20142,6 @@ async function promptForCredentials(config) {
|
|
|
20142
20142
|
prompter.close();
|
|
20143
20143
|
}
|
|
20144
20144
|
}
|
|
20145
|
-
async function login(credentials, endpoint) {
|
|
20146
|
-
const db = createSchemaBuilderClient(endpoint);
|
|
20147
|
-
try {
|
|
20148
|
-
const res = await db.mutation.signIn(
|
|
20149
|
-
{ input: { email: credentials.email, password: credentials.password, rememberMe: true } },
|
|
20150
|
-
{ select: { result: { select: { accessToken: true, userId: true } } } }
|
|
20151
|
-
).unwrap();
|
|
20152
|
-
const token = res?.signIn?.result?.accessToken;
|
|
20153
|
-
const userId = res?.signIn?.result?.userId;
|
|
20154
|
-
assert(token, "No access token returned from signIn");
|
|
20155
|
-
assert(userId, "No user ID returned from signIn");
|
|
20156
|
-
return { token, userId };
|
|
20157
|
-
} catch (error) {
|
|
20158
|
-
throw new Error(`Login failed: ${getErrorMessage(error)}`);
|
|
20159
|
-
}
|
|
20160
|
-
}
|
|
20161
20145
|
async function registerTestUser(endpoint, email, password) {
|
|
20162
20146
|
const db = createSchemaBuilderClient(endpoint);
|
|
20163
20147
|
try {
|
|
@@ -20220,7 +20204,8 @@ async function provisionDatabase(db, options) {
|
|
|
20220
20204
|
domain: options.domain,
|
|
20221
20205
|
subdomain: options.subdomain || void 0,
|
|
20222
20206
|
ownerId: options.ownerId,
|
|
20223
|
-
modules: ["all"]
|
|
20207
|
+
modules: ["all"],
|
|
20208
|
+
bootstrapUser: true
|
|
20224
20209
|
},
|
|
20225
20210
|
select: {
|
|
20226
20211
|
id: true,
|
|
@@ -22394,9 +22379,9 @@ Endpoint: ${config.endpoint}`);
|
|
|
22394
22379
|
console.log("");
|
|
22395
22380
|
logStep("Authenticating with schema builder");
|
|
22396
22381
|
const credentials = await promptForCredentials(config);
|
|
22397
|
-
const authResult = await
|
|
22382
|
+
const authResult = await loginOrRegister(config.endpoint, credentials.email, credentials.password);
|
|
22398
22383
|
const { token, userId } = authResult;
|
|
22399
|
-
logOk(`
|
|
22384
|
+
logOk(`Authenticated as user ${mask(userId)}`);
|
|
22400
22385
|
if (config.dryRun) {
|
|
22401
22386
|
logWarn("Dry run mode - skipping provisioning");
|
|
22402
22387
|
return;
|
|
@@ -22431,6 +22416,14 @@ Endpoint: ${config.endpoint}`);
|
|
|
22431
22416
|
authenticatedRoleName: topology.dataRoleName
|
|
22432
22417
|
}
|
|
22433
22418
|
);
|
|
22419
|
+
logStep("Registering admin user on per-database auth...");
|
|
22420
|
+
await sleep(5e3);
|
|
22421
|
+
try {
|
|
22422
|
+
const perDbAuth = await loginOrRegister(topology.authEndpoint, credentials.email, credentials.password);
|
|
22423
|
+
logOk(`Per-database admin user ready: ${mask(perDbAuth.userId)}`);
|
|
22424
|
+
} catch (error) {
|
|
22425
|
+
logWarn(`Per-database admin registration deferred: ${error instanceof Error ? error.message : String(error)}`);
|
|
22426
|
+
}
|
|
22434
22427
|
const seededRowCounts = {};
|
|
22435
22428
|
let seedUserId;
|
|
22436
22429
|
if (dataset && preset) {
|