@adobe/spacecat-shared-data-access 2.65.2 → 2.66.0
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.66.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.65.2...@adobe/spacecat-shared-data-access-v2.66.0) (2025-10-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add configuration methods to register audits ([#1000](https://github.com/adobe/spacecat-shared/issues/1000)) ([f58670e](https://github.com/adobe/spacecat-shared/commit/f58670e5b3561bef09911102cc947fa6ba2a4955))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-data-access-v2.65.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.65.1...@adobe/spacecat-shared-data-access-v2.65.2) (2025-10-01)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ import { isNonEmptyObject, isNonEmptyArray } from '@adobe/spacecat-shared-utils'
|
|
|
14
14
|
|
|
15
15
|
import { sanitizeIdAndAuditFields } from '../../util/util.js';
|
|
16
16
|
import BaseModel from '../base/base.model.js';
|
|
17
|
+
import { Audit } from '../audit/index.js';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Configuration - A class representing an Configuration entity.
|
|
@@ -248,6 +249,70 @@ class Configuration extends BaseModel {
|
|
|
248
249
|
this.updateHandlerOrgs(type, orgId, false);
|
|
249
250
|
}
|
|
250
251
|
|
|
252
|
+
registerAudit(type, enabledByDefault = false, interval = Configuration.JOB_INTERVALS.NEVER) {
|
|
253
|
+
// Validate audit type
|
|
254
|
+
if (!Object.values(Audit.AUDIT_TYPES).includes(type)) {
|
|
255
|
+
throw new Error(`Audit type ${type} is not a valid audit type in the data model`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Validate job interval
|
|
259
|
+
if (!Object.values(Configuration.JOB_INTERVALS).includes(interval)) {
|
|
260
|
+
throw new Error(`Invalid interval ${interval}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Add to handlers if not already registered
|
|
264
|
+
const handlers = this.getHandlers();
|
|
265
|
+
if (!handlers[type]) {
|
|
266
|
+
handlers[type] = {
|
|
267
|
+
enabledByDefault,
|
|
268
|
+
enabled: {
|
|
269
|
+
sites: [],
|
|
270
|
+
orgs: [],
|
|
271
|
+
},
|
|
272
|
+
disabled: {
|
|
273
|
+
sites: [],
|
|
274
|
+
orgs: [],
|
|
275
|
+
},
|
|
276
|
+
dependencies: [],
|
|
277
|
+
};
|
|
278
|
+
this.setHandlers(handlers);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Add to jobs if not already registered
|
|
282
|
+
const jobs = this.getJobs();
|
|
283
|
+
const exists = jobs.find((job) => job.group === 'audits' && job.type === type);
|
|
284
|
+
if (!exists) {
|
|
285
|
+
jobs.push({
|
|
286
|
+
group: 'audits',
|
|
287
|
+
type,
|
|
288
|
+
interval,
|
|
289
|
+
});
|
|
290
|
+
this.setJobs(jobs);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
unregisterAudit(type) {
|
|
295
|
+
// Validate audit type
|
|
296
|
+
if (!Object.values(Audit.AUDIT_TYPES).includes(type)) {
|
|
297
|
+
throw new Error(`Audit type ${type} is not a valid audit type in the data model`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Remove from handlers
|
|
301
|
+
const handlers = this.getHandlers();
|
|
302
|
+
if (handlers[type]) {
|
|
303
|
+
delete handlers[type];
|
|
304
|
+
this.setHandlers(handlers);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Remove from jobs
|
|
308
|
+
const jobs = this.getJobs();
|
|
309
|
+
const jobIndex = jobs.findIndex((job) => job.group === 'audits' && job.type === type);
|
|
310
|
+
if (jobIndex !== -1) {
|
|
311
|
+
jobs.splice(jobIndex, 1);
|
|
312
|
+
this.setJobs(jobs);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
251
316
|
async save() {
|
|
252
317
|
return this.collection.create(sanitizeIdAndAuditFields(this.constructor.name, this.toJSON()));
|
|
253
318
|
}
|
|
@@ -39,6 +39,8 @@ export interface Configuration extends BaseModel {
|
|
|
39
39
|
setSlackRoles(slackRoles: object): void;
|
|
40
40
|
updateHandlerOrgs(type: string, orgId: string, enabled: boolean): void;
|
|
41
41
|
updateHandlerSites(type: string, siteId: string, enabled: boolean): void;
|
|
42
|
+
registerAudit(type: string, enabledByDefault?: boolean, interval?: string): void;
|
|
43
|
+
unregisterAudit(type: string): void;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export interface ConfigurationCollection extends BaseCollection<Configuration> {
|