@uidu/client 3.20.0 → 3.21.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uidu/client",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Typed GraphQL client for the uidu platform. Server-first, framework-agnostic.",
5
5
  "license": "MIT",
6
6
  "author": "uidu",
package/src/candidates.ts CHANGED
@@ -1,13 +1,23 @@
1
1
  import type { UiduClient } from './client';
2
2
  import {
3
+ CreateCandidateDocument,
4
+ type CreateCandidateMutationVariables,
3
5
  CreatePoolContactDocument,
4
6
  type CreatePoolContactMutationVariables,
7
+ DeletePoolContactDocument,
8
+ type DeletePoolContactMutationVariables,
5
9
  FindCandidatesDocument,
6
10
  type FindCandidatesQuery,
7
11
  type FindCandidatesQueryVariables,
8
12
  GetCandidateDocument,
9
13
  type GetCandidateQuery,
10
14
  type GetCandidateQueryVariables,
15
+ GetPoolDocument,
16
+ type GetPoolQuery,
17
+ type GetPoolQueryVariables,
18
+ ListCandidatesDocument,
19
+ type ListCandidatesQuery,
20
+ type ListCandidatesQueryVariables,
11
21
  ListPoolsDocument,
12
22
  type ListPoolsQuery,
13
23
  type ListPoolsQueryVariables,
@@ -20,6 +30,10 @@ import { nodes } from './utils/relay';
20
30
  // the person's `user` and `contact` with their pool consent and retention.
21
31
  // `Pool`s group contacts (a `PoolContact` is one contact in one pool).
22
32
  //
33
+ // A candidate's `sourceChannel` says how they arrived (`application`, `pool`,
34
+ // `import`, `manual`); `source` is the record they came through — an
35
+ // Application, a Pool, an Organization (e.g. the referring agency) or a User.
36
+ //
23
37
  // Everything here holds private personal data: reads and writes need an
24
38
  // account (Bearer / apiKey), server-side.
25
39
 
@@ -38,14 +52,42 @@ export type Pool = NonNullable<
38
52
  >[number]
39
53
  >['node']
40
54
  >;
55
+ export type CandidateListItem = NonNullable<
56
+ NonNullable<
57
+ NonNullable<
58
+ NonNullable<
59
+ ListCandidatesQuery['currentWorkspace']
60
+ >['candidates']['edges']
61
+ >[number]
62
+ >['node']
63
+ >;
64
+ export type PoolDetail = NonNullable<
65
+ NonNullable<GetPoolQuery['currentWorkspace']>['pool']
66
+ >;
67
+ export type PoolContact = NonNullable<
68
+ NonNullable<NonNullable<PoolDetail['poolContacts']['edges']>[number]>['node']
69
+ >;
70
+
71
+ /**
72
+ * The workspace's candidates with their custom fields, filtered with
73
+ * `params.filters` — `poolIds` (in), `source` (in, the GlobalIDs of the
74
+ * Application, Pool, Organization or User they came through) and
75
+ * `lastInteractionAt` (`>=`, `<=`, `between`); page with `first`/`after`.
76
+ */
77
+ export async function listCandidates(
78
+ client: UiduClient,
79
+ variables: ListCandidatesQueryVariables = {},
80
+ ): Promise<CandidateListItem[]> {
81
+ const result = await client.query(ListCandidatesDocument, variables);
82
+ return nodes(result.currentWorkspace?.candidates);
83
+ }
41
84
 
42
85
  /**
43
86
  * Rank the talent pool against a description (`term`) — and, with `callId`,
44
87
  * that call's applications too — and return the `candidates`, `applications`
45
88
  * and per-record `evidence`, or null when the viewer may not search.
46
89
  *
47
- * This is the only way to list candidates: the workspace has no plain
48
- * `candidates` connection. A blank `term` with a `callId` uses the call's own
90
+ * For a plain filtered list use {@link listCandidates}. A blank `term` with a `callId` uses the call's own
49
91
  * words; `near` + `withinKm` keep only those living close enough, and
50
92
  * `eligibleFor` only those of an age the contract allows.
51
93
  */
@@ -71,7 +113,22 @@ export async function getCandidate(
71
113
  }
72
114
 
73
115
  /**
74
- * Update a candidate: pool consent (`poolConsentAt`), `source`, or
116
+ * Add someone to the talent pool as a candidate: `attributes: { userId,
117
+ * sourceChannel?, sourceId?, poolConsentAt?, fieldValues? }`, where `sourceId`
118
+ * is the GlobalID of the Application, Pool, Organization or User they came
119
+ * through. Returns the mutation payload as-is (including any `errors`).
120
+ */
121
+ export async function createCandidate(
122
+ client: UiduClient,
123
+ variables: CreateCandidateMutationVariables,
124
+ ) {
125
+ const result = await client.mutate(CreateCandidateDocument, variables);
126
+ return result.createCandidate ?? null;
127
+ }
128
+
129
+ /**
130
+ * Update a candidate: pool consent (`poolConsentAt`), where they came from
131
+ * (`sourceChannel` + `sourceId`), custom `fieldValues`, or
75
132
  * `extendRetention: true` to push `retainUntil` out by another retention
76
133
  * period. Returns the mutation payload as-is (including any `errors`).
77
134
  */
@@ -92,6 +149,18 @@ export async function listPools(
92
149
  return nodes(result.currentWorkspace?.pools);
93
150
  }
94
151
 
152
+ /**
153
+ * One talent pool by GlobalID with a page of the contacts in it (`first` /
154
+ * `after`), or null.
155
+ */
156
+ export async function getPool(
157
+ client: UiduClient,
158
+ variables: GetPoolQueryVariables,
159
+ ): Promise<PoolDetail | null> {
160
+ const result = await client.query(GetPoolDocument, variables);
161
+ return result.currentWorkspace?.pool ?? null;
162
+ }
163
+
95
164
  /**
96
165
  * Add a contact to a pool (`attributes: { poolId, contactId }`). Returns the
97
166
  * mutation payload as-is (including any `errors`).
@@ -103,3 +172,15 @@ export async function createPoolContact(
103
172
  const result = await client.mutate(CreatePoolContactDocument, variables);
104
173
  return result.createPoolContact ?? null;
105
174
  }
175
+
176
+ /**
177
+ * Take a contact out of a pool, by the PoolContact's GlobalID. Returns the
178
+ * mutation payload as-is (including any `errors`).
179
+ */
180
+ export async function deletePoolContact(
181
+ client: UiduClient,
182
+ variables: DeletePoolContactMutationVariables,
183
+ ) {
184
+ const result = await client.mutate(DeletePoolContactDocument, variables);
185
+ return result.deletePoolContact ?? null;
186
+ }