@reqquest/ui 1.1.0 → 1.1.2

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/dist/api.js CHANGED
@@ -1,1163 +1 @@
1
- import { PUBLIC_API_BASE, PUBLIC_AUTH_REDIRECT, PUBLIC_SHOW_DUPLICATE_PROMPTS } from '$env/static/public';
2
- import { APIBase } from '@txstate-mws/sveltekit-utils';
3
- import { createClient, enumAppRequestIndexDestination, enumIneligiblePhases, enumPromptVisibility, enumRequirementStatus, enumRequirementType } from './typed-client/index.js';
4
- import { DateTime } from 'luxon';
5
- import { omit, pick } from 'txstate-utils';
6
- import { error } from '@sveltejs/kit';
7
- import { applicantRequirementTypes } from './status-utils.js';
8
- export const showDupePrompts = PUBLIC_SHOW_DUPLICATE_PROMPTS.trim() === 'true';
9
- class API extends APIBase {
10
- client = createClient({
11
- url: PUBLIC_API_BASE,
12
- fetcher: async (operation) => {
13
- if (Array.isArray(operation))
14
- throw new Error('Batching not supported');
15
- const data = await this.graphql(operation.query, operation.variables);
16
- return { data };
17
- }
18
- });
19
- async getAccess() {
20
- const response = await this.client.query({
21
- __name: 'GetAccess',
22
- access: {
23
- user: {
24
- login: true,
25
- fullname: true
26
- },
27
- createPeriod: true,
28
- createRole: true,
29
- viewRoleManagement: true,
30
- viewPeriodManagement: true,
31
- viewReviewerInterface: true,
32
- viewApplicantDashboard: true,
33
- viewAppRequestList: true,
34
- createAppRequestSelf: true,
35
- createAppRequestOther: true
36
- }
37
- });
38
- return response.access;
39
- }
40
- async getAccessUsers(accessUsersFilter, pageFilter) {
41
- const filter = accessUsersFilter;
42
- const paged = pageFilter;
43
- const response = await this.client.query({
44
- __name: 'GetAccessUsers',
45
- accessUsers: {
46
- __args: { filter, paged },
47
- login: true,
48
- fullname: true,
49
- groups: true,
50
- roles: {
51
- name: true
52
- },
53
- otherIdentifiers: {
54
- id: true,
55
- label: true
56
- },
57
- otherInfo: true
58
- },
59
- pageInfo: {
60
- accessUsers: {
61
- currentPage: true,
62
- totalItems: true,
63
- hasNextPage: true,
64
- perPage: true,
65
- categories: {
66
- tags: {
67
- tag: true,
68
- label: true
69
- },
70
- category: true,
71
- label: true,
72
- useInFilters: true,
73
- useInList: true
74
- }
75
- }
76
- }
77
- });
78
- return { users: response.accessUsers, pageInfo: response.pageInfo.accessUsers };
79
- }
80
- async getApplicantRequests(additionalFilters = {}, paged) {
81
- // const filter = { own: true, ...additionalFilters }
82
- const filter = { ...additionalFilters };
83
- const response = await this.client.query({
84
- __name: 'GetApplicantRequests',
85
- appRequests: {
86
- __args: { filter, paged },
87
- id: true,
88
- status: true,
89
- createdAt: true,
90
- updatedAt: true,
91
- complete: true,
92
- applicant: {
93
- fullname: true,
94
- otherIdentifiers: {
95
- id: true
96
- }
97
- },
98
- period: {
99
- name: true,
100
- openDate: true,
101
- closeDate: true
102
- },
103
- applications: {
104
- id: true,
105
- title: true,
106
- status: true,
107
- statusReason: true,
108
- requirements: {
109
- id: true,
110
- type: true,
111
- status: true,
112
- statusReason: true,
113
- prompts: {
114
- id: true,
115
- visibility: true,
116
- invalidated: true,
117
- invalidatedReason: true
118
- }
119
- }
120
- },
121
- actions: {
122
- acceptOffer: true,
123
- cancel: true,
124
- reopen: true,
125
- returnToApplicant: true,
126
- returnToOffer: true,
127
- submit: true
128
- }
129
- }
130
- });
131
- return response.appRequests;
132
- }
133
- async getApplicantPrompt(appRequestId, promptId) {
134
- const response = await this.client.query({
135
- __name: 'GetPromptData',
136
- appRequests: {
137
- __args: { filter: { ids: [appRequestId] } },
138
- data: true,
139
- dataVersion: true,
140
- applications: {
141
- id: true,
142
- requirements: {
143
- type: true,
144
- status: true,
145
- statusReason: true,
146
- prompts: {
147
- id: true,
148
- key: true,
149
- title: true,
150
- description: true,
151
- answered: true,
152
- visibility: true,
153
- preloadData: true,
154
- fetchedData: true,
155
- configurationData: true,
156
- gatheredConfigData: true
157
- }
158
- }
159
- }
160
- }
161
- });
162
- if (response.appRequests.length === 0)
163
- return {};
164
- const appRequest = response.appRequests[0];
165
- for (const application of appRequest.applications) {
166
- for (const requirement of application.requirements.filter(r => applicantRequirementTypes.has(r.type))) {
167
- for (const prompt of requirement.prompts) {
168
- if (prompt.id === promptId)
169
- return { prompt };
170
- }
171
- }
172
- }
173
- return {};
174
- }
175
- async updatePrompt(promptId, data, validateOnly, dataVersion) {
176
- const response = await this.graphqlWithUploads(`
177
- mutation UpdatePrompt($promptId: ID!, $data: JsonData!, $validateOnly: Boolean!, $dataVersion: Int) {
178
- updatePrompt(promptId: $promptId, data: $data, validateOnly: $validateOnly, dataVersion: $dataVersion) {
179
- success
180
- messages {
181
- message
182
- type
183
- arg
184
- }
185
- }
186
- }
187
- `, { promptId, data, validateOnly, dataVersion });
188
- return this.mutationForDialog(response.updatePrompt);
189
- }
190
- async updateConfiguration(periodId, definitionKey, data, validateOnly) {
191
- const response = await this.client.mutation({
192
- __name: 'UpdateConfiguration',
193
- updateConfiguration: {
194
- __args: { periodId, key: definitionKey, data, validateOnly },
195
- success: true,
196
- messages: {
197
- message: true,
198
- type: true,
199
- arg: true
200
- }
201
- }
202
- });
203
- return this.mutationForDialog(response.updateConfiguration);
204
- }
205
- async getAppRequestData(appRequestId) {
206
- const response = await this.client.query({
207
- __name: 'GetAppRequestData',
208
- appRequests: {
209
- __args: { filter: { ids: [appRequestId] } },
210
- id: true,
211
- data: true,
212
- applications: {
213
- requirements: {
214
- prompts: {
215
- key: true,
216
- gatheredConfigData: true
217
- }
218
- }
219
- }
220
- }
221
- });
222
- if (response.appRequests.length === 0)
223
- return { data: {}, applications: [] };
224
- const appRequest = response.appRequests[0];
225
- return appRequest;
226
- }
227
- static splitPromptsForApplicant(applications) {
228
- const prequalPrompts = [];
229
- const postqualPrompts = [];
230
- const qualPrompts = [];
231
- const applicationsReviewWithDupes = [];
232
- const applicationsReviewNoDupes = [];
233
- const applicationsForNavWithDupes = [];
234
- const applicationsForNavNoDupes = [];
235
- const applicationsAcceptWithDupes = [];
236
- const applicationsAcceptNoDupes = [];
237
- const promptsById = {};
238
- const promptsByKey = {};
239
- const seenForReview = new Set();
240
- const seenForNav = new Set();
241
- const seenForAccept = new Set();
242
- const visibilitiesToShow = new Set([enumPromptVisibility.AVAILABLE, enumPromptVisibility.REQUEST_DUPE]);
243
- const requirementTypesForNavigation = new Set([enumRequirementType.PREQUAL, enumRequirementType.POSTQUAL, enumRequirementType.QUALIFICATION]);
244
- const requirementTypesForReview = new Set([enumRequirementType.QUALIFICATION, enumRequirementType.PREAPPROVAL, enumRequirementType.APPROVAL, enumRequirementType.WORKFLOW]);
245
- for (const application of applications) {
246
- const requirementsReviewWithDupes = [];
247
- const requirementsReviewNoDupes = [];
248
- const requirementsForNavWithDupes = [];
249
- const requirementsForNavNoDupes = [];
250
- const requirementsAcceptWithDupes = [];
251
- const requirementsAcceptNoDupes = [];
252
- for (const requirement of application.requirements) {
253
- const promptsForNavWithDupes = [];
254
- const promptsForNavNoDupes = [];
255
- const promptsReviewNoDupes = [];
256
- const promptsReviewWithDupes = [];
257
- const promptsAcceptWithDupes = [];
258
- const promptsAcceptNoDupes = [];
259
- for (const prompt of requirement.prompts) {
260
- const retPrompt = { ...prompt, statusReasons: [{ ...pick(requirement, 'status', 'statusReason'), programName: application.title }] };
261
- const withDupesPrompt = { ...retPrompt };
262
- promptsById[prompt.id] = retPrompt;
263
- if (prompt.moot || prompt.visibility === enumPromptVisibility.UNREACHABLE)
264
- continue;
265
- promptsByKey[prompt.key] ??= [];
266
- promptsByKey[prompt.key].push(retPrompt);
267
- if (!visibilitiesToShow.has(prompt.visibility))
268
- continue;
269
- promptsReviewWithDupes.push(withDupesPrompt);
270
- if (requirementTypesForNavigation.has(requirement.type))
271
- promptsForNavWithDupes.push(withDupesPrompt);
272
- if (requirement.type === enumRequirementType.ACCEPTANCE)
273
- promptsAcceptWithDupes.push(withDupesPrompt);
274
- if (!seenForReview.has(prompt.key))
275
- promptsReviewNoDupes.push(retPrompt);
276
- seenForReview.add(prompt.key);
277
- if (requirementTypesForNavigation.has(requirement.type)) {
278
- if (!seenForNav.has(prompt.key))
279
- promptsForNavNoDupes.push(retPrompt);
280
- seenForNav.add(prompt.key);
281
- }
282
- if (requirement.type === enumRequirementType.ACCEPTANCE) {
283
- if (!seenForAccept.has(prompt.key))
284
- promptsAcceptNoDupes.push(retPrompt);
285
- seenForAccept.add(prompt.key);
286
- }
287
- }
288
- if (requirement.type === enumRequirementType.PREQUAL)
289
- prequalPrompts.push(...promptsForNavNoDupes);
290
- else if (requirement.type === enumRequirementType.POSTQUAL)
291
- postqualPrompts.push(...promptsForNavNoDupes);
292
- else if (requirementTypesForReview.has(requirement.type)) {
293
- requirementsReviewWithDupes.push({ ...requirement, prompts: promptsReviewWithDupes });
294
- requirementsReviewNoDupes.push({ ...requirement, prompts: promptsReviewNoDupes });
295
- if (requirement.type === enumRequirementType.QUALIFICATION) {
296
- qualPrompts.push(...promptsForNavNoDupes);
297
- requirementsForNavWithDupes.push({ ...requirement, prompts: promptsForNavWithDupes });
298
- requirementsForNavNoDupes.push({ ...requirement, prompts: promptsForNavNoDupes });
299
- }
300
- }
301
- else if (requirement.type === enumRequirementType.ACCEPTANCE) {
302
- requirementsAcceptWithDupes.push({ ...requirement, prompts: promptsAcceptWithDupes });
303
- requirementsAcceptNoDupes.push({ ...requirement, prompts: promptsAcceptNoDupes });
304
- }
305
- }
306
- const reqsForCompletion = application.requirements.filter(r => r.type !== enumRequirementType.POSTQUAL);
307
- let completionStatus = 'ELIGIBLE';
308
- let completionStatusForNav = 'ELIGIBLE';
309
- const warningReasons = [];
310
- const warningReasonsFull = [];
311
- const ineligibleReasons = [];
312
- const ineligibleReasonsFull = [];
313
- let hasWarning = false;
314
- let hasWarningForNav = false;
315
- for (const req of reqsForCompletion) {
316
- const showWarnings = application.ineligiblePhase !== enumIneligiblePhases.PREQUAL || req.type === enumRequirementType.PREQUAL;
317
- if (req.status === enumRequirementStatus.PENDING) {
318
- if (completionStatus !== 'INELIGIBLE')
319
- completionStatus = 'PENDING';
320
- if (completionStatusForNav !== 'INELIGIBLE' && requirementTypesForNavigation.has(req.type))
321
- completionStatusForNav = 'PENDING';
322
- }
323
- else if (req.status === enumRequirementStatus.WARNING) {
324
- hasWarning = true;
325
- if (requirementTypesForNavigation.has(req.type))
326
- hasWarningForNav = true;
327
- if (req.statusReason && showWarnings) {
328
- if (requirementTypesForNavigation.has(req.type))
329
- warningReasons.push(req.statusReason);
330
- warningReasonsFull.push(req.statusReason);
331
- }
332
- }
333
- else if (req.status === enumRequirementStatus.DISQUALIFYING) {
334
- completionStatus = 'INELIGIBLE';
335
- if (requirementTypesForNavigation.has(req.type))
336
- completionStatusForNav = 'INELIGIBLE';
337
- if (req.statusReason && showWarnings) {
338
- if (requirementTypesForNavigation.has(req.type))
339
- ineligibleReasons.push(req.statusReason);
340
- if (application.ineligiblePhase !== enumIneligiblePhases.PREQUAL || req.type !== enumRequirementType.PREQUAL)
341
- ineligibleReasonsFull.push(req.statusReason);
342
- }
343
- }
344
- }
345
- applicationsReviewWithDupes.push({ ...application, requirements: requirementsReviewWithDupes, completionStatus, warningReasons: warningReasonsFull, ineligibleReasons: ineligibleReasonsFull, hasWarning });
346
- applicationsReviewNoDupes.push({ ...application, requirements: requirementsReviewNoDupes, completionStatus, warningReasons: warningReasonsFull, ineligibleReasons: ineligibleReasonsFull, hasWarning });
347
- applicationsForNavWithDupes.push({ ...application, requirements: requirementsForNavWithDupes, completionStatus: completionStatusForNav, warningReasons, ineligibleReasons, hasWarning: hasWarningForNav });
348
- applicationsForNavNoDupes.push({ ...application, requirements: requirementsForNavNoDupes, completionStatus: completionStatusForNav, warningReasons, ineligibleReasons, hasWarning: hasWarningForNav });
349
- applicationsAcceptWithDupes.push({ ...application, requirements: requirementsAcceptWithDupes, completionStatus, warningReasons: warningReasonsFull, ineligibleReasons: ineligibleReasonsFull, hasWarning });
350
- applicationsAcceptNoDupes.push({ ...application, requirements: requirementsAcceptNoDupes, completionStatus, warningReasons: warningReasonsFull, ineligibleReasons: ineligibleReasonsFull, hasWarning });
351
- }
352
- for (const prompts of Object.values(promptsByKey)) {
353
- const statusReasons = prompts.map(p => p.statusReasons[0]);
354
- for (const prompt of prompts)
355
- prompt.statusReasons = statusReasons;
356
- }
357
- return { prequalPrompts, postqualPrompts, qualPrompts, applicationsReviewWithDupes, applicationsReviewNoDupes, applicationsForNavWithDupes, applicationsForNavNoDupes, applicationsAcceptWithDupes, applicationsAcceptNoDupes, promptsByKey, promptsById };
358
- }
359
- async getAppRequestForExport(appRequestId) {
360
- const response = await this.client.query({
361
- __name: 'GetAppRequestForExport',
362
- appRequests: {
363
- __args: { filter: { ids: [appRequestId] } },
364
- id: true,
365
- status: true,
366
- data: true,
367
- dataVersion: true,
368
- period: {
369
- name: true
370
- },
371
- applications: {
372
- id: true,
373
- status: true,
374
- ineligiblePhase: true,
375
- statusReason: true,
376
- title: true,
377
- navTitle: true,
378
- requirements: {
379
- id: true,
380
- type: true,
381
- status: true,
382
- statusReason: true,
383
- prompts: {
384
- id: true,
385
- key: true,
386
- title: true,
387
- navTitle: true,
388
- answered: true,
389
- visibility: true,
390
- moot: true,
391
- invalidated: true,
392
- invalidatedReason: true,
393
- configurationData: true,
394
- gatheredConfigData: true
395
- }
396
- }
397
- }
398
- }
399
- });
400
- if (response.appRequests.length === 0)
401
- throw error(404, 'Application request not found');
402
- const splitInfo = API.splitPromptsForApplicant(response.appRequests[0]?.applications ?? []);
403
- return {
404
- ...omit(splitInfo, 'applicationsForNavNoDupes', 'applicationsForNavWithDupes', 'applicationsReviewNoDupes', 'applicationsReviewWithDupes'),
405
- applicationsForNav: showDupePrompts ? splitInfo.applicationsForNavWithDupes : splitInfo.applicationsForNavNoDupes,
406
- applicationsReview: showDupePrompts ? splitInfo.applicationsReviewWithDupes : splitInfo.applicationsReviewNoDupes,
407
- applicationsAccept: showDupePrompts ? splitInfo.applicationsAcceptWithDupes : splitInfo.applicationsAcceptNoDupes,
408
- appRequest: response.appRequests[0]
409
- };
410
- }
411
- async createAppRequest(periodId, login, validateOnly) {
412
- const messages = [];
413
- if (!periodId)
414
- messages.push({ message: 'You must select a period to create an application.', type: 'error', path: 'periodId' });
415
- if (!login)
416
- messages.push({ message: 'You must provide a login to create an application.', type: 'error', path: 'login' });
417
- if (messages.length > 0)
418
- return { success: false, messages, data: { periodId, login }, id: undefined };
419
- const response = await this.client.mutation({
420
- __name: 'CreateAppRequest',
421
- createAppRequest: {
422
- __args: { periodId: periodId, login: login, validateOnly },
423
- success: true,
424
- messages: {
425
- message: true,
426
- type: true,
427
- arg: true
428
- },
429
- appRequest: {
430
- id: true
431
- }
432
- }
433
- });
434
- return { ...this.mutationForDialog(response.createAppRequest), id: response.createAppRequest.appRequest?.id };
435
- }
436
- async appRequestPhaseChange(appRequestId, phaseChange) {
437
- const response = await this.graphql(`
438
- mutation AppRequestPhaseChange($appRequestId: ID!) {
439
- ${phaseChange}(appRequestId: $appRequestId) {
440
- success
441
- messages {
442
- message
443
- type
444
- arg
445
- }
446
- }
447
- }
448
- `, { appRequestId });
449
- return this.mutationForDialog(response[phaseChange]);
450
- }
451
- async cancelAppRequest(appRequestId, dataVersion) {
452
- const response = await this.client.mutation({
453
- __name: 'CancelAppRequest',
454
- cancelAppRequest: {
455
- __args: { appRequestId, dataVersion },
456
- success: true,
457
- messages: {
458
- message: true,
459
- type: true,
460
- arg: true
461
- }
462
- }
463
- });
464
- return this.mutationForDialog(response.cancelAppRequest);
465
- }
466
- async reopenAppRequest(appRequestId) {
467
- const response = await this.client.mutation({
468
- __name: 'ReopenAppRequest',
469
- reopenAppRequest: {
470
- __args: { appRequestId },
471
- success: true,
472
- messages: {
473
- message: true,
474
- type: true,
475
- arg: true
476
- }
477
- }
478
- });
479
- return this.mutationForDialog(response.reopenAppRequest);
480
- }
481
- async advanceWorkflow(applicationId) {
482
- const response = await this.client.mutation({
483
- __name: 'AdvanceWorkflow',
484
- advanceWorkflow: {
485
- __args: { applicationId },
486
- success: true,
487
- messages: {
488
- message: true,
489
- type: true,
490
- arg: true
491
- }
492
- }
493
- });
494
- return this.mutationForDialog(response.advanceWorkflow);
495
- }
496
- async reverseWorkflow(applicationId) {
497
- const response = await this.client.mutation({
498
- __name: 'ReverseWorkflow',
499
- reverseWorkflow: {
500
- __args: { applicationId },
501
- success: true,
502
- messages: {
503
- message: true,
504
- type: true,
505
- arg: true
506
- }
507
- }
508
- });
509
- return this.mutationForDialog(response.reverseWorkflow);
510
- }
511
- async closeAppRequest(appRequestId) {
512
- const response = await this.client.mutation({
513
- __name: 'CloseAppRequest',
514
- closeAppRequest: {
515
- __args: { appRequestId },
516
- success: true,
517
- messages: {
518
- message: true,
519
- type: true,
520
- arg: true
521
- }
522
- }
523
- });
524
- return this.mutationForDialog(response.closeAppRequest);
525
- }
526
- async getAppRequests(filter, paged, dest = enumAppRequestIndexDestination.APP_REQUEST_LIST) {
527
- const processedFilter = {
528
- ...filter,
529
- indexes: filter?.indexes ? Object.entries(filter.indexes).map(([category, tags]) => ({ category, tags })) : undefined
530
- };
531
- const response = await this.client.query({
532
- __name: 'GetAppRequests',
533
- appRequests: {
534
- __args: { filter: processedFilter, paged },
535
- id: true,
536
- createdAt: true,
537
- closedAt: true,
538
- updatedAt: true,
539
- applications: {
540
- title: true
541
- },
542
- applicant: {
543
- login: true,
544
- fullname: true
545
- },
546
- status: true,
547
- statusReason: true,
548
- period: {
549
- id: true,
550
- name: true
551
- },
552
- indexCategories: {
553
- __args: { for: dest },
554
- category: true,
555
- categoryLabel: true,
556
- values: {
557
- value: true,
558
- label: true
559
- }
560
- },
561
- actions: {
562
- review: true
563
- }
564
- },
565
- appRequestIndexes: {
566
- category: true,
567
- categoryLabel: true,
568
- appRequestListPriority: true,
569
- listFiltersPriority: true,
570
- listable: true,
571
- values: {
572
- __args: { inUse: true },
573
- value: true,
574
- label: true
575
- }
576
- },
577
- pageInfo: {
578
- appRequests: {
579
- currentPage: true,
580
- totalItems: true,
581
- hasNextPage: true,
582
- perPage: true,
583
- categories: {
584
- tags: {
585
- tag: true,
586
- label: true
587
- },
588
- category: true,
589
- label: true,
590
- useInFilters: true,
591
- useInList: true
592
- }
593
- }
594
- }
595
- });
596
- return response;
597
- }
598
- async searchIndexItems(category, search) {
599
- const response = await this.client.query({
600
- __name: 'SearchIndexItems',
601
- appRequestIndexes: {
602
- __args: { categories: [category] },
603
- values: {
604
- __args: { search },
605
- value: true,
606
- label: true
607
- }
608
- }
609
- });
610
- return response.appRequestIndexes[0]?.values ?? [];
611
- }
612
- async getBasicRequestData(appRequestId) {
613
- const response = await this.client.query({
614
- __name: 'GetBasicRequestData',
615
- appRequests: {
616
- __args: { filter: { ids: [appRequestId] } },
617
- complete: true,
618
- status: true,
619
- closedAt: true,
620
- applicant: {
621
- login: true,
622
- fullname: true,
623
- otherIdentifiers: {
624
- id: true,
625
- label: true
626
- },
627
- otherInfo: true
628
- },
629
- period: {
630
- id: true,
631
- name: true,
632
- code: true,
633
- openDate: true,
634
- closeDate: true,
635
- archiveDate: true
636
- },
637
- applications: {
638
- id: true,
639
- navTitle: true,
640
- programKey: true
641
- },
642
- actions: {
643
- acceptOffer: true,
644
- cancel: true,
645
- close: true,
646
- completeRequest: true,
647
- completeReview: true,
648
- reopen: true,
649
- returnToApplicant: true,
650
- returnToNonBlocking: true,
651
- returnToOffer: true,
652
- returnToReview: true,
653
- review: true,
654
- submit: true
655
- }
656
- }
657
- });
658
- if (response.appRequests.length === 0)
659
- return undefined;
660
- return response.appRequests[0];
661
- }
662
- async getReviewData(appRequestId, visibilities = [enumPromptVisibility.AVAILABLE, enumPromptVisibility.REQUEST_DUPE]) {
663
- const response = await this.client.query({
664
- __name: 'GetReviewData',
665
- appRequests: {
666
- __args: { filter: { ids: [appRequestId] } },
667
- id: true,
668
- status: true,
669
- data: true,
670
- applications: {
671
- id: true,
672
- phase: true,
673
- status: true,
674
- statusReason: true,
675
- title: true,
676
- navTitle: true,
677
- programKey: true,
678
- workflowStage: {
679
- key: true,
680
- blocking: true
681
- },
682
- nextWorkflowStage: {
683
- key: true,
684
- title: true
685
- },
686
- previousWorkflowStage: {
687
- key: true,
688
- title: true
689
- },
690
- actions: {
691
- advanceWorkflow: true,
692
- reverseWorkflow: true
693
- },
694
- requirements: {
695
- id: true,
696
- type: true,
697
- title: true,
698
- status: true,
699
- statusReason: true,
700
- workflowStage: {
701
- key: true,
702
- title: true,
703
- blocking: true
704
- },
705
- prompts: {
706
- id: true,
707
- key: true,
708
- title: true,
709
- navTitle: true,
710
- answered: true,
711
- visibility: true,
712
- configurationData: true,
713
- gatheredConfigData: true,
714
- moot: true,
715
- invalidated: true,
716
- invalidatedReason: true,
717
- preloadData: true,
718
- fetchedData: true,
719
- actions: {
720
- update: true
721
- }
722
- }
723
- }
724
- },
725
- actions: {
726
- acceptOffer: true,
727
- cancel: true,
728
- close: true,
729
- completeRequest: true,
730
- completeReview: true,
731
- reopen: true,
732
- returnToApplicant: true,
733
- returnToNonBlocking: true,
734
- returnToOffer: true,
735
- returnToReview: true,
736
- review: true,
737
- submit: true
738
- }
739
- }
740
- });
741
- if (response.appRequests.length === 0)
742
- return undefined;
743
- const appRequest = response.appRequests[0];
744
- return { ...appRequest, applications: appRequest.applications.map(a => ({ ...a, requirements: a.requirements.map(r => ({ ...r, prompts: r.prompts.filter(p => visibilities.includes(p.visibility)) })) })) };
745
- }
746
- async getRequestActivity(appRequestId, filters, paged) {
747
- const response = await this.client.query({
748
- __name: 'GetRequestActivity',
749
- appRequests: {
750
- __args: { filter: { ids: [appRequestId] } },
751
- activity: {
752
- __args: { filters, paged },
753
- id: true,
754
- user: {
755
- login: true,
756
- fullname: true
757
- },
758
- impersonatedBy: {
759
- login: true,
760
- fullname: true
761
- },
762
- action: true,
763
- description: true,
764
- data: true,
765
- createdAt: true
766
- }
767
- },
768
- pageInfo: {
769
- appRequestsActivity: {
770
- currentPage: true,
771
- totalItems: true,
772
- hasNextPage: true,
773
- perPage: true
774
- }
775
- }
776
- });
777
- if (response.appRequests.length === 0)
778
- return undefined;
779
- return {
780
- activity: response.appRequests[0].activity.map(activity => ({
781
- ...activity,
782
- createdAt: DateTime.fromISO(activity.createdAt)
783
- })),
784
- pageInfo: response.pageInfo.appRequestsActivity
785
- };
786
- }
787
- async getPromptData(appRequestId, promptId) {
788
- const response = await this.client.query({
789
- __name: 'GetPromptData',
790
- appRequests: {
791
- __args: { filter: { ids: [appRequestId] } },
792
- prompt: {
793
- __args: { promptId },
794
- data: true,
795
- preloadData: true,
796
- configurationData: true,
797
- gatheredConfigData: true,
798
- fetchedData: true
799
- }
800
- }
801
- });
802
- const appRequest = response.appRequests[0];
803
- return appRequest.prompt;
804
- }
805
- async getPeriodList() {
806
- const response = await this.client.query({
807
- __name: 'GetPeriodList',
808
- periods: {
809
- id: true,
810
- name: true,
811
- code: true,
812
- openDate: true,
813
- closeDate: true,
814
- archiveDate: true,
815
- reviewed: true,
816
- actions: {
817
- update: true,
818
- delete: true,
819
- createAppRequest: true
820
- }
821
- }
822
- });
823
- return response.periods;
824
- }
825
- async getOpenPeriods() {
826
- const response = await this.client.query({
827
- __name: 'GetOpenPeriods',
828
- periods: {
829
- __args: { filter: { openNow: true } },
830
- id: true,
831
- name: true,
832
- code: true,
833
- openDate: true,
834
- closeDate: true,
835
- archiveDate: true,
836
- reviewed: true
837
- }
838
- });
839
- return response.periods;
840
- }
841
- async createPeriod(period, validateOnly, copyPeriodId) {
842
- const response = await this.client.mutation({
843
- __name: 'CreatePeriod',
844
- createPeriod: {
845
- __args: { period, validateOnly, copyPeriodId },
846
- success: true,
847
- messages: {
848
- message: true,
849
- type: true,
850
- arg: true
851
- }
852
- }
853
- });
854
- return api.mutationForDialog(response.createPeriod, { prefix: 'period' });
855
- }
856
- async updatePeriod(periodId, period, validateOnly) {
857
- const response = await this.client.mutation({
858
- __name: 'UpdatePeriod',
859
- updatePeriod: {
860
- __args: { periodId, update: period, validateOnly },
861
- success: true,
862
- messages: {
863
- message: true,
864
- type: true,
865
- arg: true
866
- }
867
- }
868
- });
869
- return this.mutationForDialog(response.updatePeriod, { prefix: 'period' });
870
- }
871
- async markPeriodReviewed(periodId, validateOnly) {
872
- const response = await this.client.mutation({
873
- __name: 'MarkPeriodReviewed',
874
- markPeriodReviewed: {
875
- __args: { periodId, validateOnly },
876
- success: true,
877
- messages: {
878
- message: true,
879
- type: true,
880
- arg: true
881
- }
882
- }
883
- });
884
- return this.mutationForDialog(response.markPeriodReviewed, { prefix: 'period' });
885
- }
886
- async deletePeriod(periodId) {
887
- const response = await this.client.mutation({
888
- __name: 'DeletePeriod',
889
- deletePeriod: {
890
- __args: { periodId },
891
- success: true
892
- }
893
- });
894
- return response.deletePeriod.success;
895
- }
896
- async disablePeriodProgramRequirements(periodId, requirementKey, disabled) {
897
- const response = await this.client.mutation({
898
- __name: 'updatePeriodProgram',
899
- updatePeriodRequirement: {
900
- __args: { periodId, requirementKey, disabled },
901
- success: true
902
- }
903
- });
904
- return response.updatePeriodRequirement.success;
905
- }
906
- async getPeriodConfigurations(periodId) {
907
- const response = await this.client.query({
908
- __name: 'GetPeriodConfigurations',
909
- periods: {
910
- __args: { filter: { ids: [periodId] } },
911
- id: true,
912
- name: true,
913
- code: true,
914
- openDate: true,
915
- closeDate: true,
916
- archiveDate: true,
917
- reviewed: true,
918
- programs: {
919
- key: true,
920
- title: true,
921
- enabled: true,
922
- requirements: {
923
- key: true,
924
- title: true,
925
- description: true,
926
- enabled: true,
927
- type: true,
928
- configuration: {
929
- data: true,
930
- actions: {
931
- update: true
932
- }
933
- },
934
- prompts: {
935
- key: true,
936
- title: true,
937
- description: true,
938
- configuration: {
939
- data: true,
940
- actions: {
941
- update: true
942
- }
943
- }
944
- }
945
- }
946
- }
947
- }
948
- });
949
- if (!response.periods.length)
950
- return { period: undefined, programs: [] };
951
- const period = response.periods[0];
952
- return { programs: period.programs, period };
953
- }
954
- async getConfigurationFetched(periodId, definitionKey) {
955
- const response = await this.client.query({
956
- __name: 'GetConfigurationFetched',
957
- periods: {
958
- __args: { filter: { ids: [periodId] } },
959
- configurations: {
960
- __args: { filter: { keys: [definitionKey] } },
961
- fetchedData: true
962
- }
963
- }
964
- });
965
- return response.periods[0].configurations[0]?.fetchedData ?? {};
966
- }
967
- async getRoleList() {
968
- const response = await this.client.query({
969
- __name: 'GetRoleList',
970
- roles: {
971
- id: true,
972
- name: true,
973
- description: true,
974
- groups: {
975
- groupName: true,
976
- managers: {
977
- fullname: true,
978
- email: true
979
- },
980
- dateAdded: true,
981
- dateCreated: true
982
- },
983
- actions: {
984
- update: true,
985
- delete: true
986
- }
987
- }
988
- });
989
- if (response.roles.length === 0)
990
- return undefined;
991
- const roles = response.roles;
992
- return roles.map(role => ({ ...role, groups: role.groups.map((group) => ({
993
- ...group,
994
- dateAdded: DateTime.fromISO(group.dateAdded),
995
- dateCreated: group.dateCreated ? DateTime.fromISO(group.dateCreated) : undefined
996
- })) }));
997
- }
998
- async getRoleDetails(roleId) {
999
- const response = await this.client.query({
1000
- __name: 'GetRoleDetails',
1001
- roles: {
1002
- __args: { filter: { ids: [roleId] } },
1003
- id: true,
1004
- name: true,
1005
- description: true,
1006
- groups: {
1007
- groupName: true,
1008
- managers: {
1009
- fullname: true,
1010
- email: true
1011
- },
1012
- dateAdded: true,
1013
- dateCreated: true
1014
- },
1015
- grants: {
1016
- id: true,
1017
- controlGroup: {
1018
- name: true,
1019
- title: true,
1020
- description: true
1021
- },
1022
- allow: true,
1023
- controls: true,
1024
- tags: {
1025
- category: true,
1026
- categoryLabel: true,
1027
- tag: true,
1028
- label: true
1029
- },
1030
- actions: {
1031
- update: true,
1032
- delete: true
1033
- }
1034
- },
1035
- actions: {
1036
- update: true,
1037
- delete: true
1038
- }
1039
- }
1040
- });
1041
- if (!response.roles.length)
1042
- return undefined;
1043
- const role = response.roles[0];
1044
- return { ...role, groups: role.groups.map((group) => ({
1045
- ...group,
1046
- dateAdded: DateTime.fromISO(group.dateAdded),
1047
- dateCreated: group.dateCreated ? DateTime.fromISO(group.dateCreated) : undefined
1048
- })) };
1049
- }
1050
- async getAuthorizationInfo() {
1051
- const response = await this.client.query({
1052
- __name: 'GetAuthorizationInfo',
1053
- controlGroups: {
1054
- name: true,
1055
- title: true,
1056
- description: true,
1057
- tags: {
1058
- category: true,
1059
- label: true,
1060
- description: true,
1061
- listable: true,
1062
- tags: {
1063
- value: true,
1064
- label: true
1065
- }
1066
- },
1067
- controls: {
1068
- name: true,
1069
- description: true
1070
- }
1071
- }
1072
- });
1073
- return response.controlGroups;
1074
- }
1075
- async upsertRole(roleId, role, validateOnly, copyRoleId) {
1076
- if (roleId != null) {
1077
- const response = await this.client.mutation({
1078
- __name: 'UpdateRole',
1079
- roleUpdate: {
1080
- __args: { roleId, role, validateOnly },
1081
- success: true,
1082
- messages: {
1083
- message: true,
1084
- type: true,
1085
- arg: true
1086
- }
1087
- }
1088
- });
1089
- return this.mutationForDialog(response.roleUpdate);
1090
- }
1091
- else {
1092
- const response = await this.client.mutation({
1093
- __name: 'CreateRole',
1094
- roleCreate: {
1095
- __args: { role, copyRoleId, validateOnly },
1096
- success: true,
1097
- messages: {
1098
- message: true,
1099
- type: true,
1100
- arg: true
1101
- }
1102
- }
1103
- });
1104
- return this.mutationForDialog(response.roleCreate);
1105
- }
1106
- }
1107
- async deleteRole(roleId) {
1108
- const response = await this.client.mutation({
1109
- __name: 'DeleteRole',
1110
- roleDelete: {
1111
- __args: { roleId },
1112
- success: true
1113
- }
1114
- });
1115
- return response.roleDelete.success;
1116
- }
1117
- async updateGrant(grantId, grant, validateOnly) {
1118
- const response = await this.client.mutation({
1119
- __name: 'UpdateGrant',
1120
- roleUpdateGrant: {
1121
- __args: { grantId, grant, validateOnly },
1122
- success: true,
1123
- messages: {
1124
- message: true,
1125
- type: true,
1126
- arg: true
1127
- }
1128
- }
1129
- });
1130
- return this.mutationForDialog(response.roleUpdateGrant);
1131
- }
1132
- async createGrant(roleId, grant, validateOnly) {
1133
- const response = await this.client.mutation({
1134
- __name: 'CreateGrant',
1135
- roleAddGrant: {
1136
- __args: { roleId, grant, validateOnly },
1137
- success: true,
1138
- messages: {
1139
- message: true,
1140
- type: true,
1141
- arg: true
1142
- }
1143
- }
1144
- });
1145
- return this.mutationForDialog(response.roleAddGrant);
1146
- }
1147
- async deleteGrant(grantId) {
1148
- const response = await this.client.mutation({
1149
- __name: 'DeleteGrant',
1150
- roleDeleteGrant: {
1151
- __args: { grantId },
1152
- success: true,
1153
- messages: {
1154
- message: true,
1155
- type: true,
1156
- arg: true
1157
- }
1158
- }
1159
- });
1160
- return this.mutationForDialog(response.roleDeleteGrant);
1161
- }
1162
- }
1163
- export const api = new API(PUBLIC_API_BASE, PUBLIC_AUTH_REDIRECT);
1
+ export {};