All files / libs/assignments/plans/state/src/lib queries.keys.ts

100% Statements 29/29
100% Branches 5/5
30% Functions 3/10
100% Lines 29/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { type Plan } from '@amalia/payout-definition/plans/types';
import { type UserContract } from '@amalia/tenants/users/types';
 
import { type GetUserPlanAssignmentsOptions } from './api-client/user-plan-assignments.api-client';
 
export const planAssignmentsQueryKeys = {
  all: () => ['plan-assigments'] as const,
 
  allPlans: () => [...planAssignmentsQueryKeys.all(), 'plans'] as const,
  plan: (planId: Plan['id'], relations: 'user'[] = []) =>
    [...planAssignmentsQueryKeys.allPlans(), planId, relations] as const,
 
  allUsers: () => [...planAssignmentsQueryKeys.all(), 'users'] as const,
  user: (userId: UserContract['id'], options?: GetUserPlanAssignmentsOptions) =>
    [
      ...planAssignmentsQueryKeys.allUsers(),
      userId,
      options?.effectiveBetween?.start,
      options?.effectiveBetween?.end,
    ] as const,
} as const;
 
export const planAssignmentsMutationKeys = {
  all: () => ['plan-assigments'] as const,
  upsert: () => [...planAssignmentsMutationKeys.all(), 'upsert'] as const,
  upsertDryRun: () => [...planAssignmentsMutationKeys.all(), 'upsert-dry-run'] as const,
  update: () => [...planAssignmentsMutationKeys.all(), 'update'] as const,
  delete: () => [...planAssignmentsMutationKeys.all(), 'delete'] as const,
} as const;