@uidu/client 3.2.0 → 3.3.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.
- package/CHANGELOG.md +14 -0
- package/dist/declarations/src/generated/index.d.ts +48 -0
- package/dist/declarations/src/index.d.ts +2 -2
- package/dist/declarations/src/people.d.ts +47 -1
- package/dist/uidu-client.cjs.dev.js +76 -1
- package/dist/uidu-client.cjs.prod.js +76 -1
- package/dist/uidu-client.esm.js +75 -2
- package/package.json +1 -1
- package/src/generated/index.ts +10 -0
- package/src/index.ts +12 -1
- package/src/people.test.ts +78 -1
- package/src/people.ts +114 -0
- package/src/queries/people/ListEmploymentHistory.graphql +36 -0
package/package.json
CHANGED
package/src/generated/index.ts
CHANGED
|
@@ -49842,6 +49842,15 @@ export type ListEmployeesQueryVariables = Exact<{
|
|
|
49842
49842
|
|
|
49843
49843
|
export type ListEmployeesQuery = { __typename?: 'Query', currentWorkspace?: { __typename?: 'Workspace', employees: { __typename?: 'EmployeeConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, edges?: Array<{ __typename?: 'EmployeeEdge', node?: { __typename?: 'Employee', id: string, employeeCode?: string | null, user?: { __typename?: 'User', id: string, name?: string | null, firstName?: string | null, lastName?: string | null, email?: string | null } | null, currentEmployment?: { __typename?: 'Employment', id: string, jobTitle?: string | null, contractType?: string | null, isActive: boolean, startDate: any } | null } | null } | null> | null } } | null };
|
|
49844
49844
|
|
|
49845
|
+
export type ListEmploymentHistoryQueryVariables = Exact<{
|
|
49846
|
+
first?: InputMaybe<Scalars['Int']['input']>;
|
|
49847
|
+
after?: InputMaybe<Scalars['String']['input']>;
|
|
49848
|
+
employmentsFirst?: InputMaybe<Scalars['Int']['input']>;
|
|
49849
|
+
}>;
|
|
49850
|
+
|
|
49851
|
+
|
|
49852
|
+
export type ListEmploymentHistoryQuery = { __typename?: 'Query', currentWorkspace?: { __typename?: 'Workspace', employees: { __typename?: 'EmployeeConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, edges?: Array<{ __typename?: 'EmployeeEdge', node?: { __typename?: 'Employee', id: string, user?: { __typename?: 'User', id: string, name?: string | null, email?: string | null } | null, employments: { __typename?: 'EmploymentConnection', edges?: Array<{ __typename?: 'EmploymentEdge', node?: { __typename?: 'Employment', id: string, startDate: any, endDate?: any | null, endReason?: string | null, jobTitle?: string | null, contractType?: string | null } | null } | null> | null } } | null } | null> | null } } | null };
|
|
49853
|
+
|
|
49845
49854
|
export type ListKindsQueryVariables = Exact<{
|
|
49846
49855
|
models: Array<Scalars['String']['input']> | Scalars['String']['input'];
|
|
49847
49856
|
first?: InputMaybe<Scalars['Int']['input']>;
|
|
@@ -50069,6 +50078,7 @@ export const DeleteNoteDocument = {"kind":"Document","definitions":[{"kind":"Ope
|
|
|
50069
50078
|
export const GetEmployeeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetEmployee"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"weekStartingAt"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ISO8601Date"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"employee"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"employeeCode"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"firstName"}},{"kind":"Field","name":{"kind":"Name","value":"lastName"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}},{"kind":"Field","name":{"kind":"Name","value":"currentEmployment"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"jobTitle"}},{"kind":"Field","name":{"kind":"Name","value":"contractType"}},{"kind":"Field","name":{"kind":"Name","value":"contractLevel"}},{"kind":"Field","name":{"kind":"Name","value":"classification"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"startDate"}},{"kind":"Field","name":{"kind":"Name","value":"endDate"}},{"kind":"Field","name":{"kind":"Name","value":"fteRatio"}},{"kind":"Field","name":{"kind":"Name","value":"primaryOffice"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"todayTimeClocks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"beginsAt"}},{"kind":"Field","name":{"kind":"Name","value":"finishesAt"}},{"kind":"Field","name":{"kind":"Name","value":"kind"}}]}},{"kind":"Field","name":{"kind":"Name","value":"weeklyShifts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"weekStartingAt"},"value":{"kind":"Variable","name":{"kind":"Name","value":"weekStartingAt"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"20"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"beginsAt"}},{"kind":"Field","name":{"kind":"Name","value":"finishesAt"}},{"kind":"Field","name":{"kind":"Name","value":"aasmState"}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<GetEmployeeQuery, GetEmployeeQueryVariables>;
|
|
50070
50079
|
export const ListCirclesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ListCircles"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"circles"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"kind"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ListCirclesQuery, ListCirclesQueryVariables>;
|
|
50071
50080
|
export const ListEmployeesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ListEmployees"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"employees"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"employeeCode"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"firstName"}},{"kind":"Field","name":{"kind":"Name","value":"lastName"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}},{"kind":"Field","name":{"kind":"Name","value":"currentEmployment"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"jobTitle"}},{"kind":"Field","name":{"kind":"Name","value":"contractType"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"startDate"}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ListEmployeesQuery, ListEmployeesQueryVariables>;
|
|
50081
|
+
export const ListEmploymentHistoryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ListEmploymentHistory"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"employmentsFirst"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"employees"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}},{"kind":"Field","name":{"kind":"Name","value":"employments"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"employmentsFirst"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"startDate"}},{"kind":"Field","name":{"kind":"Name","value":"endDate"}},{"kind":"Field","name":{"kind":"Name","value":"endReason"}},{"kind":"Field","name":{"kind":"Name","value":"jobTitle"}},{"kind":"Field","name":{"kind":"Name","value":"contractType"}}]}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ListEmploymentHistoryQuery, ListEmploymentHistoryQueryVariables>;
|
|
50072
50082
|
export const ListKindsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ListKinds"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"models"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"kinds"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"models"},"value":{"kind":"Variable","name":{"kind":"Name","value":"models"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"model"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ListKindsQuery, ListKindsQueryVariables>;
|
|
50073
50083
|
export const ListOfficesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ListOffices"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"offices"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<ListOfficesQuery, ListOfficesQueryVariables>;
|
|
50074
50084
|
export const CreateEmployeeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateEmployee"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateEmployeeInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createEmployee"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"employee"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"employeeCode"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}}]}}]}}]} as unknown as DocumentNode<CreateEmployeeMutation, CreateEmployeeMutationVariables>;
|
package/src/index.ts
CHANGED
|
@@ -124,8 +124,19 @@ export {
|
|
|
124
124
|
listRoles,
|
|
125
125
|
listKinds,
|
|
126
126
|
listCcnls,
|
|
127
|
+
listEmploymentHistory,
|
|
128
|
+
contractEvents,
|
|
129
|
+
} from './people';
|
|
130
|
+
export type {
|
|
131
|
+
Employee,
|
|
132
|
+
Office,
|
|
133
|
+
Circle,
|
|
134
|
+
Kind,
|
|
135
|
+
EmploymentRecord,
|
|
136
|
+
EmployeeContracts,
|
|
137
|
+
ContractEvent,
|
|
138
|
+
ContractEventType,
|
|
127
139
|
} from './people';
|
|
128
|
-
export type { Employee, Office, Circle, Kind } from './people';
|
|
129
140
|
|
|
130
141
|
export {
|
|
131
142
|
getBooking,
|
package/src/people.test.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import type { UiduClient } from './client';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type EmployeeContracts,
|
|
5
|
+
contractEvents,
|
|
6
|
+
listCcnls,
|
|
7
|
+
listRoles,
|
|
8
|
+
weekStartFor,
|
|
9
|
+
} from './people';
|
|
4
10
|
|
|
5
11
|
/** Minimal fake client whose `query` returns a fixed `currentWorkspace` payload. */
|
|
6
12
|
function fakeClient(currentWorkspace: unknown) {
|
|
@@ -61,3 +67,74 @@ describe('listCcnls', () => {
|
|
|
61
67
|
expect(variables).toMatchObject({ models: ['Ccnl'] });
|
|
62
68
|
});
|
|
63
69
|
});
|
|
70
|
+
|
|
71
|
+
describe('contractEvents', () => {
|
|
72
|
+
const employees: EmployeeContracts[] = [
|
|
73
|
+
{
|
|
74
|
+
id: 'e1',
|
|
75
|
+
name: 'Alice',
|
|
76
|
+
employments: [
|
|
77
|
+
// deliberately out of order to exercise the sort
|
|
78
|
+
{
|
|
79
|
+
id: 'c2',
|
|
80
|
+
startDate: '2024-06-01',
|
|
81
|
+
endDate: '2025-03-31',
|
|
82
|
+
endReason: 'contract_end',
|
|
83
|
+
jobTitle: 'Senior Dev',
|
|
84
|
+
contractType: 'determinato',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'c1',
|
|
88
|
+
startDate: '2022-01-15',
|
|
89
|
+
endDate: null,
|
|
90
|
+
endReason: null,
|
|
91
|
+
jobTitle: 'Dev',
|
|
92
|
+
contractType: 'indeterminato',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'e2',
|
|
98
|
+
name: 'Bob',
|
|
99
|
+
employments: [
|
|
100
|
+
{
|
|
101
|
+
id: 'c3',
|
|
102
|
+
startDate: null, // no start date → ignored
|
|
103
|
+
endDate: null,
|
|
104
|
+
endReason: null,
|
|
105
|
+
jobTitle: null,
|
|
106
|
+
contractType: null,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
it('classifies first contract as hire and later ones as variation', () => {
|
|
113
|
+
const events = contractEvents(employees);
|
|
114
|
+
const alice = events.filter((e) => e.employeeId === 'e1');
|
|
115
|
+
expect(alice.find((e) => e.employmentId === 'c1')?.type).toBe('hire');
|
|
116
|
+
// c2 yields both a variation (on its start) and a termination (on its end).
|
|
117
|
+
const c2Types = alice.filter((e) => e.employmentId === 'c2').map((e) => e.type);
|
|
118
|
+
expect(c2Types).toContain('variation');
|
|
119
|
+
expect(c2Types).not.toContain('hire');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('emits a termination event for contracts with an end date', () => {
|
|
123
|
+
const events = contractEvents(employees);
|
|
124
|
+
const term = events.find((e) => e.type === 'termination');
|
|
125
|
+
expect(term).toMatchObject({
|
|
126
|
+
employmentId: 'c2',
|
|
127
|
+
date: '2025-03-31',
|
|
128
|
+
month: '2025-03',
|
|
129
|
+
endReason: 'contract_end',
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('ignores contracts without a start date and sorts most-recent first', () => {
|
|
134
|
+
const events = contractEvents(employees);
|
|
135
|
+
// Bob's undated contract produces no events.
|
|
136
|
+
expect(events.some((e) => e.employeeId === 'e2')).toBe(false);
|
|
137
|
+
const dates = events.map((e) => e.date);
|
|
138
|
+
expect(dates).toEqual([...dates].sort().reverse());
|
|
139
|
+
});
|
|
140
|
+
});
|
package/src/people.ts
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
type ListCirclesQueryVariables,
|
|
9
9
|
ListEmployeesDocument,
|
|
10
10
|
type ListEmployeesQueryVariables,
|
|
11
|
+
ListEmploymentHistoryDocument,
|
|
12
|
+
type ListEmploymentHistoryQueryVariables,
|
|
11
13
|
ListKindsDocument,
|
|
12
14
|
type ListKindsQuery,
|
|
13
15
|
type ListKindsQueryVariables,
|
|
@@ -134,3 +136,115 @@ export async function listCcnls(
|
|
|
134
136
|
): Promise<Kind[]> {
|
|
135
137
|
return listKinds(client, { ...variables, models: ['Ccnl'] });
|
|
136
138
|
}
|
|
139
|
+
|
|
140
|
+
// --- Employment history & contract events ---
|
|
141
|
+
|
|
142
|
+
/** A single contract (employment) reduced to the fields that describe its span. */
|
|
143
|
+
export type EmploymentRecord = {
|
|
144
|
+
id: string;
|
|
145
|
+
startDate: string | null;
|
|
146
|
+
endDate: string | null;
|
|
147
|
+
endReason: string | null;
|
|
148
|
+
jobTitle: string | null;
|
|
149
|
+
contractType: string | null;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** An employee together with their full list of contracts. */
|
|
153
|
+
export type EmployeeContracts = {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
employments: EmploymentRecord[];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* List every employee with their full employment (contract) history — not just
|
|
161
|
+
* the current one. Use {@link contractEvents} to turn this into a flat, dated
|
|
162
|
+
* list of hires, terminations and contract variations.
|
|
163
|
+
*/
|
|
164
|
+
export async function listEmploymentHistory(
|
|
165
|
+
client: UiduClient,
|
|
166
|
+
variables: ListEmploymentHistoryQueryVariables = {},
|
|
167
|
+
): Promise<EmployeeContracts[]> {
|
|
168
|
+
const result = await client.query(ListEmploymentHistoryDocument, {
|
|
169
|
+
employmentsFirst: 50,
|
|
170
|
+
...variables,
|
|
171
|
+
});
|
|
172
|
+
return nodes(result.currentWorkspace?.employees).map((employee) => ({
|
|
173
|
+
id: employee.id ?? '',
|
|
174
|
+
name: employee.user?.name || employee.user?.email || 'Senza nome',
|
|
175
|
+
employments: nodes(employee.employments).map((e) => ({
|
|
176
|
+
id: e.id ?? '',
|
|
177
|
+
startDate: e.startDate ?? null,
|
|
178
|
+
endDate: e.endDate ?? null,
|
|
179
|
+
endReason: e.endReason ?? null,
|
|
180
|
+
jobTitle: e.jobTitle ?? null,
|
|
181
|
+
contractType: e.contractType ?? null,
|
|
182
|
+
})),
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type ContractEventType = 'hire' | 'variation' | 'termination';
|
|
187
|
+
|
|
188
|
+
/** A dated contract event derived from employment history. */
|
|
189
|
+
export type ContractEvent = {
|
|
190
|
+
type: ContractEventType;
|
|
191
|
+
/** ISO8601 date (YYYY-MM-DD) the event happened on. */
|
|
192
|
+
date: string;
|
|
193
|
+
/** Year-month bucket (YYYY-MM), convenient for grouping. */
|
|
194
|
+
month: string;
|
|
195
|
+
employeeId: string;
|
|
196
|
+
employeeName: string;
|
|
197
|
+
employmentId: string;
|
|
198
|
+
jobTitle: string | null;
|
|
199
|
+
contractType: string | null;
|
|
200
|
+
/** Only set on `termination` events. */
|
|
201
|
+
endReason: string | null;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Flatten employment history into dated contract events, most recent first:
|
|
206
|
+
* - the employee's earliest contract is a `hire` (assunzione) on its start date;
|
|
207
|
+
* - every later contract is a `variation` (variazione) on its start date;
|
|
208
|
+
* - any contract with an end date yields a `termination` (cessazione) on it.
|
|
209
|
+
*
|
|
210
|
+
* Contracts without a start date are ignored.
|
|
211
|
+
*/
|
|
212
|
+
export function contractEvents(employees: EmployeeContracts[]): ContractEvent[] {
|
|
213
|
+
const events: ContractEvent[] = [];
|
|
214
|
+
|
|
215
|
+
for (const employee of employees) {
|
|
216
|
+
const dated = employee.employments
|
|
217
|
+
.filter((e) => e.startDate)
|
|
218
|
+
.sort((a, b) => (a.startDate! < b.startDate! ? -1 : 1));
|
|
219
|
+
|
|
220
|
+
dated.forEach((employment, index) => {
|
|
221
|
+
const base = {
|
|
222
|
+
employeeId: employee.id,
|
|
223
|
+
employeeName: employee.name,
|
|
224
|
+
employmentId: employment.id,
|
|
225
|
+
jobTitle: employment.jobTitle,
|
|
226
|
+
contractType: employment.contractType,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
events.push({
|
|
230
|
+
...base,
|
|
231
|
+
type: index === 0 ? 'hire' : 'variation',
|
|
232
|
+
date: employment.startDate!,
|
|
233
|
+
month: employment.startDate!.slice(0, 7),
|
|
234
|
+
endReason: null,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (employment.endDate) {
|
|
238
|
+
events.push({
|
|
239
|
+
...base,
|
|
240
|
+
type: 'termination',
|
|
241
|
+
date: employment.endDate,
|
|
242
|
+
month: employment.endDate.slice(0, 7),
|
|
243
|
+
endReason: employment.endReason,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return events.sort((a, b) => (a.date < b.date ? 1 : a.date > b.date ? -1 : 0));
|
|
250
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
query ListEmploymentHistory(
|
|
2
|
+
$first: Int
|
|
3
|
+
$after: String
|
|
4
|
+
$employmentsFirst: Int
|
|
5
|
+
) {
|
|
6
|
+
currentWorkspace {
|
|
7
|
+
employees(first: $first, after: $after) {
|
|
8
|
+
pageInfo {
|
|
9
|
+
hasNextPage
|
|
10
|
+
endCursor
|
|
11
|
+
}
|
|
12
|
+
edges {
|
|
13
|
+
node {
|
|
14
|
+
id
|
|
15
|
+
user {
|
|
16
|
+
id
|
|
17
|
+
name
|
|
18
|
+
email
|
|
19
|
+
}
|
|
20
|
+
employments(first: $employmentsFirst) {
|
|
21
|
+
edges {
|
|
22
|
+
node {
|
|
23
|
+
id
|
|
24
|
+
startDate
|
|
25
|
+
endDate
|
|
26
|
+
endReason
|
|
27
|
+
jobTitle
|
|
28
|
+
contractType
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|