@hapl/api-queries 1.0.0 → 1.0.1--canary.231.8b1452d.0

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.
@@ -1,8 +1,11 @@
1
1
  import { AxiosResponse, AxiosError } from 'axios';
2
- import { ExpertGrade, ExpertGradeType } from '../../types';
2
+ import { ExpertGradePossibleEmpty, ExpertGradeType } from '../../types';
3
+ declare type Data = ExpertGradePossibleEmpty & {
4
+ _id: string;
5
+ };
3
6
  declare type ResultData = {
4
- ids: number[];
5
- byId: Record<string, ExpertGrade>;
7
+ ids: string[];
8
+ byId: Record<string, Data>;
6
9
  meta: {
7
10
  total: number;
8
11
  };
@@ -17,9 +17,12 @@ export declare type ExpertGrade = {
17
17
  lastFourSeasonGross: MoneyAmount;
18
18
  lastSeasonGross: MoneyAmount;
19
19
  lastTwoSeasonGross: MoneyAmount;
20
- supervisor: Partial<User> & Required<Pick<User, 'id'>>;
21
20
  createdBy?: Partial<User> & Required<Pick<User, 'id'>>;
21
+ supervisor?: Partial<User> & Required<Pick<User, 'id'>>;
22
22
  };
23
+ declare type EmptyGradeOmittedFields = 'amount' | 'createdAt' | 'grade' | 'gradePercent' | 'id';
24
+ export declare type ExpertGradePossibleEmpty = Omit<ExpertGrade, EmptyGradeOmittedFields> & Partial<Pick<ExpertGrade, EmptyGradeOmittedFields>>;
23
25
  export declare type ShortExpertGrade = Pick<ExpertGrade, 'createdAt' | 'expert' | 'id' | 'grade' | 'gradePercent' | 'supervisor'> & {
24
26
  gross: number;
25
27
  };
28
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.0.1--canary.231.8b1452d.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,12 +1,15 @@
1
1
  import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
2
+ import { nanoid } from 'nanoid/non-secure';
2
3
  import qs from 'qs';
3
- import { ExpertGrade, ExpertGradeType } from '../../types';
4
+ import { ExpertGradePossibleEmpty, ExpertGradeType } from '../../types';
4
5
  import { DEFAULT_BASE_URL } from '../../../constants';
5
6
 
6
- type SuccessData = { success: true; data: ExpertGrade[]; pageParams: { length: number; page: number } };
7
+ type Data = ExpertGradePossibleEmpty & { _id: string };
8
+
9
+ type SuccessData = { success: true; data: Data[]; pageParams: { length: number; page: number } };
7
10
  type ErrorData = { success: false; data: { error: string } };
8
11
 
9
- type ResultData = { ids: number[]; byId: Record<string, ExpertGrade>; meta: { total: number } };
12
+ type ResultData = { ids: string[]; byId: Record<string, Data>; meta: { total: number } };
10
13
  type ResultError = string;
11
14
 
12
15
  export type FindExpertGradesHeaders = { 'x-auth-hc'?: string };
@@ -45,8 +48,9 @@ export function findExpertGradesRequest({ baseURL = DEFAULT_BASE_URL, headers, p
45
48
  const byId: ResultData['byId'] = {};
46
49
 
47
50
  data.data.forEach(entity => {
48
- byId[entity.id] = entity;
49
- ids.push(entity.id);
51
+ const _id = nanoid();
52
+ byId[_id] = { ...entity, _id };
53
+ ids.push(_id);
50
54
  });
51
55
 
52
56
  return { ids, byId, meta: { total: data.pageParams?.length || 0 } };
@@ -19,11 +19,16 @@ export type ExpertGrade = {
19
19
  lastFourSeasonGross: MoneyAmount;
20
20
  lastSeasonGross: MoneyAmount;
21
21
  lastTwoSeasonGross: MoneyAmount;
22
- supervisor: Partial<User> & Required<Pick<User, 'id'>>;
23
22
 
24
23
  createdBy?: Partial<User> & Required<Pick<User, 'id'>>;
24
+ supervisor?: Partial<User> & Required<Pick<User, 'id'>>;
25
25
  };
26
26
 
27
+ type EmptyGradeOmittedFields = 'amount' | 'createdAt' | 'grade' | 'gradePercent' | 'id';
28
+
29
+ export type ExpertGradePossibleEmpty = Omit<ExpertGrade, EmptyGradeOmittedFields> &
30
+ Partial<Pick<ExpertGrade, EmptyGradeOmittedFields>>;
31
+
27
32
  export type ShortExpertGrade = Pick<
28
33
  ExpertGrade,
29
34
  'createdAt' | 'expert' | 'id' | 'grade' | 'gradePercent' | 'supervisor'