salesprompter-cli 0.1.30 → 0.1.32

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/auth.js CHANGED
@@ -15,7 +15,9 @@ const UserSchema = z.object({
15
15
  name: nullableOptionalString,
16
16
  orgId: nullableOptionalString,
17
17
  orgName: nullableOptionalString,
18
- orgSlug: nullableOptionalString
18
+ orgSlug: nullableOptionalString,
19
+ workspaceClientId: nullableOptionalString,
20
+ workspaceClientName: nullableOptionalString
19
21
  });
20
22
  const AuthSessionSchema = z.object({
21
23
  accessToken: z.string().min(1),
@@ -84,6 +86,8 @@ const WhoAmIResponseSchema = z
84
86
  orgId: nullableOptionalString,
85
87
  orgName: nullableOptionalString,
86
88
  orgSlug: nullableOptionalString,
89
+ workspaceClientId: nullableOptionalString,
90
+ workspaceClientName: nullableOptionalString,
87
91
  expiresAt: z.string().datetime().optional()
88
92
  }),
89
93
  z.object({
@@ -107,7 +111,9 @@ const WhoAmIResponseSchema = z
107
111
  name: value.name,
108
112
  orgId: value.orgId,
109
113
  orgName: value.orgName,
110
- orgSlug: value.orgSlug
114
+ orgSlug: value.orgSlug,
115
+ workspaceClientId: value.workspaceClientId,
116
+ workspaceClientName: value.workspaceClientName
111
117
  },
112
118
  expiresAt: value.expiresAt
113
119
  };
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { setTimeout as delay } from "node:timers/promises";
10
10
  import { createClient } from "@supabase/supabase-js";
11
11
  import { Command } from "commander";
12
12
  import { z } from "zod";
13
- import { clearAuthSession, loginWithBrowserConnect, loginWithDeviceFlow, loginWithToken, requireAuthSession, shouldBypassAuth, verifySession } from "./auth.js";
13
+ import { clearAuthSession, loginWithBrowserConnect, loginWithDeviceFlow, loginWithToken, requireAuthSession, shouldBypassAuth, verifySession, writeAuthSession } from "./auth.js";
14
14
  import { buildBigQueryLeadLookupSql, executeBigQuerySql, normalizeBigQueryLeadRows, runBigQueryQuery, runBigQueryRows } from "./bigquery.js";
15
15
  import { AccountProfileSchema, EnrichedLeadSchema, IcpSchema, LeadSchema, ScoredLeadSchema, SyncTargetSchema } from "./domain.js";
16
16
  import { auditDomainDecisions, buildDomainfinderBacklogQueries, buildDomainfinderCandidatesSql, buildDomainfinderInputSql, buildDomainfinderWritebackSql, buildExistingDomainRepairSql, buildExistingDomainAuditQueries, compareDomainSelectionStrategies, selectBestDomains } from "./domainfinder.js";
@@ -2540,9 +2540,24 @@ function writeWizardSection(title, description) {
2540
2540
  }
2541
2541
  writeWizardLine();
2542
2542
  }
2543
+ function compactOptionalText(value) {
2544
+ const compacted = value?.trim();
2545
+ return compacted && compacted.length > 0 ? compacted : null;
2546
+ }
2543
2547
  function getOrgLabel(session) {
2544
- const label = session.user.orgName ?? session.user.orgSlug ?? session.user.orgId ?? null;
2545
- return label;
2548
+ const orgName = compactOptionalText(session.user.orgName) ?? compactOptionalText(session.user.workspaceClientName);
2549
+ const orgSlug = compactOptionalText(session.user.orgSlug);
2550
+ const orgId = compactOptionalText(session.user.orgId);
2551
+ const workspaceClientId = compactOptionalText(session.user.workspaceClientId);
2552
+ if (orgName) {
2553
+ const clientLabel = workspaceClientId ? `client ${workspaceClientId}` : null;
2554
+ const details = [orgSlug, clientLabel, orgId].filter((value) => Boolean(value));
2555
+ return details.length > 0 ? `${orgName} (${details.join(", ")})` : orgName;
2556
+ }
2557
+ if (orgSlug) {
2558
+ return orgId ? `${orgSlug} (${orgId})` : orgSlug;
2559
+ }
2560
+ return orgId;
2546
2561
  }
2547
2562
  function resolveSessionOrgId(session) {
2548
2563
  const orgId = session.user.orgId?.trim();
@@ -2771,7 +2786,9 @@ async function ensureWizardSession(options) {
2771
2786
  };
2772
2787
  }
2773
2788
  try {
2774
- const session = await requireAuthSession();
2789
+ const cachedSession = await requireAuthSession();
2790
+ const session = await verifySession(cachedSession);
2791
+ await writeAuthSession(session);
2775
2792
  writeSessionSummary(session);
2776
2793
  writeWizardLine();
2777
2794
  return {
@@ -2800,9 +2817,32 @@ async function ensureWizardSession(options) {
2800
2817
  }
2801
2818
  async function confirmWizardWorkspace(rl, session, options) {
2802
2819
  const orgLabel = getOrgLabel(session);
2803
- const promptLabel = orgLabel ? `workspace ${orgLabel}` : "this signed-in account without a selected workspace";
2804
- const useCurrentWorkspace = await promptYesNo(rl, `Use ${promptLabel} for this CLI run?`, true);
2805
- if (useCurrentWorkspace) {
2820
+ const hasNamedOrg = Boolean(compactOptionalText(session.user.orgName) || compactOptionalText(session.user.orgSlug));
2821
+ const currentLabel = orgLabel
2822
+ ? hasNamedOrg
2823
+ ? `Use ${orgLabel}`
2824
+ : `Use current workspace (${orgLabel})`
2825
+ : "Use signed-in account without a selected workspace";
2826
+ const currentDescription = orgLabel
2827
+ ? hasNamedOrg
2828
+ ? "Current cached CLI workspace"
2829
+ : "Workspace name is not available in this cached token"
2830
+ : "Choose another workspace in the browser if this account belongs to more than one";
2831
+ const workspaceChoice = await promptChoice(rl, "Which workspace should I use?", [
2832
+ {
2833
+ value: "current",
2834
+ label: currentLabel,
2835
+ description: currentDescription,
2836
+ aliases: ["current", "cached", "this workspace", "use current"]
2837
+ },
2838
+ {
2839
+ value: "browser",
2840
+ label: "Choose another workspace in the browser",
2841
+ description: "Opens Salesprompter so you can pick from your organizations",
2842
+ aliases: ["browser", "choose another", "switch workspace", "select organization"]
2843
+ }
2844
+ ], "current");
2845
+ if (workspaceChoice === "current") {
2806
2846
  writeWizardLine();
2807
2847
  return session;
2808
2848
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "salesprompter-cli",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Sales workflow CLI for guided lead generation, enrichment, scoring, and sync.",
5
5
  "author": "Daniel Sinewe <hello@danielsinewe.com>",
6
6
  "type": "module",