@uidu/client 3.17.0 → 3.19.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 +46 -0
- package/dist/declarations/src/calls.d.ts +9 -1
- package/dist/declarations/src/candidates.d.ts +102 -0
- package/dist/declarations/src/contacts.d.ts +22 -1
- package/dist/declarations/src/contracts.d.ts +8 -0
- package/dist/declarations/src/expenses.d.ts +169 -0
- package/dist/declarations/src/field-values.d.ts +34 -0
- package/dist/declarations/src/generated/index.d.ts +13283 -4414
- package/dist/declarations/src/index.d.ts +24 -8
- package/dist/declarations/src/meetings.d.ts +41 -0
- package/dist/declarations/src/mutations.d.ts +168 -131
- package/dist/declarations/src/people.d.ts +13 -1
- package/dist/declarations/src/reviews.d.ts +195 -0
- package/dist/declarations/src/skills.d.ts +34 -0
- package/dist/declarations/src/work-sites.d.ts +9 -0
- package/dist/uidu-client.cjs.dev.js +570 -31
- package/dist/uidu-client.cjs.prod.js +570 -31
- package/dist/uidu-client.esm.js +523 -32
- package/package.json +1 -1
- package/src/calls.ts +37 -0
- package/src/candidates.ts +105 -0
- package/src/contacts.ts +33 -0
- package/src/contracts.ts +44 -0
- package/src/expenses.test.ts +155 -0
- package/src/expenses.ts +155 -0
- package/src/field-values.ts +95 -0
- package/src/generated/index.ts +3461 -2268
- package/src/index.ts +83 -4
- package/src/meetings.ts +37 -0
- package/src/mutations.test.ts +40 -1
- package/src/mutations.ts +170 -60
- package/src/people.ts +33 -0
- package/src/queries/calls/ListCallStatuses.graphql +26 -0
- package/src/queries/candidates/CandidateFields.graphql +28 -0
- package/src/queries/candidates/CandidateMutations.graphql +35 -0
- package/src/queries/candidates/CandidateQueries.graphql +94 -0
- package/src/queries/contacts/ContactMutations.graphql +0 -13
- package/src/queries/contacts/GetOrganization.graphql +17 -0
- package/src/queries/contacts/ListOrganizations.graphql +21 -0
- package/src/queries/contacts/OrganizationMutations.graphql +17 -0
- package/src/queries/contracts/ContractQueries.graphql +67 -0
- package/src/queries/courses/CourseMutations.graphql +0 -13
- package/src/queries/discardable/DiscardableMutations.graphql +32 -0
- package/src/queries/expenses/ExpenseFields.graphql +29 -0
- package/src/queries/expenses/ExpenseMutations.graphql +81 -0
- package/src/queries/expenses/GetExpenseReport.graphql +14 -0
- package/src/queries/expenses/ListAnalyticAccounts.graphql +20 -0
- package/src/queries/expenses/ListExpenseReports.graphql +22 -0
- package/src/queries/field-values/FieldValueFields.graphql +18 -0
- package/src/queries/field-values/FieldValueQueries.graphql +43 -0
- package/src/queries/forms/FormMutations.graphql +0 -13
- package/src/queries/help-center/ChannelMutations.graphql +0 -13
- package/src/queries/kb/KbMutations.graphql +0 -26
- package/src/queries/meetings/MeetingQueries.graphql +48 -0
- package/src/queries/notes/NoteMutations.graphql +0 -13
- package/src/queries/people/EmploymentVariationKindMutations.graphql +51 -0
- package/src/queries/people/ListEmploymentVariationKinds.graphql +23 -0
- package/src/queries/people/PeopleMutations.graphql +0 -13
- package/src/queries/reviews/ReviewFields.graphql +35 -0
- package/src/queries/reviews/ReviewMutations.graphql +32 -0
- package/src/queries/reviews/ReviewQueries.graphql +86 -0
- package/src/queries/skills/SkillQueries.graphql +53 -0
- package/src/queries/spaces/SpaceMutations.graphql +0 -13
- package/src/queries/tasks/TaskMutations.graphql +0 -13
- package/src/queries/work-sites/ListWorkSites.graphql +32 -0
- package/src/recruiting.test.ts +196 -0
- package/src/reviews.ts +114 -0
- package/src/skills.ts +47 -0
- package/src/work-sites.ts +28 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
mutation CreateEmploymentVariationKind($input: CreateEmploymentVariationKindInput!) {
|
|
2
|
+
createEmploymentVariationKind(input: $input) {
|
|
3
|
+
employmentVariationKind {
|
|
4
|
+
node {
|
|
5
|
+
id
|
|
6
|
+
name
|
|
7
|
+
description
|
|
8
|
+
shortname
|
|
9
|
+
color
|
|
10
|
+
position
|
|
11
|
+
changesContract
|
|
12
|
+
changesHours
|
|
13
|
+
changesLevel
|
|
14
|
+
changesPlace
|
|
15
|
+
changesPay
|
|
16
|
+
changesBenefits
|
|
17
|
+
requiresUnilav
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
errors {
|
|
21
|
+
key
|
|
22
|
+
name
|
|
23
|
+
type
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
mutation UpdateEmploymentVariationKind($input: UpdateEmploymentVariationKindInput!) {
|
|
29
|
+
updateEmploymentVariationKind(input: $input) {
|
|
30
|
+
employmentVariationKind {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
description
|
|
34
|
+
shortname
|
|
35
|
+
color
|
|
36
|
+
position
|
|
37
|
+
changesContract
|
|
38
|
+
changesHours
|
|
39
|
+
changesLevel
|
|
40
|
+
changesPlace
|
|
41
|
+
changesPay
|
|
42
|
+
changesBenefits
|
|
43
|
+
requiresUnilav
|
|
44
|
+
}
|
|
45
|
+
errors {
|
|
46
|
+
key
|
|
47
|
+
name
|
|
48
|
+
type
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
query ListEmploymentVariationKinds($first: Int, $after: String) {
|
|
2
|
+
currentWorkspace {
|
|
3
|
+
employmentVariationKinds(first: $first, after: $after) {
|
|
4
|
+
edges {
|
|
5
|
+
node {
|
|
6
|
+
id
|
|
7
|
+
name
|
|
8
|
+
description
|
|
9
|
+
shortname
|
|
10
|
+
color
|
|
11
|
+
position
|
|
12
|
+
changesContract
|
|
13
|
+
changesHours
|
|
14
|
+
changesLevel
|
|
15
|
+
changesPlace
|
|
16
|
+
changesPay
|
|
17
|
+
changesBenefits
|
|
18
|
+
requiresUnilav
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -79,16 +79,3 @@ mutation UpdateEmployment($input: UpdateEmploymentInput!) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
mutation DeleteEmployment($input: DeleteEmploymentInput!) {
|
|
84
|
-
deleteEmployment(input: $input) {
|
|
85
|
-
employment {
|
|
86
|
-
id
|
|
87
|
-
}
|
|
88
|
-
errors {
|
|
89
|
-
key
|
|
90
|
-
name
|
|
91
|
-
type
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
fragment ReviewSummary on Review {
|
|
2
|
+
id
|
|
3
|
+
name
|
|
4
|
+
aasmState
|
|
5
|
+
completed
|
|
6
|
+
completedAt
|
|
7
|
+
dispatchedAt
|
|
8
|
+
dueOn
|
|
9
|
+
createdAt
|
|
10
|
+
updatedAt
|
|
11
|
+
user {
|
|
12
|
+
id
|
|
13
|
+
name
|
|
14
|
+
email
|
|
15
|
+
}
|
|
16
|
+
role {
|
|
17
|
+
id
|
|
18
|
+
name
|
|
19
|
+
}
|
|
20
|
+
reviewTemplate {
|
|
21
|
+
id
|
|
22
|
+
name
|
|
23
|
+
kind
|
|
24
|
+
}
|
|
25
|
+
reviewCycle {
|
|
26
|
+
id
|
|
27
|
+
name
|
|
28
|
+
}
|
|
29
|
+
parent {
|
|
30
|
+
id
|
|
31
|
+
}
|
|
32
|
+
formResponse {
|
|
33
|
+
id
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# `createReviews` takes a list of attributes; a review without a cycle passes
|
|
2
|
+
# `reviewTemplateId` (and optionally `dueOn`) instead of `reviewCycleId`.
|
|
3
|
+
mutation CreateReviews($input: CreateReviewsInput!) {
|
|
4
|
+
createReviews(input: $input) {
|
|
5
|
+
reviews {
|
|
6
|
+
node {
|
|
7
|
+
...ReviewSummary
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
reviewCycle {
|
|
11
|
+
id
|
|
12
|
+
}
|
|
13
|
+
errors {
|
|
14
|
+
key
|
|
15
|
+
name
|
|
16
|
+
type
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mutation UpdateReview($input: UpdateReviewInput!) {
|
|
22
|
+
updateReview(input: $input) {
|
|
23
|
+
review {
|
|
24
|
+
...ReviewSummary
|
|
25
|
+
}
|
|
26
|
+
errors {
|
|
27
|
+
key
|
|
28
|
+
name
|
|
29
|
+
type
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# The workspace has no `reviews` connection of its own: reviews hang off the
|
|
2
|
+
# person reviewed (Employee or User) or the cycle they belong to. `ownerId`
|
|
3
|
+
# is the GlobalID of any of the three.
|
|
4
|
+
query ListReviews($ownerId: ID!, $first: Int, $after: String) {
|
|
5
|
+
node(id: $ownerId) {
|
|
6
|
+
__typename
|
|
7
|
+
... on Employee {
|
|
8
|
+
employeeReviews: reviews(first: $first, after: $after) {
|
|
9
|
+
pageInfo {
|
|
10
|
+
hasNextPage
|
|
11
|
+
endCursor
|
|
12
|
+
}
|
|
13
|
+
edges {
|
|
14
|
+
node {
|
|
15
|
+
...ReviewSummary
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
... on User {
|
|
21
|
+
userReviews: reviews(first: $first, after: $after) {
|
|
22
|
+
pageInfo {
|
|
23
|
+
hasNextPage
|
|
24
|
+
endCursor
|
|
25
|
+
}
|
|
26
|
+
edges {
|
|
27
|
+
node {
|
|
28
|
+
...ReviewSummary
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
... on ReviewCycle {
|
|
34
|
+
cycleReviews: reviews(first: $first, after: $after) {
|
|
35
|
+
pageInfo {
|
|
36
|
+
hasNextPage
|
|
37
|
+
endCursor
|
|
38
|
+
}
|
|
39
|
+
edges {
|
|
40
|
+
node {
|
|
41
|
+
...ReviewSummary
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
query GetReview($id: ID!) {
|
|
50
|
+
currentWorkspace {
|
|
51
|
+
review(id: $id) {
|
|
52
|
+
...ReviewSummary
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
query ListReviewTemplates(
|
|
58
|
+
$first: Int
|
|
59
|
+
$after: String
|
|
60
|
+
$scopes: [String!]
|
|
61
|
+
$orderBy: String
|
|
62
|
+
) {
|
|
63
|
+
currentWorkspace {
|
|
64
|
+
reviewTemplates(
|
|
65
|
+
first: $first
|
|
66
|
+
after: $after
|
|
67
|
+
scopes: $scopes
|
|
68
|
+
orderBy: $orderBy
|
|
69
|
+
) {
|
|
70
|
+
pageInfo {
|
|
71
|
+
hasNextPage
|
|
72
|
+
endCursor
|
|
73
|
+
}
|
|
74
|
+
edges {
|
|
75
|
+
node {
|
|
76
|
+
id
|
|
77
|
+
name
|
|
78
|
+
kind
|
|
79
|
+
description
|
|
80
|
+
preferences
|
|
81
|
+
createdAt
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Workspace skills are the catalog (e.g. "Forklift licence", "Italian B2");
|
|
2
|
+
# a `Skill` is one of them held by a person (`skillable`), with a score.
|
|
3
|
+
query ListSkills(
|
|
4
|
+
$first: Int
|
|
5
|
+
$after: String
|
|
6
|
+
$scopes: [String!]
|
|
7
|
+
$orderBy: String
|
|
8
|
+
) {
|
|
9
|
+
currentWorkspace {
|
|
10
|
+
workspaceSkills(
|
|
11
|
+
first: $first
|
|
12
|
+
after: $after
|
|
13
|
+
scopes: $scopes
|
|
14
|
+
orderBy: $orderBy
|
|
15
|
+
) {
|
|
16
|
+
pageInfo {
|
|
17
|
+
hasNextPage
|
|
18
|
+
endCursor
|
|
19
|
+
}
|
|
20
|
+
edges {
|
|
21
|
+
node {
|
|
22
|
+
id
|
|
23
|
+
name
|
|
24
|
+
icon
|
|
25
|
+
description
|
|
26
|
+
scores
|
|
27
|
+
createdAt
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
mutation CreateSkill($input: CreateSkillInput!) {
|
|
35
|
+
createSkill(input: $input) {
|
|
36
|
+
skill {
|
|
37
|
+
node {
|
|
38
|
+
id
|
|
39
|
+
score
|
|
40
|
+
body
|
|
41
|
+
workspaceSkill {
|
|
42
|
+
id
|
|
43
|
+
name
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
errors {
|
|
48
|
+
key
|
|
49
|
+
name
|
|
50
|
+
type
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
query ListWorkSites($first: Int, $after: String, $params: SearchParams) {
|
|
2
|
+
currentWorkspace {
|
|
3
|
+
workSites(first: $first, after: $after, params: $params) {
|
|
4
|
+
pageInfo {
|
|
5
|
+
hasNextPage
|
|
6
|
+
endCursor
|
|
7
|
+
}
|
|
8
|
+
edges {
|
|
9
|
+
node {
|
|
10
|
+
id
|
|
11
|
+
name
|
|
12
|
+
code
|
|
13
|
+
externalCode
|
|
14
|
+
status
|
|
15
|
+
weeklyHours
|
|
16
|
+
geofenceRadiusMeters
|
|
17
|
+
analyticAccount {
|
|
18
|
+
id
|
|
19
|
+
name
|
|
20
|
+
code
|
|
21
|
+
}
|
|
22
|
+
primaryAddress {
|
|
23
|
+
id
|
|
24
|
+
formattedAddress
|
|
25
|
+
city
|
|
26
|
+
}
|
|
27
|
+
fieldValuesByShortname
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { listCallStatuses } from './calls';
|
|
3
|
+
import { getCandidate } from './candidates';
|
|
4
|
+
import type { UiduClient } from './client';
|
|
5
|
+
import {
|
|
6
|
+
type RecordFieldValue,
|
|
7
|
+
fieldValueAsOf,
|
|
8
|
+
getRecordFieldValues,
|
|
9
|
+
listFieldValueHistory,
|
|
10
|
+
} from './field-values';
|
|
11
|
+
import { createReview, listReviews } from './reviews';
|
|
12
|
+
|
|
13
|
+
const queryClient = (...pages: unknown[]) => {
|
|
14
|
+
const query = vi.fn();
|
|
15
|
+
for (const page of pages) query.mockResolvedValueOnce(page);
|
|
16
|
+
return { client: { query } as unknown as UiduClient, query };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const conn = <T>(
|
|
20
|
+
items: T[],
|
|
21
|
+
hasNextPage = false,
|
|
22
|
+
endCursor: string | null = null,
|
|
23
|
+
) => ({
|
|
24
|
+
pageInfo: { hasNextPage, endCursor },
|
|
25
|
+
edges: items.map((node) => ({ node })),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('getCandidate', () => {
|
|
29
|
+
it('returns the node when it is a Candidate', async () => {
|
|
30
|
+
const { client } = queryClient({
|
|
31
|
+
node: { __typename: 'Candidate', id: 'c1' },
|
|
32
|
+
});
|
|
33
|
+
expect(await getCandidate(client, { id: 'c1' })).toEqual({
|
|
34
|
+
__typename: 'Candidate',
|
|
35
|
+
id: 'c1',
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('returns null for any other type', async () => {
|
|
40
|
+
const { client } = queryClient({ node: { __typename: 'Contact' } });
|
|
41
|
+
expect(await getCandidate(client, { id: 'x' })).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('listReviews', () => {
|
|
46
|
+
it('reads the connection of whichever owner the id resolves to', async () => {
|
|
47
|
+
const { client } = queryClient(
|
|
48
|
+
{
|
|
49
|
+
node: { __typename: 'Employee', employeeReviews: conn([{ id: 'r1' }]) },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
node: { __typename: 'ReviewCycle', cycleReviews: conn([{ id: 'r2' }]) },
|
|
53
|
+
},
|
|
54
|
+
{ node: { __typename: 'Contact' } },
|
|
55
|
+
);
|
|
56
|
+
expect(await listReviews(client, { ownerId: 'e1' })).toEqual([
|
|
57
|
+
{ id: 'r1' },
|
|
58
|
+
]);
|
|
59
|
+
expect(await listReviews(client, { ownerId: 'rc1' })).toEqual([
|
|
60
|
+
{ id: 'r2' },
|
|
61
|
+
]);
|
|
62
|
+
expect(await listReviews(client, { ownerId: 'x' })).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('createReview', () => {
|
|
67
|
+
it('wraps one set of attributes into createReviews', async () => {
|
|
68
|
+
const payload = { createReviews: { reviews: [], errors: [] } };
|
|
69
|
+
const mutate = vi.fn().mockResolvedValue(payload);
|
|
70
|
+
const client = { mutate } as unknown as UiduClient;
|
|
71
|
+
|
|
72
|
+
const attributes = {
|
|
73
|
+
userId: 'u1',
|
|
74
|
+
reviewTemplateId: 't1',
|
|
75
|
+
dueOn: '2026-12-01',
|
|
76
|
+
};
|
|
77
|
+
const result = await createReview(client, attributes);
|
|
78
|
+
|
|
79
|
+
expect(mutate.mock.calls[0][1]).toEqual({
|
|
80
|
+
input: { attributes: [attributes] },
|
|
81
|
+
});
|
|
82
|
+
expect(result).toEqual(payload.createReviews);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('listCallStatuses', () => {
|
|
87
|
+
it('walks every page and sorts by position', async () => {
|
|
88
|
+
const page = (
|
|
89
|
+
statuses: unknown,
|
|
90
|
+
hasNext: boolean,
|
|
91
|
+
cursor: string | null,
|
|
92
|
+
) => ({
|
|
93
|
+
currentWorkspace: {
|
|
94
|
+
call: { statuses: conn(statuses as object[], hasNext, cursor) },
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const { client, query } = queryClient(
|
|
98
|
+
page(
|
|
99
|
+
[
|
|
100
|
+
{ id: 's3', position: 3 },
|
|
101
|
+
{ id: 's1', position: 1 },
|
|
102
|
+
],
|
|
103
|
+
true,
|
|
104
|
+
'c1',
|
|
105
|
+
),
|
|
106
|
+
page([{ id: 's2', position: 2 }], false, null),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const statuses = await listCallStatuses(client, { callId: 'call1' });
|
|
110
|
+
|
|
111
|
+
expect(statuses.map((s) => s.id)).toEqual(['s1', 's2', 's3']);
|
|
112
|
+
expect(query.mock.calls[1][1]).toEqual({
|
|
113
|
+
first: 100,
|
|
114
|
+
callId: 'call1',
|
|
115
|
+
after: 'c1',
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('getRecordFieldValues', () => {
|
|
121
|
+
it('returns the values of a record that carries fields', async () => {
|
|
122
|
+
const { client } = queryClient({
|
|
123
|
+
node: {
|
|
124
|
+
__typename: 'Contract',
|
|
125
|
+
id: 'k1',
|
|
126
|
+
fieldValuesByShortname: { fte: 1 },
|
|
127
|
+
fieldValues: [{ id: 'fv1' }],
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
expect(await getRecordFieldValues(client, { id: 'k1' })).toEqual({
|
|
131
|
+
typename: 'Contract',
|
|
132
|
+
id: 'k1',
|
|
133
|
+
byShortname: { fte: 1 },
|
|
134
|
+
fieldValues: [{ id: 'fv1' }],
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('returns null for a type without fields', async () => {
|
|
139
|
+
const { client } = queryClient({ node: { __typename: 'Pool', id: 'p1' } });
|
|
140
|
+
expect(await getRecordFieldValues(client, { id: 'p1' })).toBeNull();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('listFieldValueHistory', () => {
|
|
145
|
+
it('flattens every page of the field history', async () => {
|
|
146
|
+
const page = (
|
|
147
|
+
values: unknown[],
|
|
148
|
+
hasNext: boolean,
|
|
149
|
+
cursor: string | null,
|
|
150
|
+
) => ({
|
|
151
|
+
currentWorkspace: {
|
|
152
|
+
field: { fieldValues: conn(values as object[], hasNext, cursor) },
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
const { client } = queryClient(
|
|
156
|
+
page([{ id: 'a' }], true, 'c'),
|
|
157
|
+
page([{ id: 'b' }], false, null),
|
|
158
|
+
);
|
|
159
|
+
const history = await listFieldValueHistory(client, {
|
|
160
|
+
fieldId: 'f',
|
|
161
|
+
modelId: 'm',
|
|
162
|
+
});
|
|
163
|
+
expect(history.map((v) => v.id)).toEqual(['a', 'b']);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('fieldValueAsOf', () => {
|
|
168
|
+
const v = (id: string, validFrom: string | null, createdAt: string) =>
|
|
169
|
+
({ id, validFrom, createdAt }) as RecordFieldValue;
|
|
170
|
+
|
|
171
|
+
const history = [
|
|
172
|
+
v('old', '2024-01-01', '2024-01-01T09:00:00Z'),
|
|
173
|
+
v('mid', '2024-06-01', '2024-06-01T09:00:00Z'),
|
|
174
|
+
v('mid-fix', '2024-06-01', '2024-06-02T09:00:00Z'),
|
|
175
|
+
v('legacy', null, '2024-09-15T10:00:00Z'),
|
|
176
|
+
v('scheduled', '2027-01-01', '2026-11-01T09:00:00Z'),
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
it('picks the latest value holding on the date, ties to the last written', () => {
|
|
180
|
+
expect(fieldValueAsOf(history, '2024-06-30')?.id).toBe('mid-fix');
|
|
181
|
+
expect(fieldValueAsOf(history, '2024-03-01')?.id).toBe('old');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('dates a row without validFrom by its createdAt day', () => {
|
|
185
|
+
expect(fieldValueAsOf(history, '2024-09-15')?.id).toBe('legacy');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('leaves out values that start after the date', () => {
|
|
189
|
+
expect(fieldValueAsOf(history, '2026-12-31')?.id).toBe('legacy');
|
|
190
|
+
expect(fieldValueAsOf(history, '2027-01-01')?.id).toBe('scheduled');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('returns null before the first value', () => {
|
|
194
|
+
expect(fieldValueAsOf(history, '2023-12-31')).toBeNull();
|
|
195
|
+
});
|
|
196
|
+
});
|
package/src/reviews.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { UiduClient } from './client';
|
|
2
|
+
import {
|
|
3
|
+
CreateReviewsDocument,
|
|
4
|
+
type CreateReviewsMutationVariables,
|
|
5
|
+
GetReviewDocument,
|
|
6
|
+
type GetReviewQueryVariables,
|
|
7
|
+
ListReviewsDocument,
|
|
8
|
+
type ListReviewsQueryVariables,
|
|
9
|
+
ListReviewTemplatesDocument,
|
|
10
|
+
type ListReviewTemplatesQuery,
|
|
11
|
+
type ListReviewTemplatesQueryVariables,
|
|
12
|
+
type ReviewAttributes,
|
|
13
|
+
type ReviewSummaryFragment,
|
|
14
|
+
UpdateReviewDocument,
|
|
15
|
+
type UpdateReviewMutationVariables,
|
|
16
|
+
} from './generated';
|
|
17
|
+
import { nodes } from './utils/relay';
|
|
18
|
+
|
|
19
|
+
// Reviews: a person (`userId`) assessed against a `ReviewTemplate`'s form.
|
|
20
|
+
// A review either belongs to a `ReviewCycle` (which brings the template) or
|
|
21
|
+
// stands on its own with `reviewTemplateId` and an optional `dueOn` — what a
|
|
22
|
+
// probation check, a 1:1 or a placement follow-up is.
|
|
23
|
+
//
|
|
24
|
+
// Reads and writes need an account (Bearer / apiKey), server-side.
|
|
25
|
+
|
|
26
|
+
export type Review = ReviewSummaryFragment;
|
|
27
|
+
export type ReviewTemplate = NonNullable<
|
|
28
|
+
NonNullable<
|
|
29
|
+
NonNullable<
|
|
30
|
+
NonNullable<
|
|
31
|
+
ListReviewTemplatesQuery['currentWorkspace']
|
|
32
|
+
>['reviewTemplates']['edges']
|
|
33
|
+
>[number]
|
|
34
|
+
>['node']
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The reviews of one person or cycle — `ownerId` is the GlobalID of an
|
|
39
|
+
* Employee, a User or a ReviewCycle — as a flat array; page with
|
|
40
|
+
* `first`/`after`.
|
|
41
|
+
*/
|
|
42
|
+
export async function listReviews(
|
|
43
|
+
client: UiduClient,
|
|
44
|
+
variables: ListReviewsQueryVariables,
|
|
45
|
+
): Promise<Review[]> {
|
|
46
|
+
const result = await client.query(ListReviewsDocument, variables);
|
|
47
|
+
const node = result.node;
|
|
48
|
+
if (!node) return [];
|
|
49
|
+
if (node.__typename === 'Employee' && 'employeeReviews' in node) {
|
|
50
|
+
return nodes(node.employeeReviews);
|
|
51
|
+
}
|
|
52
|
+
if (node.__typename === 'User' && 'userReviews' in node) {
|
|
53
|
+
return nodes(node.userReviews);
|
|
54
|
+
}
|
|
55
|
+
if (node.__typename === 'ReviewCycle' && 'cycleReviews' in node) {
|
|
56
|
+
return nodes(node.cycleReviews);
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** One review by id, or null. */
|
|
62
|
+
export async function getReview(
|
|
63
|
+
client: UiduClient,
|
|
64
|
+
variables: GetReviewQueryVariables,
|
|
65
|
+
): Promise<Review | null> {
|
|
66
|
+
const result = await client.query(GetReviewDocument, variables);
|
|
67
|
+
return result.currentWorkspace?.review ?? null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create one review. Without a cycle pass `reviewTemplateId` (and optionally
|
|
72
|
+
* `dueOn`) with the `userId`; with one pass `reviewCycleId`. Returns the
|
|
73
|
+
* `createReviews` payload as-is (including any `errors`).
|
|
74
|
+
*/
|
|
75
|
+
export async function createReview(
|
|
76
|
+
client: UiduClient,
|
|
77
|
+
attributes: ReviewAttributes,
|
|
78
|
+
) {
|
|
79
|
+
return createReviews(client, { input: { attributes: [attributes] } });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create several reviews in one call (`input.attributes` is a list). Returns
|
|
84
|
+
* the mutation payload as-is (including any `errors`).
|
|
85
|
+
*/
|
|
86
|
+
export async function createReviews(
|
|
87
|
+
client: UiduClient,
|
|
88
|
+
variables: CreateReviewsMutationVariables,
|
|
89
|
+
) {
|
|
90
|
+
const result = await client.mutate(CreateReviewsDocument, variables);
|
|
91
|
+
return result.createReviews ?? null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Update a review — its `dueOn`, its answers (`formResponseAttributes`) or its
|
|
96
|
+
* skill scores (`skillsAttributes`). Returns the mutation payload as-is
|
|
97
|
+
* (including any `errors`).
|
|
98
|
+
*/
|
|
99
|
+
export async function updateReview(
|
|
100
|
+
client: UiduClient,
|
|
101
|
+
variables: UpdateReviewMutationVariables,
|
|
102
|
+
) {
|
|
103
|
+
const result = await client.mutate(UpdateReviewDocument, variables);
|
|
104
|
+
return result.updateReview ?? null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The workspace's review templates; page with `first`/`after`. */
|
|
108
|
+
export async function listReviewTemplates(
|
|
109
|
+
client: UiduClient,
|
|
110
|
+
variables: ListReviewTemplatesQueryVariables = {},
|
|
111
|
+
): Promise<ReviewTemplate[]> {
|
|
112
|
+
const result = await client.query(ListReviewTemplatesDocument, variables);
|
|
113
|
+
return nodes(result.currentWorkspace?.reviewTemplates);
|
|
114
|
+
}
|