@dooer/dooer-test-env 1.1.0 → 1.2.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 +14 -0
- package/lib/command/customer.js +1 -0
- package/package.json +1 -1
package/lib/account.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// - service_accounts.companies2users the given user linked as role 'Owner'
|
|
8
8
|
// - service_accounts.subscriptions the same active set Ghost Inspector has on staging
|
|
9
9
|
// - service_accounts."partnerOrganization" the org placed under partner `dooer` by default
|
|
10
|
+
// - service_accounts."tosAcceptance" the current Terms of Service pre-accepted (so sumify doesn't block)
|
|
10
11
|
// It does NOT add customer data (ledger, documents, tasks, …) — the account starts empty.
|
|
11
12
|
|
|
12
13
|
const crypto = require('crypto')
|
|
@@ -117,6 +118,19 @@ async function createAccount({ local, name, ownerUserId, execute = false } = {})
|
|
|
117
118
|
VALUES ($1,$2,$3,now(),now())`,
|
|
118
119
|
[uuid(), partner.rows[0].id, orgId]
|
|
119
120
|
)
|
|
121
|
+
// Pre-accept the current Terms of Service so the account is ready to use (sumify otherwise prompts and
|
|
122
|
+
// blocks). Accept every active tos (usedFrom passed, not yet ended), acceptedBy the owner.
|
|
123
|
+
const activeTos = await client.query(
|
|
124
|
+
'SELECT id FROM service_accounts.tos WHERE "usedFrom" <= now() AND ("usedTo" IS NULL OR "usedTo" > now())'
|
|
125
|
+
)
|
|
126
|
+
for (const row of activeTos.rows) {
|
|
127
|
+
await client.query(
|
|
128
|
+
`INSERT INTO service_accounts."tosAcceptance" (id, "tosId", "organizationId", "acceptedBy", "createdAt", "updatedAt")
|
|
129
|
+
VALUES ($1,$2,$3,$4,now(),now())`,
|
|
130
|
+
[uuid(), row.id, orgId, ownerUserId]
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
plan.tosAccepted = activeTos.rowCount
|
|
120
134
|
await client.query('COMMIT')
|
|
121
135
|
return plan
|
|
122
136
|
} catch (e) {
|
package/lib/command/customer.js
CHANGED
|
@@ -99,6 +99,7 @@ module.exports = {
|
|
|
99
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
|
+
console.log(` TOS: ${res.tosAccepted} version(s) pre-accepted`)
|
|
102
103
|
}
|
|
103
104
|
if (res.warning) console.log(chalk.yellow(`\n⚠ ${res.warning}`))
|
|
104
105
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooer/dooer-test-env",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|