@sendhoney/cli 0.1.10 → 0.1.11

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 CHANGED
@@ -11,7 +11,7 @@ SendHoney platform CLI for authenticated API, CRUD, release, and ThunderCompute
11
11
  npm install -g @sendhoney/cli
12
12
 
13
13
  # npm (pinned)
14
- npm install -g @sendhoney/cli@0.1.10
14
+ npm install -g @sendhoney/cli@0.1.11
15
15
 
16
16
  # Homebrew
17
17
  brew tap sendhoney/tap && brew install sendhoney
package/bin/sendhoney CHANGED
@@ -114,7 +114,7 @@ function json(value) { process.stdout.write(`${JSON.stringify(value, null, 2)}\n
114
114
  function die(message, code = 1) { process.stderr.write(`sendhoney: ${message}\n`); process.exit(code) }
115
115
  function organizationIdFrom(value) {
116
116
  if (!value || typeof value !== 'object') return ''
117
- return String(value.orgId || value.organizationId || value.tenantId || value.organization?.id || value.organization?.orgId || value.workspace?.organizationId || value.organizations?.[0]?.id || '').trim()
117
+ return String(value.orgId || value.org_id || value.organizationId || value.tenantId || value.organization?.id || value.organization?.orgId || value.workspace?.organizationId || value.organizations?.[0]?.id || '').trim()
118
118
  }
119
119
 
120
120
  async function persistLoginSession(config, args, auth, tokens) {
@@ -125,8 +125,18 @@ async function persistLoginSession(config, args, auth, tokens) {
125
125
  fetch(`${apiUrl.replace(/\/$/, '')}/api/v1/org/me`, { headers }).catch(() => null),
126
126
  ])
127
127
  const user = userResponse ? await userResponse.json().catch(() => ({})) : {}
128
- const organization = orgResponse ? await orgResponse.json().catch(() => ({})) : {}
129
- const orgId = organizationIdFrom(organization)
128
+ let organization = orgResponse ? await orgResponse.json().catch(() => ({})) : {}
129
+ let orgId = organizationIdFrom(organization)
130
+ if (!orgId && user.email) {
131
+ const onboardingResponse = await fetch(`${apiUrl.replace(/\/$/, '')}/organizations/onboarding-status?email=${encodeURIComponent(user.email)}`, { headers }).catch(() => null)
132
+ const onboarding = onboardingResponse ? await onboardingResponse.json().catch(() => ({})) : {}
133
+ orgId = organizationIdFrom(onboarding)
134
+ if (orgId) {
135
+ const organizationResponse = await fetch(`${apiUrl.replace(/\/$/, '')}/organizations/${encodeURIComponent(orgId)}`, { headers }).catch(() => null)
136
+ const fullOrganization = organizationResponse ? await organizationResponse.json().catch(() => ({})) : {}
137
+ organization = { ...onboarding, ...fullOrganization, orgId }
138
+ }
139
+ }
130
140
  const session = { authenticated: true, authenticatedAt: new Date().toISOString(), user, organization, orgId: orgId || undefined }
131
141
  saveConfig({
132
142
  ...config, apiUrl, authUrl: auth.authUrl, realm: auth.realm, clientId: auth.clientId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendhoney/cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "SendHoney platform CLI for authenticated API, CRUD, release, and ThunderCompute operations.",
5
5
  "private": false,
6
6
  "bin": { "sendhoney": "bin/sendhoney" },