@adobe/spacecat-shared-data-access 2.74.2 → 2.75.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.75.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.74.2...@adobe/spacecat-shared-data-access-v2.75.0) (2025-10-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* scrape url access pattern ([#1059](https://github.com/adobe/spacecat-shared/issues/1059)) ([26facf6](https://github.com/adobe/spacecat-shared/commit/26facf63dfae4908ed88221f16266910205e2473))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-data-access-v2.74.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.74.1...@adobe/spacecat-shared-data-access-v2.74.2) (2025-10-28)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -67,6 +67,7 @@ class Audit extends BaseModel {
|
|
|
67
67
|
READABILITY: 'readability',
|
|
68
68
|
PRERENDER: 'prerender',
|
|
69
69
|
PRODUCT_METATAGS: 'product-metatags',
|
|
70
|
+
PRODUCT_METATAGS_AUTO_SUGGEST: 'product-metatags-auto-suggest',
|
|
70
71
|
SUMMARIZATION: 'summarization',
|
|
71
72
|
PAGE_TYPE_DETECTION: 'page-type-detection',
|
|
72
73
|
FAQS: 'faqs',
|
|
@@ -20,6 +20,7 @@ export interface ScrapeUrl extends BaseModel {
|
|
|
20
20
|
getReason(): string,
|
|
21
21
|
getStatus(): string,
|
|
22
22
|
getUrl(): string,
|
|
23
|
+
getProcessingType(): string,
|
|
23
24
|
getIsOriginal(): boolean,
|
|
24
25
|
setFile(file: string): void,
|
|
25
26
|
setScrapeJobId(ScrapeJobId: string): void,
|
|
@@ -27,12 +28,15 @@ export interface ScrapeUrl extends BaseModel {
|
|
|
27
28
|
setReason(reason: string): void,
|
|
28
29
|
setStatus(status: string): void,
|
|
29
30
|
setUrl(url: string): void,
|
|
31
|
+
setProcessingType(processingType: string): void,
|
|
30
32
|
setIsOriginal(isOriginal: boolean): void,
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export interface ScrapeUrlCollection extends BaseCollection<ScrapeUrl> {
|
|
34
36
|
allByScrapeJobId(ScrapeJobId: string): Promise<ScrapeUrl[]>;
|
|
35
37
|
allByScrapeUrlsByJobIdAndStatus(ScrapeJobId: string, status: string): Promise<ScrapeUrl[]>;
|
|
38
|
+
allByUrlAndIsOriginalAndProcessingType(url: string, isOriginal: boolean, processingType: string): Promise<ScrapeUrl[]>;
|
|
39
|
+
allRecentByUrlAndProcessingType(url: string, processingType: string, maxAgeInHours?: number): Promise<ScrapeUrl[]>;
|
|
36
40
|
findByScrapeJobId(ScrapeJobId: string): Promise<ScrapeUrl | null>;
|
|
37
41
|
findByScrapeJobIdAndUrl(ScrapeJobId: string, url: string): Promise<ScrapeUrl | null>;
|
|
38
42
|
}
|
|
@@ -20,7 +20,20 @@ import BaseCollection from '../base/base.collection.js';
|
|
|
20
20
|
* @extends BaseCollection
|
|
21
21
|
*/
|
|
22
22
|
class ScrapeUrlCollection extends BaseCollection {
|
|
23
|
-
|
|
23
|
+
async allRecentByUrlAndProcessingType(url, processingType, maxAgeInHours = 168) {
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const pastDate = new Date(now.getTime() - maxAgeInHours * 60 * 60 * 1000);
|
|
26
|
+
const pastDateIso = pastDate.toISOString();
|
|
27
|
+
const nowIso = now.toISOString();
|
|
28
|
+
|
|
29
|
+
return this.allByIndexKeys({ url, isOriginal: true, processingType }, {
|
|
30
|
+
between: {
|
|
31
|
+
attribute: 'createdAt',
|
|
32
|
+
start: pastDateIso,
|
|
33
|
+
end: nowIso,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
export default ScrapeUrlCollection;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/* c8 ignore start */
|
|
14
14
|
|
|
15
|
-
import { isValidUrl } from '@adobe/spacecat-shared-utils';
|
|
15
|
+
import { isObject, isString, isValidUrl } from '@adobe/spacecat-shared-utils';
|
|
16
16
|
|
|
17
17
|
import SchemaBuilder from '../base/schema.builder.js';
|
|
18
18
|
import ScrapeUrl from './scrape-url.model.js';
|
|
@@ -46,9 +46,22 @@ const schema = new SchemaBuilder(ScrapeUrl, ScrapeUrlCollection)
|
|
|
46
46
|
required: true,
|
|
47
47
|
validate: (value) => isValidUrl(value),
|
|
48
48
|
})
|
|
49
|
+
.addAttribute('processingType', {
|
|
50
|
+
type: 'string',
|
|
51
|
+
required: true,
|
|
52
|
+
validate: (value) => isString(value),
|
|
53
|
+
})
|
|
54
|
+
.addAttribute('options', {
|
|
55
|
+
type: 'any',
|
|
56
|
+
validate: (value) => !value || isObject(value),
|
|
57
|
+
})
|
|
49
58
|
.addAttribute('isOriginal', {
|
|
50
59
|
type: 'boolean',
|
|
51
60
|
default: true,
|
|
52
|
-
})
|
|
61
|
+
})
|
|
62
|
+
.addIndex(
|
|
63
|
+
{ composite: ['url'] },
|
|
64
|
+
{ composite: ['isOriginal', 'processingType', 'createdAt'] },
|
|
65
|
+
);
|
|
53
66
|
|
|
54
67
|
export default schema.build();
|