-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b15c31b
commit 1279b04
Showing
12 changed files
with
1,195 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file renamed
BIN
+349 KB
...ypes-npm-4.93.0-18808935f7-dda3743a4b.zip → ...ypes-npm-4.94.0-c5ce6b7558-8cc1a8dd54.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { ASSESSMENT_TEMPLATES } from './gqls'; | ||
import { makeGraphQLRequest } from './makeGraphQLRequest'; | ||
import type { | ||
AssessmentSection, | ||
RetentionSchedule, | ||
UserPreview, | ||
} from './fetchAllAssessments'; | ||
import { | ||
AssessmentFormTemplateSource, | ||
AssessmentFormTemplateStatus, | ||
} from '@transcend-io/privacy-types'; | ||
|
||
/** | ||
* Represents an assessment template with various properties and metadata. | ||
*/ | ||
export interface AssessmentTemplate { | ||
/** The ID of the assessment template */ | ||
id: string; | ||
/** The user who created the assessment template */ | ||
creator: UserPreview; | ||
/** The user who last edited the assessment template */ | ||
lastEditor: UserPreview; | ||
/** The title of the assessment template */ | ||
title: string; | ||
/** The description of the assessment template */ | ||
description: string; | ||
/** The current status of the assessment template */ | ||
status: AssessmentFormTemplateStatus; | ||
/** The source fo the form template */ | ||
source: AssessmentFormTemplateSource; | ||
/** ID of parent template */ | ||
parentId: string; | ||
/** Indicates if the assessment template is locked */ | ||
isLocked: boolean; | ||
/** Indicates if the assessment template is archived */ | ||
isArchived: boolean; | ||
/** The date when the assessment template was created */ | ||
createdAt: string; | ||
/** The date when the assessment template was last updated */ | ||
updatedAt: string; | ||
/** The retention schedule of the assessment template */ | ||
retentionSchedule: RetentionSchedule; | ||
/** The sections of the assessment template */ | ||
sections: AssessmentSection[]; | ||
} | ||
|
||
const PAGE_SIZE = 20; | ||
|
||
/** | ||
* Fetch all assessment templates in the organization | ||
* | ||
* @param client - GraphQL client | ||
* @returns All assessment templates in the organization | ||
*/ | ||
export async function fetchAllAssessmentTemplates( | ||
client: GraphQLClient, | ||
): Promise<AssessmentTemplate[]> { | ||
const assessmentTemplates: AssessmentTemplate[] = []; | ||
let offset = 0; | ||
|
||
let shouldContinue = false; | ||
do { | ||
const { | ||
assessmentFormTemplates: { nodes }, | ||
// eslint-disable-next-line no-await-in-loop | ||
} = await makeGraphQLRequest<{ | ||
/** Templates */ | ||
assessmentFormTemplates: { | ||
/** Nodes */ | ||
nodes: AssessmentTemplate[]; | ||
}; | ||
}>(client, ASSESSMENT_TEMPLATES, { | ||
first: PAGE_SIZE, | ||
offset, | ||
}); | ||
assessmentTemplates.push(...nodes); | ||
offset += PAGE_SIZE; | ||
shouldContinue = nodes.length === PAGE_SIZE; | ||
} while (shouldContinue); | ||
|
||
return assessmentTemplates.sort((a, b) => a.title.localeCompare(b.title)); | ||
} |
Oops, something went wrong.