Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions packages/spacecat-shared-data-access/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,39 @@ export interface Audit {
getScores: () => object;
}

// AuditConfigType defines the structure for specific audit type configurations
/**
* AuditConfigType defines the structure for specific audit type configurations
*/
export interface AuditConfigType {
/**
* Returns true if the audit type is disabled for the site. If an audit type is disabled, no
* audits of that type will be scheduled for the site.
* @returns True if the audit type is disabled for the site
*/
disabled(): boolean;
}

// AuditConfig defines the structure for the overall audit configuration of a site
/**
* AuditConfig defines the structure for the overall audit configuration of a site
*/
export interface AuditConfig {
/**
* Returns true if audits are disabled for the site. If audits are disabled, no audits will be
* scheduled for the site. Overrides any audit type specific configurations.
* @returns True if audits are disabled for the site
*/
auditsDisabled: () => boolean;
getAuditConfigForType: (auditType: string) => AuditConfigType;
/**
* Returns the audit config for a specific audit type. The audit type is the key.
* @param auditType The audit type to get the config for
* @returns The audit config for the audit type
*/
getAuditTypeConfig: (auditType: string) => AuditConfigType;
/**
* Returns the audit configs for all audit types. The keys are the audit types.
* @returns The audit configs for all audit types
*/
getAuditTypeConfigs: () => object;
}

export interface Site {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
*/
import AuditConfigType from './audit-config-type.js';

/**
* Initializes the audit type configs. If auditsDisabled is true, all audit types will be disabled.
* @param {object} auditTypeConfigs - Object containing audit type configs.
* @param {boolean} auditsDisabled - Flag indicating if all audits are disabled.
* @return {object} Object containing audit type configs.
*/
function getAuditTypeConfigs(auditTypeConfigs, auditsDisabled) {
return Object.entries(auditTypeConfigs || {}).reduce((acc, [key, value]) => {
acc[key] = AuditConfigType(value, auditsDisabled);
Expand Down