@uidu/client 3.12.0 → 3.13.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 +18 -0
- package/dist/declarations/src/applications.d.ts +56 -3
- package/dist/declarations/src/generated/index.d.ts +2883 -166
- package/dist/declarations/src/index.d.ts +3 -3
- package/dist/declarations/src/mutations.d.ts +20 -1
- package/dist/declarations/src/sites.d.ts +23 -1
- package/dist/uidu-client.cjs.dev.js +54 -3
- package/dist/uidu-client.cjs.prod.js +54 -3
- package/dist/uidu-client.esm.js +51 -4
- package/package.json +1 -1
- package/src/applications.test.ts +42 -0
- package/src/applications.ts +31 -2
- package/src/generated/index.ts +2526 -170
- package/src/index.ts +8 -1
- package/src/mutations.ts +7 -0
- package/src/queries/applications/UpdateApplication.graphql +17 -0
- package/src/queries/people/TimeClockMutations.graphql +17 -0
- package/src/queries/sites/CreateSite.graphql +15 -0
- package/src/sites.test.ts +26 -0
- package/src/sites.ts +17 -0
package/package.json
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { completeApplication, updateApplication } from './applications';
|
|
3
|
+
import type { UiduClient } from './client';
|
|
4
|
+
|
|
5
|
+
const payload = {
|
|
6
|
+
updateApplication: { application: { id: 'a1', aasmState: 'completed' }, errors: [] },
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
describe('updateApplication', () => {
|
|
10
|
+
it('passes the variables through and returns the payload', async () => {
|
|
11
|
+
const mutate = vi.fn().mockResolvedValue(payload);
|
|
12
|
+
const client = { mutate } as unknown as UiduClient;
|
|
13
|
+
|
|
14
|
+
const result = await updateApplication(client, {
|
|
15
|
+
input: { id: 'a1', attributes: { summary: 'Note' } },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(mutate.mock.calls[0][1]).toEqual({ input: { id: 'a1', attributes: { summary: 'Note' } } });
|
|
19
|
+
expect(result).toEqual(payload.updateApplication);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns null when the payload is missing', async () => {
|
|
23
|
+
const client = { mutate: vi.fn().mockResolvedValue({}) } as unknown as UiduClient;
|
|
24
|
+
|
|
25
|
+
expect(await updateApplication(client, { input: { id: 'a1', attributes: {} } })).toBeNull();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('completeApplication', () => {
|
|
30
|
+
it('fires the complete! event with no attributes', async () => {
|
|
31
|
+
const mutate = vi.fn().mockResolvedValue(payload);
|
|
32
|
+
const client = { mutate } as unknown as UiduClient;
|
|
33
|
+
|
|
34
|
+
const result = await completeApplication(client, 'a1');
|
|
35
|
+
|
|
36
|
+
expect(mutate).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(mutate.mock.calls[0][1]).toEqual({
|
|
38
|
+
input: { id: 'a1', event: 'complete!', attributes: {} },
|
|
39
|
+
});
|
|
40
|
+
expect(result?.application?.aasmState).toBe('completed');
|
|
41
|
+
});
|
|
42
|
+
});
|
package/src/applications.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
ListApplicationsDocument,
|
|
6
6
|
type ListApplicationsQuery,
|
|
7
7
|
type ListApplicationsQueryVariables,
|
|
8
|
+
UpdateApplicationDocument,
|
|
9
|
+
type UpdateApplicationMutationVariables,
|
|
8
10
|
} from './generated';
|
|
9
11
|
import { nodes } from './utils/relay';
|
|
10
12
|
|
|
@@ -17,8 +19,9 @@ import { nodes } from './utils/relay';
|
|
|
17
19
|
* `yarn workspace @uidu/client codegen` after editing those files.
|
|
18
20
|
*
|
|
19
21
|
* Reads (`listApplications`) require a Bearer token (`apiKey`): applications
|
|
20
|
-
* hold private candidate data. Writes (`createApplication
|
|
21
|
-
* "apply to this
|
|
22
|
+
* hold private candidate data. Writes (`createApplication`,
|
|
23
|
+
* `updateApplication`, `completeApplication`) are the public "apply to this
|
|
24
|
+
* job" path.
|
|
22
25
|
*/
|
|
23
26
|
export type Application = NonNullable<
|
|
24
27
|
NonNullable<
|
|
@@ -49,3 +52,29 @@ export async function createApplication(
|
|
|
49
52
|
const result = await client.mutate(CreateApplicationDocument, variables);
|
|
50
53
|
return result.createApplication ?? null;
|
|
51
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Update an application, optionally firing a state event (`event: 'complete!'`).
|
|
58
|
+
* Returns the mutation payload as-is (including any `errors`) rather than
|
|
59
|
+
* throwing.
|
|
60
|
+
*/
|
|
61
|
+
export async function updateApplication(
|
|
62
|
+
client: UiduClient,
|
|
63
|
+
variables: UpdateApplicationMutationVariables,
|
|
64
|
+
) {
|
|
65
|
+
const result = await client.mutate(UpdateApplicationDocument, variables);
|
|
66
|
+
return result.updateApplication ?? null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Submit a draft application, the last step of applying.
|
|
71
|
+
*
|
|
72
|
+
* `createApplication` leaves the application in `draft`, and a call's board
|
|
73
|
+
* lists only completed ones: until this runs, nobody sees the candidate. The
|
|
74
|
+
* `complete!` event stamps `completedAt`, marks the form response completed and
|
|
75
|
+
* notifies whoever follows the call — the same call uidu's own public site
|
|
76
|
+
* makes after its last step. A no-op on an application already completed.
|
|
77
|
+
*/
|
|
78
|
+
export async function completeApplication(client: UiduClient, id: string) {
|
|
79
|
+
return updateApplication(client, { input: { id, event: 'complete!', attributes: {} } });
|
|
80
|
+
}
|