"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.queryKeys = exports.invalidateUserQueries = exports.invalidateSessionQueries = exports.invalidateAccountQueries = void 0;
/**
 * Centralized query keys for TanStack Query
 * 
 * Following best practices:
 * - Use arrays for hierarchical keys
 * - Include all parameters in the key
 * - Use consistent naming conventions
 */

const queryKeys = exports.queryKeys = {
  // Account queries
  accounts: {
    all: ['accounts'],
    lists: () => [...queryKeys.accounts.all, 'list'],
    list: sessionIds => [...queryKeys.accounts.lists(), sessionIds],
    details: () => [...queryKeys.accounts.all, 'detail'],
    detail: sessionId => [...queryKeys.accounts.details(), sessionId],
    current: () => [...queryKeys.accounts.all, 'current'],
    settings: () => [...queryKeys.accounts.all, 'settings']
  },
  // User queries
  users: {
    all: ['users'],
    lists: () => [...queryKeys.users.all, 'list'],
    list: userIds => [...queryKeys.users.lists(), userIds],
    details: () => [...queryKeys.users.all, 'detail'],
    detail: userId => [...queryKeys.users.details(), userId],
    profile: sessionId => [...queryKeys.users.details(), sessionId, 'profile']
  },
  // Session queries
  sessions: {
    all: ['sessions'],
    lists: () => [...queryKeys.sessions.all, 'list'],
    list: userId => [...queryKeys.sessions.lists(), userId],
    details: () => [...queryKeys.sessions.all, 'detail'],
    detail: sessionId => [...queryKeys.sessions.details(), sessionId],
    active: () => [...queryKeys.sessions.all, 'active'],
    device: deviceId => [...queryKeys.sessions.all, 'device', deviceId]
  },
  // Device queries
  devices: {
    all: ['devices'],
    lists: () => [...queryKeys.devices.all, 'list'],
    list: userId => [...queryKeys.devices.lists(), userId],
    details: () => [...queryKeys.devices.all, 'detail'],
    detail: deviceId => [...queryKeys.devices.details(), deviceId]
  }
};

/**
 * Helper to invalidate all account-related queries
 */
const invalidateAccountQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.accounts.all
  });
};

/**
 * Helper to invalidate all user-related queries
 */
exports.invalidateAccountQueries = invalidateAccountQueries;
const invalidateUserQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.users.all
  });
};

/**
 * Helper to invalidate all session-related queries
 */
exports.invalidateUserQueries = invalidateUserQueries;
const invalidateSessionQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.sessions.all
  });
};
exports.invalidateSessionQueries = invalidateSessionQueries;
//# sourceMappingURL=queryKeys.js.map