@dooer/dooer-test-env 1.0.3 → 1.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/lib/account.js +15 -3
- package/lib/command/customer.js +2 -1
- package/package.json +1 -1
package/lib/account.js
CHANGED
|
@@ -50,10 +50,20 @@ async function createAccount({ local, name, ownerUserId, execute = false } = {})
|
|
|
50
50
|
const client = new Client({ ...local, ssl: local.ssl === false ? undefined : { rejectUnauthorized: false } })
|
|
51
51
|
await client.connect()
|
|
52
52
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// user_type is the fk_user_roles_at_dooer_pk column (User model). Only 'customer' users get a
|
|
54
|
+
// type:'customer' login token; a 'hi'/admin user is blocked from customer-only flows (e.g. accepting
|
|
55
|
+
// Terms of Service in sumify → "only-owner-can-accept-tos"). Warn if the owner isn't a customer.
|
|
56
|
+
const owner = await client.query(
|
|
57
|
+
'SELECT users_pk, email, fk_user_roles_at_dooer_pk AS user_type FROM service_accounts.users WHERE users_pk=$1',
|
|
58
|
+
[ownerUserId]
|
|
59
|
+
)
|
|
56
60
|
if (!owner.rowCount) throw new Error(`owner user ${ownerUserId} not found in the local DB (run \`db pull\` first?)`)
|
|
61
|
+
const ownerType = owner.rows[0].user_type
|
|
62
|
+
const warning =
|
|
63
|
+
ownerType === 'customer'
|
|
64
|
+
? null
|
|
65
|
+
: `owner ${ownerUserId} is a '${ownerType}' user, not 'customer' — customer-only flows ` +
|
|
66
|
+
`(e.g. accepting Terms of Service in sumify) will fail. Use a customer user as the owner.`
|
|
57
67
|
|
|
58
68
|
const partner = await client.query('SELECT id, name FROM service_accounts.partner WHERE domain=$1', [
|
|
59
69
|
DEFAULT_PARTNER_DOMAIN,
|
|
@@ -67,8 +77,10 @@ async function createAccount({ local, name, ownerUserId, execute = false } = {})
|
|
|
67
77
|
name,
|
|
68
78
|
shortName,
|
|
69
79
|
owner: owner.rows[0].email,
|
|
80
|
+
ownerType,
|
|
70
81
|
partner: DEFAULT_PARTNER_DOMAIN,
|
|
71
82
|
subscriptions: SUBSCRIPTION_TYPES,
|
|
83
|
+
warning,
|
|
72
84
|
}
|
|
73
85
|
if (!execute) {
|
|
74
86
|
console.log('DRY-RUN (pass --execute to create):')
|
package/lib/command/customer.js
CHANGED
|
@@ -96,10 +96,11 @@ module.exports = {
|
|
|
96
96
|
console.log(chalk.green(`\ncreated account "${res.name}"`))
|
|
97
97
|
console.log(` org id: ${res.orgId}`)
|
|
98
98
|
console.log(` short name: ${res.shortName}`)
|
|
99
|
-
console.log(` owner: ${argv.owner} (${res.owner}) — role Owner`)
|
|
99
|
+
console.log(` owner: ${argv.owner} (${res.owner}) — role Owner, user_type '${res.ownerType}'`)
|
|
100
100
|
console.log(` partner: ${res.partner}`)
|
|
101
101
|
console.log(` subscriptions: ${SUBSCRIPTION_TYPES.join(', ')} (active)`)
|
|
102
102
|
}
|
|
103
|
+
if (res.warning) console.log(chalk.yellow(`\n⚠ ${res.warning}`))
|
|
103
104
|
},
|
|
104
105
|
})
|
|
105
106
|
.demandCommand(1, 'Use: customer copy | customer purge | customer new')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooer/dooer-test-env",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Run the whole Dooer backend locally (staging DB minus customers), copy/purge customers between environments, and shred — one CLI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": "Dooer/cli-dooer-test-env",
|