@uidu/client 3.20.0 → 3.22.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.22.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,18 +1,30 @@
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,
14
24
  UpdateCandidateDocument,
15
25
  type UpdateCandidateMutationVariables,
26
+ UpdatePoolContactDocument,
27
+ type UpdatePoolContactMutationVariables,
16
28
  } from './generated';
17
29
  import { nodes } from './utils/relay';
18
30
 
@@ -20,6 +32,10 @@ import { nodes } from './utils/relay';
20
32
  // the person's `user` and `contact` with their pool consent and retention.
21
33
  // `Pool`s group contacts (a `PoolContact` is one contact in one pool).
22
34
  //
35
+ // A candidate's `sourceChannel` says how they arrived (`application`, `pool`,
36
+ // `import`, `manual`); `source` is the record they came through — an
37
+ // Application, a Pool, an Organization (e.g. the referring agency) or a User.
38
+ //
23
39
  // Everything here holds private personal data: reads and writes need an
24
40
  // account (Bearer / apiKey), server-side.
25
41
 
@@ -38,14 +54,42 @@ export type Pool = NonNullable<
38
54
  >[number]
39
55
  >['node']
40
56
  >;
57
+ export type CandidateListItem = NonNullable<
58
+ NonNullable<
59
+ NonNullable<
60
+ NonNullable<
61
+ ListCandidatesQuery['currentWorkspace']
62
+ >['candidates']['edges']
63
+ >[number]
64
+ >['node']
65
+ >;
66
+ export type PoolDetail = NonNullable<
67
+ NonNullable<GetPoolQuery['currentWorkspace']>['pool']
68
+ >;
69
+ export type PoolContact = NonNullable<
70
+ NonNullable<NonNullable<PoolDetail['poolContacts']['edges']>[number]>['node']
71
+ >;
72
+
73
+ /**
74
+ * The workspace's candidates with their custom fields, filtered with
75
+ * `params.filters` — `poolIds` (in), `source` (in, the GlobalIDs of the
76
+ * Application, Pool, Organization or User they came through) and
77
+ * `lastInteractionAt` (`>=`, `<=`, `between`); page with `first`/`after`.
78
+ */
79
+ export async function listCandidates(
80
+ client: UiduClient,
81
+ variables: ListCandidatesQueryVariables = {},
82
+ ): Promise<CandidateListItem[]> {
83
+ const result = await client.query(ListCandidatesDocument, variables);
84
+ return nodes(result.currentWorkspace?.candidates);
85
+ }
41
86
 
42
87
  /**
43
88
  * Rank the talent pool against a description (`term`) — and, with `callId`,
44
89
  * that call's applications too — and return the `candidates`, `applications`
45
90
  * and per-record `evidence`, or null when the viewer may not search.
46
91
  *
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
92
+ * For a plain filtered list use {@link listCandidates}. A blank `term` with a `callId` uses the call's own
49
93
  * words; `near` + `withinKm` keep only those living close enough, and
50
94
  * `eligibleFor` only those of an age the contract allows.
51
95
  */
@@ -71,7 +115,22 @@ export async function getCandidate(
71
115
  }
72
116
 
73
117
  /**
74
- * Update a candidate: pool consent (`poolConsentAt`), `source`, or
118
+ * Add someone to the talent pool as a candidate: `attributes: { userId,
119
+ * sourceChannel?, sourceId?, poolConsentAt?, fieldValues? }`, where `sourceId`
120
+ * is the GlobalID of the Application, Pool, Organization or User they came
121
+ * through. Returns the mutation payload as-is (including any `errors`).
122
+ */
123
+ export async function createCandidate(
124
+ client: UiduClient,
125
+ variables: CreateCandidateMutationVariables,
126
+ ) {
127
+ const result = await client.mutate(CreateCandidateDocument, variables);
128
+ return result.createCandidate ?? null;
129
+ }
130
+
131
+ /**
132
+ * Update a candidate: pool consent (`poolConsentAt`), where they came from
133
+ * (`sourceChannel` + `sourceId`), custom `fieldValues`, or
75
134
  * `extendRetention: true` to push `retainUntil` out by another retention
76
135
  * period. Returns the mutation payload as-is (including any `errors`).
77
136
  */
@@ -93,8 +152,24 @@ export async function listPools(
93
152
  }
94
153
 
95
154
  /**
96
- * Add a contact to a pool (`attributes: { poolId, contactId }`). Returns the
97
- * mutation payload as-is (including any `errors`).
155
+ * One talent pool by GlobalID with a page of the contacts in it (`first` /
156
+ * `after`), or null.
157
+ */
158
+ export async function getPool(
159
+ client: UiduClient,
160
+ variables: GetPoolQueryVariables,
161
+ ): Promise<PoolDetail | null> {
162
+ const result = await client.query(GetPoolDocument, variables);
163
+ return result.currentWorkspace?.pool ?? null;
164
+ }
165
+
166
+ /**
167
+ * Refer a contact to a pool (`attributes: { poolId, contactId, sourceId?,
168
+ * sourceChannel?, referredOn? }`). Each call is one referral, so the same
169
+ * person may enter the same pool more than once: `sourceId` is who sent them
170
+ * (the GlobalID of a referring Organization or of a User), `sourceChannel` a
171
+ * short slug like an application's, `referredOn` the day (`YYYY-MM-DD`, today
172
+ * when left out). Returns the mutation payload as-is (including any `errors`).
98
173
  */
99
174
  export async function createPoolContact(
100
175
  client: UiduClient,
@@ -103,3 +178,28 @@ export async function createPoolContact(
103
178
  const result = await client.mutate(CreatePoolContactDocument, variables);
104
179
  return result.createPoolContact ?? null;
105
180
  }
181
+
182
+ /**
183
+ * Correct a referral, by the PoolContact's GlobalID (`id`, `attributes: {
184
+ * sourceId?, sourceChannel?, referredOn? }`). Returns the mutation payload
185
+ * as-is (including any `errors`).
186
+ */
187
+ export async function updatePoolContact(
188
+ client: UiduClient,
189
+ variables: UpdatePoolContactMutationVariables,
190
+ ) {
191
+ const result = await client.mutate(UpdatePoolContactDocument, variables);
192
+ return result.updatePoolContact ?? null;
193
+ }
194
+
195
+ /**
196
+ * Take a contact out of a pool, by the PoolContact's GlobalID. Returns the
197
+ * mutation payload as-is (including any `errors`).
198
+ */
199
+ export async function deletePoolContact(
200
+ client: UiduClient,
201
+ variables: DeletePoolContactMutationVariables,
202
+ ) {
203
+ const result = await client.mutate(DeletePoolContactDocument, variables);
204
+ return result.deletePoolContact ?? null;
205
+ }