-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cd886f
commit baf9deb
Showing
11 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/spacecat-shared-data-access/src/v2/models/site-competitor/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2025 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import type { BaseCollection, BaseModel, Site } from '../index'; | ||
|
||
export interface SiteCompetitor extends BaseModel { | ||
getBaseURL(): string; | ||
getSite(): Promise<Site>; | ||
getSiteId(): string; | ||
getUpdatedBy(): string; | ||
setBaseURL(baseURL: string): SiteCompetitor; | ||
setSiteId(siteId: string): SiteCompetitor; | ||
setUpdatedBy(updatedBy: string): SiteCompetitor; | ||
} | ||
|
||
export interface SiteCandidateCollection extends BaseCollection<SiteCompetitor> { | ||
allByBaseURL(baseURL: string): Promise<SiteCompetitor[]>; | ||
allBySiteId(siteId: string): Promise<SiteCompetitor[]>; | ||
findByBaseURL(baseURL: string): Promise<SiteCompetitor | null>; | ||
findBySiteId(siteId: string): Promise<SiteCompetitor | null>; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/spacecat-shared-data-access/src/v2/models/site-competitor/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2025 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import SiteCompetitor from './site-competitor.model.js'; | ||
import SiteCompetitorCollection from './site-competitor.collection.js'; | ||
|
||
export { | ||
SiteCompetitor, | ||
SiteCompetitorCollection, | ||
}; |
26 changes: 26 additions & 0 deletions
26
...s/spacecat-shared-data-access/src/v2/models/site-competitor/site-competitor.collection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import BaseCollection from '../base/base.collection.js'; | ||
|
||
/** | ||
* SiteCompetitorCollection - A collection class responsible for managing SiteCompetitor entities. | ||
* Extends the BaseCollection to provide specific methods for interacting with | ||
* SiteCompetitor records. | ||
* | ||
* @class SiteCompetitorCollection | ||
* @extends BaseCollection | ||
*/ | ||
class SiteCompetitorCollection extends BaseCollection { | ||
} | ||
|
||
export default SiteCompetitorCollection; |
25 changes: 25 additions & 0 deletions
25
packages/spacecat-shared-data-access/src/v2/models/site-competitor/site-competitor.model.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2025 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
import BaseModel from '../base/base.model.js'; | ||
|
||
/** | ||
* SiteCandidate - A class representing an SiteCompetitor entity. | ||
* Provides methods to access and manipulate SiteCompetitor-specific data. | ||
* | ||
* @class SiteCompetitor | ||
* @extends BaseModel | ||
*/ | ||
class SiteCompetitor extends BaseModel { | ||
|
||
} | ||
|
||
export default SiteCompetitor; |
50 changes: 50 additions & 0 deletions
50
packages/spacecat-shared-data-access/src/v2/models/site-competitor/site-competitor.schema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2025 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
/* c8 ignore start */ | ||
import { isValidUrl } from '@adobe/spacecat-shared-utils'; | ||
|
||
import { validate as uuidValidate } from 'uuid'; | ||
|
||
import SchemaBuilder from '../base/schema.builder.js'; | ||
import SiteCompetitor from './site-competitor.model.js'; | ||
import SiteCompetitorCollection from './site-competitor.collection.js'; | ||
|
||
/* | ||
Schema Doc: https://electrodb.dev/en/modeling/schema/ | ||
Attribute Doc: https://electrodb.dev/en/modeling/attributes/ | ||
Indexes Doc: https://electrodb.dev/en/modeling/indexes/ | ||
*/ | ||
|
||
const schema = new SchemaBuilder(SiteCompetitor, SiteCompetitorCollection) | ||
.addReference('belongs_to', 'Site') | ||
.addAttribute('siteId', { | ||
type: 'string', | ||
validate: (value) => !value || uuidValidate(value), | ||
}) | ||
.addAttribute('baseURL', { | ||
type: 'string', | ||
required: true, | ||
validate: (value) => isValidUrl(value), | ||
}) | ||
.addAttribute('updatedBy', { | ||
type: 'string', | ||
}) | ||
.addAllIndex(['baseURL']) | ||
.addIndex( | ||
{ composite: ['siteId'] }, | ||
{ composite: ['updatedAt'] }, | ||
); | ||
|
||
/* c8 ignore stop */ | ||
|
||
export default schema.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
packages/spacecat-shared-data-access/test/fixtures/site-competitor.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* Copyright 2025 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
const siteCompetitors = [ | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440000', | ||
baseURL: 'https://competitor1.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440001', | ||
baseURL: 'https://competitor2.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440002', | ||
baseURL: 'https://competitor3.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440003', | ||
baseURL: 'https://competitor4.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440004', | ||
baseURL: 'https://competitor5.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440005', | ||
baseURL: 'https://competitor6.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440006', | ||
baseURL: 'https://competitor7.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440007', | ||
baseURL: 'https://competitor8.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440008', | ||
baseURL: 'https://competitor9.com', | ||
siteId: '78fec9c7-2141-4600-b7b1-ea5c78752b91', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440009', | ||
baseURL: 'https://competitor10.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440010', | ||
baseURL: 'https://competitor11.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440011', | ||
baseURL: 'https://competitor12.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440012', | ||
baseURL: 'https://competitor13.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440013', | ||
baseURL: 'https://competitor14.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440014', | ||
baseURL: 'https://competitor15.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440015', | ||
baseURL: 'https://competitor16.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440016', | ||
baseURL: 'https://competitor17.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
{ | ||
siteCompetitorId: '550e8400-e29b-41d4-a716-446655440017', | ||
baseURL: 'https://competitor18.com', | ||
siteId: 'b1ec63c4-87de-4500-bbc9-276039e4bc10', | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
}, | ||
]; | ||
|
||
export default siteCompetitors; |
Oops, something went wrong.