@reqquest/ui 1.1.1 → 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,1159 +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
- actions: {
399
- viewApplyUI: true,
400
- viewAcceptUI: true
401
- }
402
- }
403
- });
404
- if (response.appRequests.length === 0)
405
- throw error(404, 'Application request not found');
406
- const splitInfo = API.splitPromptsForApplicant(response.appRequests[0]?.applications ?? []);
407
- return {
408
- ...omit(splitInfo, 'applicationsForNavNoDupes', 'applicationsForNavWithDupes', 'applicationsReviewNoDupes', 'applicationsReviewWithDupes'),
409
- applicationsForNav: showDupePrompts ? splitInfo.applicationsForNavWithDupes : splitInfo.applicationsForNavNoDupes,
410
- applicationsReview: showDupePrompts ? splitInfo.applicationsReviewWithDupes : splitInfo.applicationsReviewNoDupes,
411
- applicationsAccept: showDupePrompts ? splitInfo.applicationsAcceptWithDupes : splitInfo.applicationsAcceptNoDupes,
412
- appRequest: response.appRequests[0]
413
- };
414
- }
415
- async createAppRequest(periodId, login, validateOnly) {
416
- const messages = [];
417
- if (!periodId)
418
- messages.push({ message: 'You must select a period to create an application.', type: 'error', path: 'periodId' });
419
- if (!login)
420
- messages.push({ message: 'You must provide a login to create an application.', type: 'error', path: 'login' });
421
- if (messages.length > 0)
422
- return { success: false, messages, data: { periodId, login }, id: undefined };
423
- const response = await this.client.mutation({
424
- __name: 'CreateAppRequest',
425
- createAppRequest: {
426
- __args: { periodId: periodId, login: login, validateOnly },
427
- success: true,
428
- messages: {
429
- message: true,
430
- type: true,
431
- arg: true
432
- },
433
- appRequest: {
434
- id: true
435
- }
436
- }
437
- });
438
- return { ...this.mutationForDialog(response.createAppRequest), id: response.createAppRequest.appRequest?.id };
439
- }
440
- async appRequestPhaseChange(appRequestId, phaseChange) {
441
- const response = await this.graphql(`
442
- mutation AppRequestPhaseChange($appRequestId: ID!) {
443
- ${phaseChange}(appRequestId: $appRequestId) {
444
- success
445
- messages {
446
- message
447
- type
448
- arg
449
- }
450
- }
451
- }
452
- `, { appRequestId });
453
- return this.mutationForDialog(response[phaseChange]);
454
- }
455
- async cancelAppRequest(appRequestId, dataVersion) {
456
- const response = await this.client.mutation({
457
- __name: 'CancelAppRequest',
458
- cancelAppRequest: {
459
- __args: { appRequestId, dataVersion },
460
- success: true,
461
- messages: {
462
- message: true,
463
- type: true,
464
- arg: true
465
- }
466
- }
467
- });
468
- return this.mutationForDialog(response.cancelAppRequest);
469
- }
470
- async reopenAppRequest(appRequestId) {
471
- const response = await this.client.mutation({
472
- __name: 'ReopenAppRequest',
473
- reopenAppRequest: {
474
- __args: { appRequestId },
475
- success: true,
476
- messages: {
477
- message: true,
478
- type: true,
479
- arg: true
480
- }
481
- }
482
- });
483
- return this.mutationForDialog(response.reopenAppRequest);
484
- }
485
- async advanceWorkflow(applicationId) {
486
- const response = await this.client.mutation({
487
- __name: 'AdvanceWorkflow',
488
- advanceWorkflow: {
489
- __args: { applicationId },
490
- success: true,
491
- messages: {
492
- message: true,
493
- type: true,
494
- arg: true
495
- }
496
- }
497
- });
498
- return this.mutationForDialog(response.advanceWorkflow);
499
- }
500
- async reverseWorkflow(applicationId) {
501
- const response = await this.client.mutation({
502
- __name: 'ReverseWorkflow',
503
- reverseWorkflow: {
504
- __args: { applicationId },
505
- success: true,
506
- messages: {
507
- message: true,
508
- type: true,
509
- arg: true
510
- }
511
- }
512
- });
513
- return this.mutationForDialog(response.reverseWorkflow);
514
- }
515
- async closeAppRequest(appRequestId) {
516
- const response = await this.client.mutation({
517
- __name: 'CloseAppRequest',
518
- closeAppRequest: {
519
- __args: { appRequestId },
520
- success: true,
521
- messages: {
522
- message: true,
523
- type: true,
524
- arg: true
525
- }
526
- }
527
- });
528
- return this.mutationForDialog(response.closeAppRequest);
529
- }
530
- async getAppRequests(filter, paged, dest = enumAppRequestIndexDestination.APP_REQUEST_LIST) {
531
- const processedFilter = {
532
- ...filter,
533
- indexes: filter?.indexes ? Object.entries(filter.indexes).map(([category, tags]) => ({ category, tags })) : undefined
534
- };
535
- const response = await this.client.query({
536
- __name: 'GetAppRequests',
537
- appRequests: {
538
- __args: { filter: processedFilter, paged },
539
- id: true,
540
- createdAt: true,
541
- closedAt: true,
542
- updatedAt: true,
543
- applications: {
544
- title: true
545
- },
546
- applicant: {
547
- login: true,
548
- fullname: true
549
- },
550
- status: true,
551
- statusReason: true,
552
- period: {
553
- id: true,
554
- name: true
555
- },
556
- indexCategories: {
557
- __args: { for: dest },
558
- category: true,
559
- categoryLabel: true,
560
- values: {
561
- value: true,
562
- label: true
563
- }
564
- },
565
- actions: {
566
- review: true
567
- }
568
- },
569
- appRequestIndexes: {
570
- category: true,
571
- categoryLabel: true,
572
- appRequestListPriority: true,
573
- listFiltersPriority: true,
574
- listable: true,
575
- values: {
576
- __args: { inUse: true },
577
- value: true,
578
- label: true
579
- }
580
- },
581
- pageInfo: {
582
- appRequests: {
583
- currentPage: true,
584
- totalItems: true,
585
- hasNextPage: true,
586
- perPage: true,
587
- categories: {
588
- tags: {
589
- tag: true,
590
- label: true
591
- },
592
- category: true,
593
- label: true,
594
- useInFilters: true,
595
- useInList: true
596
- }
597
- }
598
- }
599
- });
600
- return response;
601
- }
602
- async searchIndexItems(category, search) {
603
- const response = await this.client.query({
604
- __name: 'SearchIndexItems',
605
- appRequestIndexes: {
606
- __args: { categories: [category] },
607
- values: {
608
- __args: { search },
609
- value: true,
610
- label: true
611
- }
612
- }
613
- });
614
- return response.appRequestIndexes[0]?.values ?? [];
615
- }
616
- async getBasicRequestData(appRequestId) {
617
- const response = await this.client.query({
618
- __name: 'GetBasicRequestData',
619
- appRequests: {
620
- __args: { filter: { ids: [appRequestId] } },
621
- complete: true,
622
- status: true,
623
- closedAt: true,
624
- applicant: {
625
- login: true,
626
- fullname: true,
627
- otherIdentifiers: {
628
- id: true,
629
- label: true
630
- },
631
- otherInfo: true
632
- },
633
- period: {
634
- id: true,
635
- name: true,
636
- code: true,
637
- openDate: true,
638
- closeDate: true,
639
- archiveDate: true
640
- },
641
- applications: {
642
- id: true,
643
- navTitle: true,
644
- programKey: true
645
- },
646
- actions: {
647
- acceptOffer: true,
648
- cancel: true,
649
- close: true,
650
- completeRequest: true,
651
- completeReview: true,
652
- reopen: true,
653
- returnToApplicant: true,
654
- returnToNonBlocking: true,
655
- returnToOffer: true,
656
- returnToReview: true,
657
- review: true,
658
- submit: true
659
- }
660
- }
661
- });
662
- if (response.appRequests.length === 0)
663
- return undefined;
664
- return response.appRequests[0];
665
- }
666
- async getReviewData(appRequestId, visibilities = [enumPromptVisibility.AVAILABLE, enumPromptVisibility.REQUEST_DUPE]) {
667
- const response = await this.client.query({
668
- __name: 'GetReviewData',
669
- appRequests: {
670
- __args: { filter: { ids: [appRequestId] } },
671
- id: true,
672
- status: true,
673
- data: true,
674
- applications: {
675
- id: true,
676
- phase: true,
677
- status: true,
678
- statusReason: true,
679
- title: true,
680
- navTitle: true,
681
- programKey: true,
682
- workflowStage: {
683
- key: true,
684
- blocking: true
685
- },
686
- nextWorkflowStage: {
687
- key: true,
688
- title: true
689
- },
690
- previousWorkflowStage: {
691
- key: true,
692
- title: true
693
- },
694
- actions: {
695
- advanceWorkflow: true,
696
- reverseWorkflow: true
697
- },
698
- requirements: {
699
- id: true,
700
- type: true,
701
- title: true,
702
- status: true,
703
- statusReason: true,
704
- workflowStage: {
705
- key: true,
706
- title: true,
707
- blocking: true
708
- },
709
- prompts: {
710
- id: true,
711
- key: true,
712
- title: true,
713
- navTitle: true,
714
- answered: true,
715
- visibility: true,
716
- configurationData: true,
717
- gatheredConfigData: true,
718
- moot: true,
719
- invalidated: true,
720
- invalidatedReason: true,
721
- preloadData: true,
722
- fetchedData: true,
723
- actions: {
724
- update: true
725
- }
726
- }
727
- }
728
- },
729
- actions: {
730
- acceptOffer: true,
731
- cancel: true,
732
- close: true,
733
- completeRequest: true,
734
- completeReview: true,
735
- reopen: true,
736
- returnToApplicant: true,
737
- returnToNonBlocking: true,
738
- returnToOffer: true,
739
- returnToReview: true,
740
- review: true,
741
- submit: true
742
- }
743
- }
744
- });
745
- if (response.appRequests.length === 0)
746
- return undefined;
747
- const appRequest = response.appRequests[0];
748
- return { ...appRequest, applications: appRequest.applications.map(a => ({ ...a, requirements: a.requirements.map(r => ({ ...r, prompts: r.prompts.filter(p => visibilities.includes(p.visibility)) })) })) };
749
- }
750
- async getRequestActivity(appRequestId, filters, paged) {
751
- const response = await this.client.query({
752
- __name: 'GetRequestActivity',
753
- appRequestActivity: {
754
- __args: { id: appRequestId, filters, paged },
755
- id: true,
756
- user: {
757
- login: true,
758
- fullname: true
759
- },
760
- impersonatedBy: {
761
- login: true,
762
- fullname: true
763
- },
764
- action: true,
765
- description: true,
766
- data: true,
767
- createdAt: true
768
- },
769
- pageInfo: {
770
- appRequestsActivity: {
771
- currentPage: true,
772
- totalItems: true,
773
- hasNextPage: true,
774
- perPage: true
775
- }
776
- }
777
- });
778
- return {
779
- activity: response.appRequestActivity,
780
- pageInfo: response.pageInfo.appRequestsActivity
781
- };
782
- }
783
- async getPromptData(appRequestId, promptId) {
784
- const response = await this.client.query({
785
- __name: 'GetPromptData',
786
- appRequests: {
787
- __args: { filter: { ids: [appRequestId] } },
788
- prompt: {
789
- __args: { promptId },
790
- data: true,
791
- preloadData: true,
792
- configurationData: true,
793
- gatheredConfigData: true,
794
- fetchedData: true
795
- }
796
- }
797
- });
798
- const appRequest = response.appRequests[0];
799
- return appRequest.prompt;
800
- }
801
- async getPeriodList() {
802
- const response = await this.client.query({
803
- __name: 'GetPeriodList',
804
- periods: {
805
- id: true,
806
- name: true,
807
- code: true,
808
- openDate: true,
809
- closeDate: true,
810
- archiveDate: true,
811
- reviewed: true,
812
- actions: {
813
- update: true,
814
- delete: true,
815
- createAppRequest: true
816
- }
817
- }
818
- });
819
- return response.periods;
820
- }
821
- async getOpenPeriods() {
822
- const response = await this.client.query({
823
- __name: 'GetOpenPeriods',
824
- periods: {
825
- __args: { filter: { openNow: true } },
826
- id: true,
827
- name: true,
828
- code: true,
829
- openDate: true,
830
- closeDate: true,
831
- archiveDate: true,
832
- reviewed: true
833
- }
834
- });
835
- return response.periods;
836
- }
837
- async createPeriod(period, validateOnly, copyPeriodId) {
838
- const response = await this.client.mutation({
839
- __name: 'CreatePeriod',
840
- createPeriod: {
841
- __args: { period, validateOnly, copyPeriodId },
842
- success: true,
843
- messages: {
844
- message: true,
845
- type: true,
846
- arg: true
847
- }
848
- }
849
- });
850
- return api.mutationForDialog(response.createPeriod, { prefix: 'period' });
851
- }
852
- async updatePeriod(periodId, period, validateOnly) {
853
- const response = await this.client.mutation({
854
- __name: 'UpdatePeriod',
855
- updatePeriod: {
856
- __args: { periodId, update: period, validateOnly },
857
- success: true,
858
- messages: {
859
- message: true,
860
- type: true,
861
- arg: true
862
- }
863
- }
864
- });
865
- return this.mutationForDialog(response.updatePeriod, { prefix: 'period' });
866
- }
867
- async markPeriodReviewed(periodId, validateOnly) {
868
- const response = await this.client.mutation({
869
- __name: 'MarkPeriodReviewed',
870
- markPeriodReviewed: {
871
- __args: { periodId, validateOnly },
872
- success: true,
873
- messages: {
874
- message: true,
875
- type: true,
876
- arg: true
877
- }
878
- }
879
- });
880
- return this.mutationForDialog(response.markPeriodReviewed, { prefix: 'period' });
881
- }
882
- async deletePeriod(periodId) {
883
- const response = await this.client.mutation({
884
- __name: 'DeletePeriod',
885
- deletePeriod: {
886
- __args: { periodId },
887
- success: true
888
- }
889
- });
890
- return response.deletePeriod.success;
891
- }
892
- async disablePeriodProgramRequirements(periodId, requirementKey, disabled) {
893
- const response = await this.client.mutation({
894
- __name: 'updatePeriodProgram',
895
- updatePeriodRequirement: {
896
- __args: { periodId, requirementKey, disabled },
897
- success: true
898
- }
899
- });
900
- return response.updatePeriodRequirement.success;
901
- }
902
- async getPeriodConfigurations(periodId) {
903
- const response = await this.client.query({
904
- __name: 'GetPeriodConfigurations',
905
- periods: {
906
- __args: { filter: { ids: [periodId] } },
907
- id: true,
908
- name: true,
909
- code: true,
910
- openDate: true,
911
- closeDate: true,
912
- archiveDate: true,
913
- reviewed: true,
914
- programs: {
915
- key: true,
916
- title: true,
917
- enabled: true,
918
- requirements: {
919
- key: true,
920
- title: true,
921
- description: true,
922
- enabled: true,
923
- type: true,
924
- configuration: {
925
- data: true,
926
- actions: {
927
- update: true
928
- }
929
- },
930
- prompts: {
931
- key: true,
932
- title: true,
933
- description: true,
934
- configuration: {
935
- data: true,
936
- actions: {
937
- update: true
938
- }
939
- }
940
- }
941
- }
942
- }
943
- }
944
- });
945
- if (!response.periods.length)
946
- return { period: undefined, programs: [] };
947
- const period = response.periods[0];
948
- return { programs: period.programs, period };
949
- }
950
- async getConfigurationFetched(periodId, definitionKey) {
951
- const response = await this.client.query({
952
- __name: 'GetConfigurationFetched',
953
- periods: {
954
- __args: { filter: { ids: [periodId] } },
955
- configurations: {
956
- __args: { filter: { keys: [definitionKey] } },
957
- fetchedData: true
958
- }
959
- }
960
- });
961
- return response.periods[0].configurations[0]?.fetchedData ?? {};
962
- }
963
- async getRoleList() {
964
- const response = await this.client.query({
965
- __name: 'GetRoleList',
966
- roles: {
967
- id: true,
968
- name: true,
969
- description: true,
970
- groups: {
971
- groupName: true,
972
- managers: {
973
- fullname: true,
974
- email: true
975
- },
976
- dateAdded: true,
977
- dateCreated: true
978
- },
979
- actions: {
980
- update: true,
981
- delete: true
982
- }
983
- }
984
- });
985
- if (response.roles.length === 0)
986
- return undefined;
987
- const roles = response.roles;
988
- return roles.map(role => ({ ...role, groups: role.groups.map((group) => ({
989
- ...group,
990
- dateAdded: DateTime.fromISO(group.dateAdded),
991
- dateCreated: group.dateCreated ? DateTime.fromISO(group.dateCreated) : undefined
992
- })) }));
993
- }
994
- async getRoleDetails(roleId) {
995
- const response = await this.client.query({
996
- __name: 'GetRoleDetails',
997
- roles: {
998
- __args: { filter: { ids: [roleId] } },
999
- id: true,
1000
- name: true,
1001
- description: true,
1002
- groups: {
1003
- groupName: true,
1004
- managers: {
1005
- fullname: true,
1006
- email: true
1007
- },
1008
- dateAdded: true,
1009
- dateCreated: true
1010
- },
1011
- grants: {
1012
- id: true,
1013
- controlGroup: {
1014
- name: true,
1015
- title: true,
1016
- description: true
1017
- },
1018
- allow: true,
1019
- controls: true,
1020
- tags: {
1021
- category: true,
1022
- categoryLabel: true,
1023
- tag: true,
1024
- label: true
1025
- },
1026
- actions: {
1027
- update: true,
1028
- delete: true
1029
- }
1030
- },
1031
- actions: {
1032
- update: true,
1033
- delete: true
1034
- }
1035
- }
1036
- });
1037
- if (!response.roles.length)
1038
- return undefined;
1039
- const role = response.roles[0];
1040
- return { ...role, groups: role.groups.map((group) => ({
1041
- ...group,
1042
- dateAdded: DateTime.fromISO(group.dateAdded),
1043
- dateCreated: group.dateCreated ? DateTime.fromISO(group.dateCreated) : undefined
1044
- })) };
1045
- }
1046
- async getAuthorizationInfo() {
1047
- const response = await this.client.query({
1048
- __name: 'GetAuthorizationInfo',
1049
- controlGroups: {
1050
- name: true,
1051
- title: true,
1052
- description: true,
1053
- tags: {
1054
- category: true,
1055
- label: true,
1056
- description: true,
1057
- listable: true,
1058
- tags: {
1059
- value: true,
1060
- label: true
1061
- }
1062
- },
1063
- controls: {
1064
- name: true,
1065
- description: true
1066
- }
1067
- }
1068
- });
1069
- return response.controlGroups;
1070
- }
1071
- async upsertRole(roleId, role, validateOnly, copyRoleId) {
1072
- if (roleId != null) {
1073
- const response = await this.client.mutation({
1074
- __name: 'UpdateRole',
1075
- roleUpdate: {
1076
- __args: { roleId, role, validateOnly },
1077
- success: true,
1078
- messages: {
1079
- message: true,
1080
- type: true,
1081
- arg: true
1082
- }
1083
- }
1084
- });
1085
- return this.mutationForDialog(response.roleUpdate);
1086
- }
1087
- else {
1088
- const response = await this.client.mutation({
1089
- __name: 'CreateRole',
1090
- roleCreate: {
1091
- __args: { role, copyRoleId, validateOnly },
1092
- success: true,
1093
- messages: {
1094
- message: true,
1095
- type: true,
1096
- arg: true
1097
- }
1098
- }
1099
- });
1100
- return this.mutationForDialog(response.roleCreate);
1101
- }
1102
- }
1103
- async deleteRole(roleId) {
1104
- const response = await this.client.mutation({
1105
- __name: 'DeleteRole',
1106
- roleDelete: {
1107
- __args: { roleId },
1108
- success: true
1109
- }
1110
- });
1111
- return response.roleDelete.success;
1112
- }
1113
- async updateGrant(grantId, grant, validateOnly) {
1114
- const response = await this.client.mutation({
1115
- __name: 'UpdateGrant',
1116
- roleUpdateGrant: {
1117
- __args: { grantId, grant, validateOnly },
1118
- success: true,
1119
- messages: {
1120
- message: true,
1121
- type: true,
1122
- arg: true
1123
- }
1124
- }
1125
- });
1126
- return this.mutationForDialog(response.roleUpdateGrant);
1127
- }
1128
- async createGrant(roleId, grant, validateOnly) {
1129
- const response = await this.client.mutation({
1130
- __name: 'CreateGrant',
1131
- roleAddGrant: {
1132
- __args: { roleId, grant, validateOnly },
1133
- success: true,
1134
- messages: {
1135
- message: true,
1136
- type: true,
1137
- arg: true
1138
- }
1139
- }
1140
- });
1141
- return this.mutationForDialog(response.roleAddGrant);
1142
- }
1143
- async deleteGrant(grantId) {
1144
- const response = await this.client.mutation({
1145
- __name: 'DeleteGrant',
1146
- roleDeleteGrant: {
1147
- __args: { grantId },
1148
- success: true,
1149
- messages: {
1150
- message: true,
1151
- type: true,
1152
- arg: true
1153
- }
1154
- }
1155
- });
1156
- return this.mutationForDialog(response.roleDeleteGrant);
1157
- }
1158
- }
1159
- export const api = new API(PUBLIC_API_BASE, PUBLIC_AUTH_REDIRECT);
1
+ export {};