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

98.27% Statements 57/58
100% Branches 3/3
32.14% Functions 9/28
100% Lines 41/41

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 30 31 32 33 34 35 36 37 38 39 40 41 421x 1x 1x 1x 1x 1x 142x 159x 143x 143x 143x 143x 143x 143x 1x 1x 142x 143x 143x 143x 143x 142x 142x 142x 142x 142x 143x 143x 143x 143x 146x 143x 1x 1x 142x 143x 143x 143x 143x 143x 1x  
import { type Quota } from '@amalia/amalia-lang/tokens/types';
import { type SearchQuotasWithAssignedPlansRequest } from '@amalia/assignments/quotas/types';
import { type UnixTimestampInSeconds } from '@amalia/ext/dates';
import { type Plan } from '@amalia/payout-definition/plans/types';
import { type UserContract } from '@amalia/tenants/users/types';
 
export const quotasQueryKeys = {
  all: () => ['quotas'] as const,
  withAssignedPlans: {
    all: () => [...quotasQueryKeys.all(), 'with-assigned-plans'] as const,
    list: (request?: SearchQuotasWithAssignedPlansRequest) =>
      [...quotasQueryKeys.withAssignedPlans.all(), 'list', request] as const,
    details: (quotaId: Quota['id']) => [...quotasQueryKeys.withAssignedPlans.all(), 'details', quotaId] as const,
  } as const,
} as const;
 
export const quotaAssignmentsQueryKeys = {
  all: () => ['quota-assignments'] as const,
  ofVariable: {
    all: (variableId: Quota['id']) => [...quotaAssignmentsQueryKeys.all(), 'of-variable', variableId] as const,
    list: (
      variableId: Quota['id'],
      startDate: UnixTimestampInSeconds,
      endDate: UnixTimestampInSeconds,
      planIds?: Plan['id'][],
    ) => [...quotaAssignmentsQueryKeys.ofVariable.all(variableId), startDate, endDate, planIds] as const,
  } as const,
  ofUser: {
    all: (userId: UserContract['id']) => [...quotaAssignmentsQueryKeys.all(), 'of-user', userId] as const,
    list: (userId: UserContract['id'], startDate?: Date | null, endDate?: Date | null) =>
      [...quotaAssignmentsQueryKeys.ofUser.all(userId), startDate, endDate] as const,
  },
} as const;
 
export const quotaAssignmentsMutationKeys = {
  all: () => ['quota-assignments'] as const,
  upsertOne: () => [...quotaAssignmentsMutationKeys.all(), 'upsert-one'] as const,
  upsertMany: () => [...quotaAssignmentsMutationKeys.all(), 'upsert-many'] as const,
  deleteOne: () => [...quotaAssignmentsMutationKeys.all(), 'delete-one'] as const,
  deleteMany: () => [...quotaAssignmentsMutationKeys.all(), 'delete-many'] as const,
} as const;