@adobe/spacecat-shared-data-access 3.72.1 → 3.73.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,9 @@
1
+ ## [@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)
2
+
3
+ ### Features
4
+
5
+ * **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))
6
+
1
7
  ## [@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
8
 
3
9
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.72.1",
3
+ "version": "3.73.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -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, semrushLocationId, language) slice, or
26
- * null. Used by spacecat-api-service POST /v2/orgs/.../semrush/projects to
27
- * 409 on a duplicate slice before calling Semrush.
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} semrushLocationId
31
- * @param {string} language
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, semrushLocationId, language) {
35
- return this.findByIndexKeys({ brandId, semrushLocationId, language });
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 a Semrush AIO
17
- * project. One row per (brand, semrushLocationId, language) slice. The Semrush
18
- * workspace is reachable via brand -> organization.getSemrushWorkspaceId() and
19
- * is not duplicated on this entity.
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
- // Semrush project. Accepts BCP-47-shaped tags: 2/3-letter primary subtag
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
- .addAttribute('semrushLocationId', {
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
- .addAttribute('language', {
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
- getSemrushLocationId(): number;
26
- getLanguage(): string;
25
+ getGeoTargetId(): number;
26
+ getLanguageCode(): string;
27
27
  setSemrushProjectId(value: string): BrandSemrushProject;
28
- setSemrushLocationId(value: number): BrandSemrushProject;
29
- setLanguage(value: string): BrandSemrushProject;
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
- semrushLocationId: number,
41
- language: string,
40
+ geoTargetId: number,
41
+ languageCode: string,
42
42
  ): Promise<BrandSemrushProject | null>;
43
43
  }