@adobe/spacecat-shared-data-access 3.66.0 → 3.68.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,15 @@
1
+ ## [@adobe/spacecat-shared-data-access-v3.68.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.67.0...@adobe/spacecat-shared-data-access-v3.68.0) (2026-05-21)
2
+
3
+ ### Features
4
+
5
+ * added pending decision in PLG onboarding ([#1610](https://github.com/adobe/spacecat-shared/issues/1610)) ([cf8a1c4](https://github.com/adobe/spacecat-shared/commit/cf8a1c4cc4f43e5d0c792adc69e7593162257f77))
6
+
7
+ ## [@adobe/spacecat-shared-data-access-v3.67.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.66.0...@adobe/spacecat-shared-data-access-v3.67.0) (2026-05-21)
8
+
9
+ ### Features
10
+
11
+ * **data-access:** add BrandSemrushProject entity ([#1615](https://github.com/adobe/spacecat-shared/issues/1615)) ([f2c6a0c](https://github.com/adobe/spacecat-shared/commit/f2c6a0c678f000da9900d135effa37ad17e08e8f))
12
+
1
13
  ## [@adobe/spacecat-shared-data-access-v3.66.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.65.0...@adobe/spacecat-shared-data-access-v3.66.0) (2026-05-21)
2
14
 
3
15
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.66.0",
3
+ "version": "3.68.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,6 +35,7 @@ import ProjectCollection from '../project/project.collection.js';
35
35
  import ScrapeJobCollection from '../scrape-job/scrape-job.collection.js';
36
36
  import ScrapeUrlCollection from '../scrape-url/scrape-url.collection.js';
37
37
  import SiteCandidateCollection from '../site-candidate/site-candidate.collection.js';
38
+ import BrandSemrushProjectCollection from '../brand-semrush-project/brand-semrush-project.collection.js';
38
39
  import SiteCollection from '../site/site.collection.js';
39
40
  import SiteEnrollmentCollection from '../site-enrollment/site-enrollment.collection.js';
40
41
  import SiteTopFormCollection from '../site-top-form/site-top-form.collection.js';
@@ -73,6 +74,7 @@ import OrganizationSchema from '../organization/organization.schema.js';
73
74
  import ProjectSchema from '../project/project.schema.js';
74
75
  import ScrapeJobSchema from '../scrape-job/scrape-job.schema.js';
75
76
  import ScrapeUrlSchema from '../scrape-url/scrape-url.schema.js';
77
+ import BrandSemrushProjectSchema from '../brand-semrush-project/brand-semrush-project.schema.js';
76
78
  import SiteSchema from '../site/site.schema.js';
77
79
  import SiteCandidateSchema from '../site-candidate/site-candidate.schema.js';
78
80
  import SiteEnrollmentSchema from '../site-enrollment/site-enrollment.schema.js';
@@ -207,6 +209,7 @@ EntityRegistry.registerEntity(OrganizationSchema, OrganizationCollection);
207
209
  EntityRegistry.registerEntity(ProjectSchema, ProjectCollection);
208
210
  EntityRegistry.registerEntity(ScrapeJobSchema, ScrapeJobCollection);
209
211
  EntityRegistry.registerEntity(ScrapeUrlSchema, ScrapeUrlCollection);
212
+ EntityRegistry.registerEntity(BrandSemrushProjectSchema, BrandSemrushProjectCollection);
210
213
  EntityRegistry.registerEntity(SiteSchema, SiteCollection);
211
214
  EntityRegistry.registerEntity(SiteCandidateSchema, SiteCandidateCollection);
212
215
  EntityRegistry.registerEntity(SiteEnrollmentSchema, SiteEnrollmentCollection);
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import BaseCollection from '../base/base.collection.js';
14
+
15
+ /**
16
+ * BrandSemrushProjectCollection - collection of BrandSemrushProject rows.
17
+ *
18
+ * @class BrandSemrushProjectCollection
19
+ * @extends BaseCollection
20
+ */
21
+ class BrandSemrushProjectCollection extends BaseCollection {
22
+ static COLLECTION_NAME = 'BrandSemrushProjectCollection';
23
+
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.
28
+ *
29
+ * @param {string} brandId
30
+ * @param {number} semrushLocationId
31
+ * @param {string} language
32
+ * @returns {Promise<BrandSemrushProject|null>}
33
+ */
34
+ async findBySlice(brandId, semrushLocationId, language) {
35
+ return this.findByIndexKeys({ brandId, semrushLocationId, language });
36
+ }
37
+ }
38
+
39
+ export default BrandSemrushProjectCollection;
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import BaseModel from '../base/base.model.js';
14
+
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.
20
+ *
21
+ * @class BrandSemrushProject
22
+ * @extends BaseModel
23
+ */
24
+ class BrandSemrushProject extends BaseModel {
25
+ static ENTITY_NAME = 'BrandSemrushProject';
26
+ }
27
+
28
+ export default BrandSemrushProject;
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { hasText } from '@adobe/spacecat-shared-utils';
14
+
15
+ import SchemaBuilder from '../base/schema.builder.js';
16
+ import BrandSemrushProject from './brand-semrush-project.model.js';
17
+ import BrandSemrushProjectCollection from './brand-semrush-project.collection.js';
18
+
19
+ // Mirrors the CHECK constraint on brand_to_semrush_projects.language
20
+ // (db/migrations/20260528000000_brand_to_semrush_projects.sql). The slice
21
+ // uniqueness gate is an exact DB string match, so inconsistent casing or
22
+ // 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
24
+ // (`en`, `de`, `zho`) optionally followed by a 2-4-letter region/script
25
+ // subtag (`de-ch`, `pt-br`, `zh-hant`). All lowercase by contract.
26
+ const LANGUAGE_TAG_REGEX = /^[a-z]{2,3}(-[a-z]{2,4})?$/;
27
+
28
+ const schema = new SchemaBuilder(BrandSemrushProject, BrandSemrushProjectCollection)
29
+ // Reference to Brand (many-to-one). The owning organization and Semrush
30
+ // workspace are reachable via Brand -> Organization.
31
+ .addReference('belongs_to', 'Brand')
32
+ .addAttribute('semrushProjectId', {
33
+ type: 'string',
34
+ required: true,
35
+ validate: (value) => hasText(value),
36
+ })
37
+ .addAttribute('semrushLocationId', {
38
+ type: 'number',
39
+ required: true,
40
+ validate: (value) => Number.isInteger(value) && value > 0,
41
+ })
42
+ .addAttribute('language', {
43
+ type: 'string',
44
+ required: true,
45
+ validate: (value) => hasText(value) && LANGUAGE_TAG_REGEX.test(value),
46
+ })
47
+ .addAllIndex(['semrushProjectId']);
48
+
49
+ export default schema.build();
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import type {
14
+ BaseCollection, BaseModel,
15
+ } from '../index';
16
+
17
+ // NOTE: `belongs_to Brand` on the schema generates `brandId` plus a
18
+ // `getBrand()` runtime accessor, but Brand is not a registered entity in this
19
+ // package (brand data lives in mysticat-data-service and is fetched over HTTP
20
+ // via @adobe/spacecat-shared-brand-client). The accessor is intentionally not
21
+ // exposed on the TypeScript surface — callers must hop to brand-client.
22
+ export interface BrandSemrushProject extends BaseModel {
23
+ getBrandId(): string;
24
+ getSemrushProjectId(): string;
25
+ getSemrushLocationId(): number;
26
+ getLanguage(): string;
27
+ setSemrushProjectId(value: string): BrandSemrushProject;
28
+ setSemrushLocationId(value: number): BrandSemrushProject;
29
+ setLanguage(value: string): BrandSemrushProject;
30
+ }
31
+
32
+ export interface BrandSemrushProjectCollection extends
33
+ BaseCollection<BrandSemrushProject> {
34
+ allByBrandId(brandId: string): Promise<BrandSemrushProject[]>;
35
+ findByBrandId(brandId: string): Promise<BrandSemrushProject | null>;
36
+ allBySemrushProjectId(semrushProjectId: string): Promise<BrandSemrushProject[]>;
37
+ findBySemrushProjectId(semrushProjectId: string): Promise<BrandSemrushProject | null>;
38
+ findBySlice(
39
+ brandId: string,
40
+ semrushLocationId: number,
41
+ language: string,
42
+ ): Promise<BrandSemrushProject | null>;
43
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ export { default as BrandSemrushProject } from './brand-semrush-project.model.js';
14
+ export { default as BrandSemrushProjectCollection } from './brand-semrush-project.collection.js';
15
+ export { default as BrandSemrushProjectSchema } from './brand-semrush-project.schema.js';
@@ -16,6 +16,7 @@ export type * from './async-job';
16
16
  export type * from './audit';
17
17
  export type * from './audit-url';
18
18
  export type * from './base';
19
+ export type * from './brand-semrush-project';
19
20
  export type * from './configuration';
20
21
  export type * from './consumer';
21
22
  export type * from './entitlement';
@@ -17,6 +17,7 @@ export * from './contact-sales-lead/index.js';
17
17
  export * from './audit/index.js';
18
18
  export * from './audit-url/index.js';
19
19
  export * from './base/index.js';
20
+ export * from './brand-semrush-project/index.js';
20
21
  export * from './configuration/index.js';
21
22
  export * from './consumer/index.js';
22
23
  export * from './entitlement/index.js';
@@ -44,6 +44,7 @@ class PlgOnboarding extends BaseModel {
44
44
  CLOSED: 'CLOSED',
45
45
  REOPENED: 'REOPENED',
46
46
  OFFBOARDED: 'OFFBOARDED',
47
+ PENDING: 'PENDING',
47
48
  };
48
49
  }
49
50
 
@@ -17,6 +17,10 @@ const DEFAULT_PAGE_SIZE = 1000;
17
17
  const ENTITY_TABLE_OVERRIDES = {
18
18
  LatestAudit: 'audits',
19
19
  SuggestionGrant: 'suggestion_grants',
20
+ // Entity renamed from BrandToSemrushProject -> BrandSemrushProject during
21
+ // PR review. The DB table name was kept as `brand_to_semrush_projects` to
22
+ // avoid a follow-up migration in mysticat-data-service.
23
+ BrandSemrushProject: 'brand_to_semrush_projects',
20
24
  };
21
25
 
22
26
  const camelToSnake = (value) => value.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();