@uidu/client 3.21.0 → 3.23.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 +13 -0
- package/dist/declarations/src/candidates.d.ts +69 -3
- package/dist/declarations/src/comments.d.ts +47 -0
- package/dist/declarations/src/contracts.d.ts +2 -0
- package/dist/declarations/src/decisions.d.ts +58 -0
- package/dist/declarations/src/generated/index.d.ts +6727 -1966
- package/dist/declarations/src/index.d.ts +10 -4
- package/dist/declarations/src/models.d.ts +28 -1
- package/dist/declarations/src/mutations.d.ts +156 -1
- package/dist/declarations/src/votes.d.ts +114 -0
- package/dist/uidu-client.cjs.dev.js +301 -3
- package/dist/uidu-client.cjs.prod.js +301 -3
- package/dist/uidu-client.esm.js +286 -4
- package/package.json +1 -1
- package/src/candidates.ts +21 -2
- package/src/comments.ts +44 -0
- package/src/decisions.test.ts +275 -0
- package/src/decisions.ts +135 -0
- package/src/generated/index.ts +1209 -36
- package/src/index.ts +26 -0
- package/src/models.ts +50 -0
- package/src/mutations.ts +72 -0
- package/src/queries/candidates/CandidateMutations.graphql +14 -9
- package/src/queries/candidates/CandidateQueries.graphql +1 -7
- package/src/queries/candidates/PoolContactFields.graphql +29 -0
- package/src/queries/comments/Comments.graphql +65 -0
- package/src/queries/contacts/AddressMutations.graphql +41 -0
- package/src/queries/contacts/EmailAddressMutations.graphql +39 -0
- package/src/queries/contacts/PhoneNumberMutations.graphql +39 -0
- package/src/queries/decisions/DecisionFields.graphql +83 -0
- package/src/queries/decisions/DecisionMutations.graphql +59 -0
- package/src/queries/decisions/DecisionQueries.graphql +32 -0
- package/src/queries/models/ModelFields.graphql +2 -0
- package/src/queries/models/ModelQueries.graphql +33 -0
- package/src/queries/votes/Votes.graphql +60 -0
- package/src/recruiting.test.ts +41 -0
- package/src/votes.ts +38 -0
|
@@ -42,3 +42,36 @@ query GetModelItem($id: ID!) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
# The item's history: the events of its own stream (`modelItem_<id>`), by
|
|
47
|
+
# default only `Database::ModelItem::Updated`. `data.changes` maps each changed
|
|
48
|
+
# Field's GlobalID to `[from, to]` (the raw `content.value`; a select's is the
|
|
49
|
+
# option's GlobalID). No `metadata`: a session may not read it.
|
|
50
|
+
query GetModelItemLog($id: ID!, $types: JSON, $first: Int, $after: String) {
|
|
51
|
+
node(id: $id) {
|
|
52
|
+
__typename
|
|
53
|
+
... on ModelItem {
|
|
54
|
+
id
|
|
55
|
+
logs(types: $types, first: $first, after: $after) {
|
|
56
|
+
pageInfo {
|
|
57
|
+
hasNextPage
|
|
58
|
+
endCursor
|
|
59
|
+
}
|
|
60
|
+
edges {
|
|
61
|
+
node {
|
|
62
|
+
id
|
|
63
|
+
type
|
|
64
|
+
data
|
|
65
|
+
timestamp
|
|
66
|
+
createdAt
|
|
67
|
+
currentUser {
|
|
68
|
+
id
|
|
69
|
+
name
|
|
70
|
+
avatar
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# A vote of the session's user on a votable record — for a custom app, one of
|
|
2
|
+
# its ModelItems. Only `voteFlag` and `emoji` may be set (Votes::Vote::Create).
|
|
3
|
+
|
|
4
|
+
fragment VoteFields on Vote {
|
|
5
|
+
id
|
|
6
|
+
voteFlag
|
|
7
|
+
emoji
|
|
8
|
+
mine
|
|
9
|
+
createdAt
|
|
10
|
+
voter {
|
|
11
|
+
__typename
|
|
12
|
+
... on Contact {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
avatar
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mutation CreateVote($input: CreateVoteInput!) {
|
|
21
|
+
createVote(input: $input) {
|
|
22
|
+
vote {
|
|
23
|
+
node {
|
|
24
|
+
...VoteFields
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
votable {
|
|
28
|
+
__typename
|
|
29
|
+
... on ModelItem {
|
|
30
|
+
id
|
|
31
|
+
votesCount
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
errors {
|
|
35
|
+
key
|
|
36
|
+
name
|
|
37
|
+
type
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
mutation DeleteVote($input: DeleteVoteInput!) {
|
|
43
|
+
deleteVote(input: $input) {
|
|
44
|
+
vote {
|
|
45
|
+
id
|
|
46
|
+
}
|
|
47
|
+
votable {
|
|
48
|
+
__typename
|
|
49
|
+
... on ModelItem {
|
|
50
|
+
id
|
|
51
|
+
votesCount
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
errors {
|
|
55
|
+
key
|
|
56
|
+
name
|
|
57
|
+
type
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/recruiting.test.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
2
2
|
import { listCallStatuses } from './calls';
|
|
3
3
|
import {
|
|
4
4
|
createCandidate,
|
|
5
|
+
createPoolContact,
|
|
5
6
|
getCandidate,
|
|
6
7
|
getPool,
|
|
7
8
|
listCandidates,
|
|
9
|
+
updatePoolContact,
|
|
8
10
|
} from './candidates';
|
|
9
11
|
import type { UiduClient } from './client';
|
|
10
12
|
import { CandidateSourceEnum } from './generated';
|
|
@@ -295,3 +297,42 @@ describe('updateMeeting', () => {
|
|
|
295
297
|
).toBeNull();
|
|
296
298
|
});
|
|
297
299
|
});
|
|
300
|
+
|
|
301
|
+
describe('pool contacts', () => {
|
|
302
|
+
it('refers a contact to a pool with who sent them, and corrects the referral', async () => {
|
|
303
|
+
const referral = {
|
|
304
|
+
id: 'pc1',
|
|
305
|
+
sourceChannel: 'ente',
|
|
306
|
+
referredOn: '2024-05-02',
|
|
307
|
+
source: { __typename: 'Organization', id: 'o1', name: 'SIL Bergamo' },
|
|
308
|
+
};
|
|
309
|
+
const mutate = vi
|
|
310
|
+
.fn()
|
|
311
|
+
.mockResolvedValueOnce({
|
|
312
|
+
createPoolContact: { poolContact: { node: referral }, errors: [] },
|
|
313
|
+
})
|
|
314
|
+
.mockResolvedValueOnce({
|
|
315
|
+
updatePoolContact: {
|
|
316
|
+
poolContact: { ...referral, sourceChannel: 'passaparola' },
|
|
317
|
+
errors: [],
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
const client = { mutate } as unknown as UiduClient;
|
|
321
|
+
|
|
322
|
+
const attributes = {
|
|
323
|
+
poolId: 'p1',
|
|
324
|
+
contactId: 'c1',
|
|
325
|
+
sourceId: 'o1',
|
|
326
|
+
sourceChannel: 'ente',
|
|
327
|
+
referredOn: '2024-05-02',
|
|
328
|
+
};
|
|
329
|
+
const created = await createPoolContact(client, { input: { attributes } });
|
|
330
|
+
expect(created?.poolContact?.node).toBe(referral);
|
|
331
|
+
expect(mutate.mock.calls[0][1]).toEqual({ input: { attributes } });
|
|
332
|
+
|
|
333
|
+
const updated = await updatePoolContact(client, {
|
|
334
|
+
input: { id: 'pc1', attributes: { sourceChannel: 'passaparola' } },
|
|
335
|
+
});
|
|
336
|
+
expect(updated?.poolContact?.sourceChannel).toBe('passaparola');
|
|
337
|
+
});
|
|
338
|
+
});
|
package/src/votes.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { UiduClient } from './client';
|
|
2
|
+
import {
|
|
3
|
+
CreateVoteDocument,
|
|
4
|
+
DeleteVoteDocument,
|
|
5
|
+
type VoteFieldsFragment,
|
|
6
|
+
} from './generated';
|
|
7
|
+
|
|
8
|
+
// Votes and reactions on a record — for a custom app, one of its ModelItems
|
|
9
|
+
// (Votes::Vote::Create, which covers taking one back too). The voter is always
|
|
10
|
+
// the contact of the token's user, and only one's own vote can be taken back.
|
|
11
|
+
|
|
12
|
+
export type Vote = VoteFieldsFragment;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Vote on a record as the token's user: an upvote by default, `voteFlag:
|
|
16
|
+
* false` for a downvote, or a reaction with `emoji`. Returns the payload: the
|
|
17
|
+
* vote at `vote.node`, the record's new `votable.votesCount`, and `errors`.
|
|
18
|
+
*/
|
|
19
|
+
export async function vote(
|
|
20
|
+
client: UiduClient,
|
|
21
|
+
variables: { votableId: string; voteFlag?: boolean; emoji?: string },
|
|
22
|
+
) {
|
|
23
|
+
const { votableId, voteFlag = true, emoji } = variables;
|
|
24
|
+
const result = await client.mutate(CreateVoteDocument, {
|
|
25
|
+
input: { votableId, attributes: { voteFlag, emoji } },
|
|
26
|
+
});
|
|
27
|
+
return result.createVote ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Take back one's own vote (`id` of a vote whose `mine` is true). Someone
|
|
32
|
+
* else's comes back as an error, not thrown. Returns the payload with the
|
|
33
|
+
* record's new `votable.votesCount`.
|
|
34
|
+
*/
|
|
35
|
+
export async function unvote(client: UiduClient, variables: { id: string }) {
|
|
36
|
+
const result = await client.mutate(DeleteVoteDocument, { input: variables });
|
|
37
|
+
return result.deleteVote ?? null;
|
|
38
|
+
}
|