From 7b48b46b56644142fdb38b7d4c35745962679902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20J=C3=A4ggi?= Date: Sat, 16 Dec 2023 07:29:40 +0100 Subject: [PATCH] fix: type def / jsdoc --- .../src/index.d.ts | 30 +++++++++++++++++-- .../src/models/site/audit-config.js | 6 ++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/spacecat-shared-data-access/src/index.d.ts b/packages/spacecat-shared-data-access/src/index.d.ts index 7c5741db9..70a15bf5f 100644 --- a/packages/spacecat-shared-data-access/src/index.d.ts +++ b/packages/spacecat-shared-data-access/src/index.d.ts @@ -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 { diff --git a/packages/spacecat-shared-data-access/src/models/site/audit-config.js b/packages/spacecat-shared-data-access/src/models/site/audit-config.js index ded497bb5..9ebd60156 100644 --- a/packages/spacecat-shared-data-access/src/models/site/audit-config.js +++ b/packages/spacecat-shared-data-access/src/models/site/audit-config.js @@ -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);