@adobe/spacecat-shared-data-access 3.72.1 → 3.73.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 +12 -0
- package/package.json +1 -1
- package/src/models/brand-semrush-project/brand-semrush-project.collection.js +7 -7
- package/src/models/brand-semrush-project/brand-semrush-project.model.js +6 -4
- package/src/models/brand-semrush-project/brand-semrush-project.schema.js +16 -3
- package/src/models/brand-semrush-project/index.d.ts +6 -6
- package/src/models/preflight/preflight.schema.js +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [@adobe/spacecat-shared-data-access-v3.73.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.73.0...@adobe/spacecat-shared-data-access-v3.73.1) (2026-05-28)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **data-access:** declare Preflight createdBy/error as 'any' so Service construction succeeds ([#1636](https://github.com/adobe/spacecat-shared/issues/1636)) ([4097963](https://github.com/adobe/spacecat-shared/commit/40979638bc65c6e29a1b9cd7b25608ad376161ed)), closes [adobe/spacecat-shared#1601](https://github.com/adobe/spacecat-shared/issues/1601)
|
|
6
|
+
|
|
7
|
+
## [@adobe/spacecat-shared-data-access-v3.73.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.72.1...@adobe/spacecat-shared-data-access-v3.73.0) (2026-05-28)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **data-access:** rename BrandSemrushProject accessors (LLMO-5190) ([#1635](https://github.com/adobe/spacecat-shared/issues/1635)) ([f97b09d](https://github.com/adobe/spacecat-shared/commit/f97b09df6f15323baa74ede7aa1f431ba7d68293))
|
|
12
|
+
|
|
1
13
|
## [@adobe/spacecat-shared-data-access-v3.72.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.72.0...@adobe/spacecat-shared-data-access-v3.72.1) (2026-05-28)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -22,17 +22,17 @@ class BrandSemrushProjectCollection extends BaseCollection {
|
|
|
22
22
|
static COLLECTION_NAME = 'BrandSemrushProjectCollection';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Find the single row for a (brand,
|
|
26
|
-
* null. Used by spacecat-api-service POST /v2/orgs/.../
|
|
27
|
-
* 409 on a duplicate slice before calling
|
|
25
|
+
* Find the single row for a (brand, geoTargetId, languageCode) slice, or
|
|
26
|
+
* null. Used by spacecat-api-service POST /v2/orgs/.../serenity/markets to
|
|
27
|
+
* 409 on a duplicate slice before calling the upstream.
|
|
28
28
|
*
|
|
29
29
|
* @param {string} brandId
|
|
30
|
-
* @param {number}
|
|
31
|
-
* @param {string}
|
|
30
|
+
* @param {number} geoTargetId Google Ads Geo Target ID.
|
|
31
|
+
* @param {string} languageCode BCP-47 primary subtag.
|
|
32
32
|
* @returns {Promise<BrandSemrushProject|null>}
|
|
33
33
|
*/
|
|
34
|
-
async findBySlice(brandId,
|
|
35
|
-
return this.findByIndexKeys({ brandId,
|
|
34
|
+
async findBySlice(brandId, geoTargetId, languageCode) {
|
|
35
|
+
return this.findByIndexKeys({ brandId, geoTargetId, languageCode });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
import BaseModel from '../base/base.model.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* BrandSemrushProject - mapping between an Adobe brand and
|
|
17
|
-
* project. One row per (brand,
|
|
18
|
-
* workspace is reachable via
|
|
19
|
-
* is not duplicated on this
|
|
16
|
+
* BrandSemrushProject - mapping between an Adobe brand and an upstream
|
|
17
|
+
* Semrush AIO project. One row per (brand, geoTargetId, languageCode) slice.
|
|
18
|
+
* The Semrush workspace is reachable via
|
|
19
|
+
* brand -> organization.getSemrushWorkspaceId() and is not duplicated on this
|
|
20
|
+
* entity. Entity + table names retain the `Semrush` prefix as internal
|
|
21
|
+
* storage identifiers; the public JS accessors do not.
|
|
20
22
|
*
|
|
21
23
|
* @class BrandSemrushProject
|
|
22
24
|
* @extends BaseModel
|
|
@@ -16,11 +16,16 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
16
16
|
import BrandSemrushProject from './brand-semrush-project.model.js';
|
|
17
17
|
import BrandSemrushProjectCollection from './brand-semrush-project.collection.js';
|
|
18
18
|
|
|
19
|
+
// "upstream" in the comments below refers to Semrush AIO — the entity name,
|
|
20
|
+
// table name, and `semrushProjectId` accessor stay because the value IS the
|
|
21
|
+
// upstream identifier. The public API surface decouples via the LLMO-5190
|
|
22
|
+
// rename plan (see the schema attributes' `postgrestField` overrides).
|
|
23
|
+
|
|
19
24
|
// Mirrors the CHECK constraint on brand_to_semrush_projects.language
|
|
20
25
|
// (db/migrations/20260528000000_brand_to_semrush_projects.sql). The slice
|
|
21
26
|
// uniqueness gate is an exact DB string match, so inconsistent casing or
|
|
22
27
|
// format between callers would silently bypass the 409 and bill a duplicate
|
|
23
|
-
//
|
|
28
|
+
// upstream project. Accepts BCP-47-shaped tags: 2/3-letter primary subtag
|
|
24
29
|
// (`en`, `de`, `zho`) optionally followed by a 2-4-letter region/script
|
|
25
30
|
// subtag (`de-ch`, `pt-br`, `zh-hant`). All lowercase by contract.
|
|
26
31
|
const LANGUAGE_TAG_REGEX = /^[a-z]{2,3}(-[a-z]{2,4})?$/;
|
|
@@ -45,15 +50,23 @@ const schema = new SchemaBuilder(BrandSemrushProject, BrandSemrushProjectCollect
|
|
|
45
50
|
required: true,
|
|
46
51
|
validate: (value) => hasText(value),
|
|
47
52
|
})
|
|
48
|
-
|
|
53
|
+
// Google Ads Geo Target ID (criterion_id for the country). Semrush re-uses
|
|
54
|
+
// it as their location identifier; the value is owned by Google Ads, not
|
|
55
|
+
// Semrush. DB column stays `semrush_location_id` — the table layout is
|
|
56
|
+
// subject to change independently (see LLMO-5190 plan §Context).
|
|
57
|
+
.addAttribute('geoTargetId', {
|
|
49
58
|
type: 'number',
|
|
50
59
|
required: true,
|
|
51
60
|
validate: (value) => Number.isInteger(value) && value > 0,
|
|
61
|
+
postgrestField: 'semrush_location_id',
|
|
52
62
|
})
|
|
53
|
-
|
|
63
|
+
// BCP-47 primary subtag (`en`, `de`, `fr`), optionally with a region/script
|
|
64
|
+
// subtag (`de-ch`, `pt-br`, `zh-hant`). DB column stays `language`.
|
|
65
|
+
.addAttribute('languageCode', {
|
|
54
66
|
type: 'string',
|
|
55
67
|
required: true,
|
|
56
68
|
validate: (value) => hasText(value) && LANGUAGE_TAG_REGEX.test(value),
|
|
69
|
+
postgrestField: 'language',
|
|
57
70
|
})
|
|
58
71
|
.addAllIndex(['semrushProjectId']);
|
|
59
72
|
|
|
@@ -22,11 +22,11 @@ import type {
|
|
|
22
22
|
export interface BrandSemrushProject extends BaseModel {
|
|
23
23
|
getBrandId(): string;
|
|
24
24
|
getSemrushProjectId(): string;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
getGeoTargetId(): number;
|
|
26
|
+
getLanguageCode(): string;
|
|
27
27
|
setSemrushProjectId(value: string): BrandSemrushProject;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
setGeoTargetId(value: number): BrandSemrushProject;
|
|
29
|
+
setLanguageCode(value: string): BrandSemrushProject;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface BrandSemrushProjectCollection extends
|
|
@@ -37,7 +37,7 @@ export interface BrandSemrushProjectCollection extends
|
|
|
37
37
|
findBySemrushProjectId(semrushProjectId: string): Promise<BrandSemrushProject | null>;
|
|
38
38
|
findBySlice(
|
|
39
39
|
brandId: string,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
geoTargetId: number,
|
|
41
|
+
languageCode: string,
|
|
42
42
|
): Promise<BrandSemrushProject | null>;
|
|
43
43
|
}
|
|
@@ -30,8 +30,16 @@ const schema = new SchemaBuilder(Preflight, PreflightCollection)
|
|
|
30
30
|
required: true,
|
|
31
31
|
default: Preflight.Status.IN_PROGRESS,
|
|
32
32
|
})
|
|
33
|
+
// `createdBy` and `error` use type 'any' (matching neighbor `result`) because
|
|
34
|
+
// ElectroDB's `map` type requires a `properties` schema for every sub-key,
|
|
35
|
+
// and the validate function below already enforces the precise shape — a
|
|
36
|
+
// duplicate `properties` declaration adds nothing. Declaring `type: 'map'`
|
|
37
|
+
// here without `properties` was the original definition and throws
|
|
38
|
+
// `InvalidAttributeDefinition` at Service construction, blocking any
|
|
39
|
+
// downstream consumer that builds a v1 `new Service(EntityRegistry.getEntities())`
|
|
40
|
+
// (e.g. spacecat-api-service `fixes.test.js`).
|
|
33
41
|
.addAttribute('createdBy', {
|
|
34
|
-
type: '
|
|
42
|
+
type: 'any',
|
|
35
43
|
required: true,
|
|
36
44
|
validate: (value) => isObject(value) && typeof value.email === 'string' && value.email.length > 0,
|
|
37
45
|
})
|
|
@@ -48,7 +56,7 @@ const schema = new SchemaBuilder(Preflight, PreflightCollection)
|
|
|
48
56
|
validate: (value) => !value || isObject(value),
|
|
49
57
|
})
|
|
50
58
|
.addAttribute('error', {
|
|
51
|
-
type: '
|
|
59
|
+
type: 'any',
|
|
52
60
|
validate: (value) => !value || (isObject(value) && typeof value.code === 'string' && value.code.length > 0 && typeof value.message === 'string' && value.message.length > 0),
|
|
53
61
|
});
|
|
54
62
|
|