flightdesk 0.1.9 → 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.
Files changed (3) hide show
  1. package/main.js +18 -13
  2. package/main.js.map +2 -2
  3. package/package.json +1 -1
package/main.js CHANGED
@@ -3121,7 +3121,7 @@ function setActiveOrganization(orgId) {
3121
3121
  function updateOrganizations(orgs) {
3122
3122
  const config = loadConfig();
3123
3123
  config.organizations = orgs;
3124
- if (config.activeOrganization && !orgs.find((o) => o.id === config.activeOrganization)) {
3124
+ if (config.activeOrganization && !orgs.some((o) => o.id === config.activeOrganization)) {
3125
3125
  config.activeOrganization = orgs[0]?.id;
3126
3126
  }
3127
3127
  saveConfig(config);
@@ -3372,9 +3372,8 @@ var FlightDeskAPI = class _FlightDeskAPI {
3372
3372
  return result.userTaskPrompts;
3373
3373
  }
3374
3374
  };
3375
- async function fetchUserInfo(apiKey, apiUrl) {
3376
- const url = apiUrl || "https://api.flightdesk.dev";
3377
- const response = await fetch(`${url}/graphql`, {
3375
+ async function fetchUserInfo(apiKey, apiUrl = "https://api.flightdesk.dev") {
3376
+ const response = await fetch(`${apiUrl}/graphql`, {
3378
3377
  method: "POST",
3379
3378
  headers: {
3380
3379
  "Content-Type": "application/json",
@@ -3384,7 +3383,10 @@ async function fetchUserInfo(apiKey, apiUrl) {
3384
3383
  query: `{
3385
3384
  me {
3386
3385
  id
3387
- email
3386
+ emails {
3387
+ email
3388
+ primary
3389
+ }
3388
3390
  organizations {
3389
3391
  organization {
3390
3392
  id
@@ -3448,15 +3450,17 @@ async function initCommand() {
3448
3450
  console.log("\nConnecting to FlightDesk...");
3449
3451
  try {
3450
3452
  const userInfo = await fetchUserInfo(apiKey, apiUrl);
3451
- if (userInfo.organizations.length === 0) {
3453
+ const orgs = userInfo.organizations || [];
3454
+ if (orgs.length === 0) {
3452
3455
  console.error("\u274C No organizations found for this user");
3453
3456
  console.log("Please make sure you are a member of at least one organization.");
3454
3457
  return;
3455
3458
  }
3459
+ const primaryEmail = userInfo.emails?.find((e) => e.primary)?.email || userInfo.emails?.[0]?.email || "unknown";
3456
3460
  console.log("\u2705 Connection successful!");
3457
- console.log(` Logged in as: ${userInfo.email}`);
3458
- console.log(` Organizations: ${userInfo.organizations.length}`);
3459
- const organizations = userInfo.organizations.map((m) => ({
3461
+ console.log(` Logged in as: ${primaryEmail}`);
3462
+ console.log(` Organizations: ${orgs.length}`);
3463
+ const organizations = orgs.map((m) => ({
3460
3464
  id: m.organization.id,
3461
3465
  name: m.organization.name
3462
3466
  }));
@@ -3472,7 +3476,7 @@ async function initCommand() {
3472
3476
  });
3473
3477
  const choice = await question(rl, `
3474
3478
  Select active organization (1-${organizations.length}): `);
3475
- const choiceIndex = parseInt(choice, 10) - 1;
3479
+ const choiceIndex = Number.parseInt(choice, 10) - 1;
3476
3480
  if (choiceIndex < 0 || choiceIndex >= organizations.length) {
3477
3481
  console.error("Invalid selection, using first organization");
3478
3482
  activeOrganization = organizations[0].id;
@@ -4249,11 +4253,12 @@ async function orgRefreshCommand() {
4249
4253
  try {
4250
4254
  const apiUrl = getApiUrl();
4251
4255
  const userInfo = await fetchUserInfo(config.apiKey, apiUrl);
4252
- if (userInfo.organizations.length === 0) {
4256
+ const orgs = userInfo.organizations || [];
4257
+ if (orgs.length === 0) {
4253
4258
  console.log("No organizations found for this user.");
4254
4259
  return;
4255
4260
  }
4256
- const organizations = userInfo.organizations.map((m) => ({
4261
+ const organizations = orgs.map((m) => ({
4257
4262
  id: m.organization.id,
4258
4263
  name: m.organization.name
4259
4264
  }));
@@ -4791,7 +4796,7 @@ async function scanClaudeSessions(options) {
4791
4796
 
4792
4797
  // apps/cli/src/main.ts
4793
4798
  var program2 = new Command();
4794
- program2.name("flightdesk").description("FlightDesk CLI - AI task management for Claude Code sessions").version("0.1.9").option("--dev", "Use local development API (localhost:3000)").option("--api <url>", "Use custom API URL");
4799
+ program2.name("flightdesk").description("FlightDesk CLI - AI task management for Claude Code sessions").version("0.1.11").option("--dev", "Use local development API (localhost:3000)").option("--api <url>", "Use custom API URL");
4795
4800
  program2.hook("preAction", () => {
4796
4801
  const opts = program2.opts();
4797
4802
  if (opts.api) {