@adobe/spacecat-shared-data-access 2.6.0 → 2.7.1
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,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.7.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.7.0...@adobe/spacecat-shared-data-access-v2.7.1) (2025-02-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* get queue url ([#612](https://github.com/adobe/spacecat-shared/issues/612)) ([232af0a](https://github.com/adobe/spacecat-shared/commit/232af0af829289214826275f81504ce6bdae5467))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v2.7.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.6.0...@adobe/spacecat-shared-data-access-v2.7.0) (2025-02-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Implement dependency check for handlers ([#608](https://github.com/adobe/spacecat-shared/issues/608)) ([0ada515](https://github.com/adobe/spacecat-shared/commit/0ada5157a3cf50bf67129e296e719a14ee2c451c)), closes [/github.com/adobe/spacecat-shared/blob/main/packages/spacecat-shared-data-access/src/models/configuration/configuration.schema.js#L35-L39](https://github.com//github.com/adobe/spacecat-shared/blob/main/packages/spacecat-shared-data-access/src/models/configuration/configuration.schema.js/issues/L35-L39)
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v2.6.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.5.0...@adobe/spacecat-shared-data-access-v2.6.0) (2025-02-18)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -71,13 +71,19 @@ class Audit extends BaseModel {
|
|
|
71
71
|
* The configurations for the audit step destinations. Used with AuditBuilder to configure
|
|
72
72
|
* the destination queue URL and payload formatting.
|
|
73
73
|
* @type {{
|
|
74
|
-
* [Audit.AUDIT_STEP_DESTINATIONS.CONTENT_SCRAPER]: {
|
|
75
|
-
*
|
|
74
|
+
* [Audit.AUDIT_STEP_DESTINATIONS.CONTENT_SCRAPER]: {
|
|
75
|
+
* getQueueUrl: function,
|
|
76
|
+
* formatPayload: function
|
|
77
|
+
* },
|
|
78
|
+
* [Audit.AUDIT_STEP_DESTINATIONS.IMPORT_WORKER]: {
|
|
79
|
+
* getQueueUrl: function,
|
|
80
|
+
* formatPayload: function
|
|
81
|
+
* }
|
|
76
82
|
* }}
|
|
77
83
|
*/
|
|
78
84
|
static AUDIT_STEP_DESTINATION_CONFIGS = {
|
|
79
85
|
[Audit.AUDIT_STEP_DESTINATIONS.IMPORT_WORKER]: {
|
|
80
|
-
|
|
86
|
+
getQueueUrl: (context) => context.env?.IMPORT_WORKER_QUEUE_URL,
|
|
81
87
|
/**
|
|
82
88
|
* Formats the payload for the import worker queue.
|
|
83
89
|
* @param {object} stepResult - The result of the audit step.
|
|
@@ -100,7 +106,7 @@ class Audit extends BaseModel {
|
|
|
100
106
|
}),
|
|
101
107
|
},
|
|
102
108
|
[Audit.AUDIT_STEP_DESTINATIONS.CONTENT_SCRAPER]: {
|
|
103
|
-
|
|
109
|
+
getQueueUrl: (context) => context.env?.CONTENT_SCRAPER_QUEUE_URL,
|
|
104
110
|
/**
|
|
105
111
|
* Formats the payload for the content scraper queue.
|
|
106
112
|
* @param {object} stepResult - The result of the audit step.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { isNonEmptyObject } from '@adobe/spacecat-shared-utils';
|
|
13
|
+
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';
|
|
@@ -146,12 +146,58 @@ class Configuration extends BaseModel {
|
|
|
146
146
|
const siteId = site.getId();
|
|
147
147
|
if (this.isHandlerEnabledForSite(type, site)) return;
|
|
148
148
|
|
|
149
|
+
const deps = this.isHandlerDependencyMetForSite(type, site);
|
|
150
|
+
if (deps !== true) {
|
|
151
|
+
throw new Error(`Cannot enable handler ${type} for site ${siteId} because of missing dependencies: ${deps}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
149
154
|
this.updateHandlerSites(type, siteId, true);
|
|
150
155
|
}
|
|
151
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Check if all dependencies for a handler of given type are met for the given org.
|
|
159
|
+
*
|
|
160
|
+
* @param {string} type handler type
|
|
161
|
+
* @param {object} org org object
|
|
162
|
+
* @returns true if all dependencies are met, array with missing dependencies otherwise
|
|
163
|
+
*/
|
|
164
|
+
isHandlerDependencyMetForOrg(type, org) {
|
|
165
|
+
const handler = this.getHandler(type);
|
|
166
|
+
|
|
167
|
+
if (!handler || !isNonEmptyArray(handler?.dependencies)) return true;
|
|
168
|
+
|
|
169
|
+
const unmetDependencies = handler.dependencies
|
|
170
|
+
.filter(({ handler: depHandler }) => !this.isHandlerEnabledForOrg(depHandler, org))
|
|
171
|
+
.map(({ handler: depHandler }) => depHandler);
|
|
172
|
+
|
|
173
|
+
return isNonEmptyArray(unmetDependencies) ? unmetDependencies : true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if all dependencies for a handler of given type are met for the given site.
|
|
178
|
+
*
|
|
179
|
+
* @param {string} type handler type
|
|
180
|
+
* @param {object} site site object
|
|
181
|
+
* @returns true if all dependencies are met, array with missing dependencies otherwise
|
|
182
|
+
*/
|
|
183
|
+
isHandlerDependencyMetForSite(type, site) {
|
|
184
|
+
const handler = this.getHandler(type);
|
|
185
|
+
if (!handler || !isNonEmptyArray(handler?.dependencies)) return true;
|
|
186
|
+
|
|
187
|
+
const unmetDependencies = handler.dependencies
|
|
188
|
+
.filter(({ handler: depHandler }) => !this.isHandlerEnabledForSite(depHandler, site))
|
|
189
|
+
.map(({ handler: depHandler }) => depHandler);
|
|
190
|
+
|
|
191
|
+
return isNonEmptyArray(unmetDependencies) ? unmetDependencies : true;
|
|
192
|
+
}
|
|
193
|
+
|
|
152
194
|
enableHandlerForOrg(type, org) {
|
|
153
195
|
const orgId = org.getId();
|
|
154
196
|
if (this.isHandlerEnabledForOrg(type, org)) return;
|
|
197
|
+
const deps = this.isHandlerDependencyMetForOrg(type, org);
|
|
198
|
+
if (deps !== true) {
|
|
199
|
+
throw new Error(`Cannot enable handler ${type} for org ${orgId} because of missing dependencies: ${deps}`);
|
|
200
|
+
}
|
|
155
201
|
|
|
156
202
|
this.updateHandlerOrgs(type, orgId, true);
|
|
157
203
|
}
|