@adobe/spacecat-shared-data-access 3.45.2 → 3.47.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 +17 -0
- package/README.md +16 -3
- package/package.json +4 -4
- package/src/models/api-key/api-key.schema.js +0 -6
- package/src/models/audit/audit.schema.js +1 -7
- package/src/models/audit-url/audit-url.model.js +1 -1
- package/src/models/audit-url/audit-url.schema.js +0 -4
- package/src/models/base/entity.registry.js +2 -2
- package/src/models/base/index.d.ts +1 -1
- package/src/models/base/schema.builder.js +1 -3
- package/src/models/base/schema.js +3 -3
- package/src/models/configuration/configuration.collection.js +1 -1
- package/src/models/configuration/configuration.model.js +1 -1
- package/src/models/configuration/configuration.schema.js +1 -1
- package/src/models/consumer/consumer.schema.js +0 -6
- package/src/models/entitlement/entitlement.model.js +1 -0
- package/src/models/entitlement/entitlement.schema.js +0 -6
- package/src/models/entitlement/index.d.ts +1 -1
- package/src/models/experiment/experiment.schema.js +0 -6
- package/src/models/fix-entity/fix-entity.schema.js +0 -6
- package/src/models/fix-entity-suggestion/fix-entity-suggestion.schema.js +0 -6
- package/src/models/geo-experiment/geo-experiment.collection.js +22 -0
- package/src/models/geo-experiment/geo-experiment.model.js +37 -3
- package/src/models/geo-experiment/geo-experiment.schema.js +2 -1
- package/src/models/geo-experiment/index.d.ts +1 -0
- package/src/models/import-job/import-job.schema.js +0 -6
- package/src/models/import-url/import-url.schema.js +0 -6
- package/src/models/key-event/key-event.schema.js +0 -6
- package/src/models/latest-audit/latest-audit.schema.js +1 -7
- package/src/models/opportunity/opportunity.schema.js +0 -6
- package/src/models/organization/organization.schema.js +0 -6
- package/src/models/page-citability/page-citability.schema.js +0 -6
- package/src/models/page-intent/README.md +1 -1
- package/src/models/page-intent/page-intent.schema.js +0 -6
- package/src/models/plg-onboarding/plg-onboarding.schema.js +0 -6
- package/src/models/project/project.schema.js +0 -6
- package/src/models/report/report.schema.js +0 -6
- package/src/models/scrape-job/scrape-job.schema.js +0 -6
- package/src/models/scrape-url/scrape-url.schema.js +0 -6
- package/src/models/sentiment-guideline/sentiment-guideline.schema.js +0 -4
- package/src/models/sentiment-topic/sentiment-topic.schema.js +0 -4
- package/src/models/site/index.d.ts +11 -0
- package/src/models/site/site.schema.js +3 -6
- package/src/models/site-candidate/site-candidate.schema.js +0 -6
- package/src/models/site-enrollment/site-enrollment.schema.js +0 -6
- package/src/models/site-top-form/site-top-form.schema.js +0 -6
- package/src/models/site-top-page/site-top-page.schema.js +0 -6
- package/src/models/suggestion/suggestion.schema.js +0 -6
- package/src/models/trial-user/trial-user.schema.js +0 -6
- package/src/models/trial-user-activity/trial-user-activity.schema.js +0 -6
- package/migration.sh +0 -137
- package/src/readme.md +0 -463
|
@@ -19,10 +19,6 @@ import SentimentGuideline from './sentiment-guideline.model.js';
|
|
|
19
19
|
import SentimentGuidelineCollection from './sentiment-guideline.collection.js';
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
23
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
24
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
25
|
-
|
|
26
22
|
Data Access Patterns:
|
|
27
23
|
1. Get all guidelines for a site: allBySiteId(siteId)
|
|
28
24
|
2. Get a specific guideline: findById(siteId, guidelineId)
|
|
@@ -19,10 +19,6 @@ import SentimentTopic from './sentiment-topic.model.js';
|
|
|
19
19
|
import SentimentTopicCollection from './sentiment-topic.collection.js';
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
23
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
24
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
25
|
-
|
|
26
22
|
Data Access Patterns:
|
|
27
23
|
1. Get all topics for a site: allBySiteId(siteId)
|
|
28
24
|
2. Get a specific topic: findById(siteId, topicId)
|
|
@@ -44,6 +44,17 @@ export interface CodeConfig {
|
|
|
44
44
|
s3StoragePath?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export interface DeliveryConfig {
|
|
48
|
+
programId?: string;
|
|
49
|
+
environmentId?: string;
|
|
50
|
+
authorURL?: string;
|
|
51
|
+
siteId?: string;
|
|
52
|
+
tenantId?: string;
|
|
53
|
+
ipAllowlistExists?: boolean;
|
|
54
|
+
imsOrgId?: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
47
58
|
export type IMPORT_TYPES = {
|
|
48
59
|
readonly ORGANIC_KEYWORDS: 'organic-keywords';
|
|
49
60
|
readonly ORGANIC_TRAFFIC: 'organic-traffic';
|
|
@@ -25,12 +25,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
25
25
|
import Site, { computeExternalIds } from './site.model.js';
|
|
26
26
|
import SiteCollection from './site.collection.js';
|
|
27
27
|
|
|
28
|
-
/*
|
|
29
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
30
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
31
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
28
|
const schema = new SchemaBuilder(Site, SiteCollection)
|
|
35
29
|
// this will add an attribute 'organizationId' as well as an index 'byOrganizationId'
|
|
36
30
|
.addReference('belongs_to', 'Organization')
|
|
@@ -120,6 +114,9 @@ const schema = new SchemaBuilder(Site, SiteCollection)
|
|
|
120
114
|
environmentId: { type: 'string' },
|
|
121
115
|
authorURL: { type: 'string', validate: (value) => isValidUrl(value) },
|
|
122
116
|
siteId: { type: 'string' },
|
|
117
|
+
tenantId: { type: 'string' },
|
|
118
|
+
ipAllowlistExists: { type: 'boolean' },
|
|
119
|
+
imsOrgId: { type: 'string' },
|
|
123
120
|
},
|
|
124
121
|
})
|
|
125
122
|
.addAttribute('hlxConfig', {
|
|
@@ -18,12 +18,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
18
18
|
import SiteCandidate from './site-candidate.model.js';
|
|
19
19
|
import SiteCandidateCollection from './site-candidate.collection.js';
|
|
20
20
|
|
|
21
|
-
/*
|
|
22
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
23
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
24
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
21
|
const schema = new SchemaBuilder(SiteCandidate, SiteCandidateCollection)
|
|
28
22
|
.addReference('belongs_to', 'Site')
|
|
29
23
|
.addAttribute('siteId', {
|
|
@@ -14,12 +14,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
14
14
|
import SiteEnrollment from './site-enrollment.model.js';
|
|
15
15
|
import SiteEnrollmentCollection from './site-enrollment.collection.js';
|
|
16
16
|
|
|
17
|
-
/*
|
|
18
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
19
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
20
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
17
|
const schema = new SchemaBuilder(SiteEnrollment, SiteEnrollmentCollection)
|
|
24
18
|
// Reference to Site (many-to-one relationship)
|
|
25
19
|
.addReference('belongs_to', 'Site')
|
|
@@ -23,12 +23,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
23
23
|
import SiteTopForm from './site-top-form.model.js';
|
|
24
24
|
import SiteTopFormCollection from './site-top-form.collection.js';
|
|
25
25
|
|
|
26
|
-
/*
|
|
27
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
28
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
29
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
26
|
const schema = new SchemaBuilder(SiteTopForm, SiteTopFormCollection)
|
|
33
27
|
.addReference('belongs_to', 'Site', ['source', 'traffic'])
|
|
34
28
|
.addAttribute('siteId', {
|
|
@@ -23,12 +23,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
23
23
|
import SiteTopPage from './site-top-page.model.js';
|
|
24
24
|
import SiteTopPageCollection from './site-top-page.collection.js';
|
|
25
25
|
|
|
26
|
-
/*
|
|
27
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
28
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
29
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
26
|
const schema = new SchemaBuilder(SiteTopPage, SiteTopPageCollection)
|
|
33
27
|
.addReference('belongs_to', 'Site', ['source', 'geo', 'traffic'])
|
|
34
28
|
.addAttribute('siteId', {
|
|
@@ -18,12 +18,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
18
18
|
import Suggestion from './suggestion.model.js';
|
|
19
19
|
import SuggestionCollection from './suggestion.collection.js';
|
|
20
20
|
|
|
21
|
-
/*
|
|
22
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
23
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
24
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
21
|
const schema = new SchemaBuilder(Suggestion, SuggestionCollection)
|
|
28
22
|
.addReference('belongs_to', 'Opportunity', ['status', 'rank'])
|
|
29
23
|
.addReference('has_many', 'FixEntitySuggestion', ['updatedAt'], { removeDependents: true })
|
|
@@ -15,12 +15,6 @@ import SchemaBuilder from '../base/schema.builder.js';
|
|
|
15
15
|
import TrialUser from './trial-user.model.js';
|
|
16
16
|
import TrialUserCollection from './trial-user.collection.js';
|
|
17
17
|
|
|
18
|
-
/*
|
|
19
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
20
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
21
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
18
|
const schema = new SchemaBuilder(TrialUser, TrialUserCollection)
|
|
25
19
|
// Reference to Organization (many-to-one relationship)
|
|
26
20
|
.addReference('belongs_to', 'Organization')
|
|
@@ -15,12 +15,6 @@ import TrialUserActivity from './trial-user-activity.model.js';
|
|
|
15
15
|
import TrialUserActivityCollection from './trial-user-activity.collection.js';
|
|
16
16
|
import Entitlement from '../entitlement/entitlement.model.js';
|
|
17
17
|
|
|
18
|
-
/*
|
|
19
|
-
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
20
|
-
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
21
|
-
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
18
|
const schema = new SchemaBuilder(TrialUserActivity, TrialUserActivityCollection)
|
|
25
19
|
.addReference('belongs_to', 'TrialUser')
|
|
26
20
|
// Reference to Organization (many-to-one relationship)
|
package/migration.sh
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Define AWS CLI command with local DynamoDB endpoint
|
|
4
|
-
AWS_CMD="aws dynamodb --endpoint-url http://localhost:8000"
|
|
5
|
-
REGION="us-west-2"
|
|
6
|
-
|
|
7
|
-
# Define table names
|
|
8
|
-
SITE_TABLE="spacecat-services-sites"
|
|
9
|
-
ORGANIZATION_TABLE="spacecat-services-organizations"
|
|
10
|
-
|
|
11
|
-
# Fetch all sites
|
|
12
|
-
SITES=$($AWS_CMD scan --table-name $SITE_TABLE)
|
|
13
|
-
ORGANIZATIONS=$($AWS_CMD scan --table-name $ORGANIZATION_TABLE)
|
|
14
|
-
|
|
15
|
-
# Migrate each site
|
|
16
|
-
echo "$SITES" | jq -c '.Items[]' | while read -r site; do
|
|
17
|
-
SITE_ID=$(echo $site | jq -r '.id.S')
|
|
18
|
-
BASE_URL=$(echo $site | jq -r '.baseURL.S')
|
|
19
|
-
DELIVERY_TYPE=$(echo $site | jq -r '.deliveryType.S')
|
|
20
|
-
GITHUB_URL=$(echo $site | jq -r '.gitHubURL.S')
|
|
21
|
-
ORG_ID=$(echo $site | jq -r '.organizationId.S')
|
|
22
|
-
IS_LIVE=$(echo $site | jq -r '.isLive.BOOL // false')
|
|
23
|
-
IS_LIVE_TOGGLED_AT=$(echo $site | jq -r '.isLiveToggledAt.S // empty')
|
|
24
|
-
GSI1PK=$(echo $site | jq -r '.GSI1PK.S')
|
|
25
|
-
CREATED_AT=$(echo $site | jq -r '.createdAt.S')
|
|
26
|
-
UPDATED_AT=$(echo $site | jq -r '.updatedAt.S')
|
|
27
|
-
SLACK=$(echo $site | jq -r '.config.M.slack // {"M": {}}')
|
|
28
|
-
IMPORTS=$(echo $site | jq -r '.config.M.imports // {"L": []}')
|
|
29
|
-
HLX_CONFIG=$(echo $site | jq -r '.hlxConfig // {"M": {}}')
|
|
30
|
-
|
|
31
|
-
# Check for 404 and broken-backlinks mentions
|
|
32
|
-
ALERTS=$(echo $site | jq -c '.config.M.alerts.L')
|
|
33
|
-
MENTIONS_404_SLACK='{"L":[]}'
|
|
34
|
-
MENTIONS_BROKEN_BACKLINKS_SLACK='{"L":[]}'
|
|
35
|
-
for alert in $(echo "$ALERTS" | jq -c '.[]'); do
|
|
36
|
-
ALERT_TYPE=$(echo $alert | jq -r '.M.type.S // empty')
|
|
37
|
-
if [ "$ALERT_TYPE" == "404" ]; then
|
|
38
|
-
MENTIONS_404_SLACK=$(echo $alert | jq -r '.M.mentions.L[0].M.slack // {"L":[]}')
|
|
39
|
-
elif [ "$ALERT_TYPE" == "broken-backlinks" ]; then
|
|
40
|
-
MENTIONS_BROKEN_BACKLINKS_SLACK=$(echo $alert | jq -r '.M.mentions.L[0].M.slack // {"L":[]}')
|
|
41
|
-
fi
|
|
42
|
-
done
|
|
43
|
-
|
|
44
|
-
# Get excluded URLs
|
|
45
|
-
EXCLUDED_URLS=$(echo $site | jq -c '.auditConfig.M.auditTypeConfigs.M["broken-backlinks"].M.excludedURLs // {"L" :[]} ')
|
|
46
|
-
MANUAL_OVERWRITES=$(echo $site | jq -c '.auditConfig.M.auditTypeConfigs.M["broken-backlinks"].M.manualOverwrites // {"L" :[]} ')
|
|
47
|
-
FIXED_URLS=$(echo $site | jq -c '.auditConfig.M.auditTypeConfigs.M["broken-backlinks"].M.fixedURLs // {"L" :[]} ')
|
|
48
|
-
MIGRATED_SITE=$(cat <<EOF
|
|
49
|
-
{
|
|
50
|
-
"id": {"S": "$SITE_ID"},
|
|
51
|
-
"baseURL": {"S": "$BASE_URL"},
|
|
52
|
-
"deliveryType": {"S": "$DELIVERY_TYPE"},
|
|
53
|
-
"gitHubURL": {"S": "$GITHUB_URL"},
|
|
54
|
-
"organizationId": {"S": "$ORG_ID"},
|
|
55
|
-
"isLive": {"BOOL": $IS_LIVE},
|
|
56
|
-
"isLiveToggledAt": {"S": "$IS_LIVE_TOGGLED_AT"},
|
|
57
|
-
"GSI1PK": {"S": "$GSI1PK"},
|
|
58
|
-
"createdAt": {"S": "$CREATED_AT"},
|
|
59
|
-
"updatedAt": {"S": "$UPDATED_AT"},
|
|
60
|
-
"hlxConfig": $HLX_CONFIG,
|
|
61
|
-
"config": {
|
|
62
|
-
"M": {
|
|
63
|
-
"slack": $SLACK,
|
|
64
|
-
"imports": $IMPORTS,
|
|
65
|
-
"handlers": {
|
|
66
|
-
"M": {
|
|
67
|
-
"404": {"M": {"mentions": {"M": {"slack": $MENTIONS_404_SLACK}}}},
|
|
68
|
-
"broken-backlinks": {"M": {"mentions": {"M": {"slack": $MENTIONS_BROKEN_BACKLINKS_SLACK}}, "excludedURLs": $EXCLUDED_URLS, "manualOverwrites": $MANUAL_OVERWRITES, "fixedURLs": $FIXED_URLS}}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
EOF
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
# Insert migrated site data into the site table
|
|
78
|
-
$AWS_CMD put-item --table-name $SITE_TABLE --item "$MIGRATED_SITE"
|
|
79
|
-
done
|
|
80
|
-
|
|
81
|
-
# Migrate each organization
|
|
82
|
-
echo "$ORGANIZATIONS" | jq -c '.Items[]' | while read -r org; do
|
|
83
|
-
ORG_ID=$(echo $org | jq -r '.id.S')
|
|
84
|
-
IMS_ORG_ID=$(echo $org | jq -r '.imsOrgId.S')
|
|
85
|
-
NAME=$(echo $org | jq -r '.name.S')
|
|
86
|
-
GSI1PK=$(echo $org | jq -r '.GSI1PK.S')
|
|
87
|
-
CREATED_AT=$(echo $org | jq -r '.createdAt.S')
|
|
88
|
-
UPDATED_AT=$(echo $org | jq -r '.updatedAt.S')
|
|
89
|
-
FULLFILLABLE_ITEMS=$(echo $org | jq -r '.fulfillableItems // {"M": {}}')
|
|
90
|
-
SLACK=$(echo $org | jq -r '.config.M.slack // {"M": {}}')
|
|
91
|
-
IMPORTS=$(echo $org | jq -r '.config.M.imports // {"L": []}')
|
|
92
|
-
|
|
93
|
-
# Check for 404 and broken-backlinks mentions
|
|
94
|
-
ALERTS=$(echo $org | jq -c '.config.M.alerts.L')
|
|
95
|
-
MENTIONS_404_SLACK='{"L":[]}'
|
|
96
|
-
MENTIONS_BROKEN_BACKLINKS_SLACK='{"L":[]}'
|
|
97
|
-
for alert in $(echo "$ALERTS" | jq -c '.[]'); do
|
|
98
|
-
ALERT_TYPE=$(echo $alert | jq -r '.M.type.S // empty')
|
|
99
|
-
if [ "$ALERT_TYPE" == "404" ]; then
|
|
100
|
-
MENTIONS_404_SLACK=$(echo $alert | jq -r '.M.mentions.L[0].M.slack // {"L":[]}')
|
|
101
|
-
elif [ "$ALERT_TYPE" == "broken-backlinks" ]; then
|
|
102
|
-
MENTIONS_BROKEN_BACKLINKS_SLACK=$(echo $alert | jq -r '.M.mentions.L[0].M.slack // {"L":[]}')
|
|
103
|
-
fi
|
|
104
|
-
done
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
MIGRATED_ORG=$(cat <<EOF
|
|
109
|
-
{
|
|
110
|
-
"id": {"S": "$ORG_ID"},
|
|
111
|
-
"imsOrgId": {"S": "$IMS_ORG_ID"},
|
|
112
|
-
"name": {"S": "$NAME"},
|
|
113
|
-
"GSI1PK": {"S": "$GSI1PK"},
|
|
114
|
-
"createdAt": {"S": "$CREATED_AT"},
|
|
115
|
-
"updatedAt": {"S": "$UPDATED_AT"},
|
|
116
|
-
"fulfillableItems": $FULLFILLABLE_ITEMS,
|
|
117
|
-
"config": {
|
|
118
|
-
"M": {
|
|
119
|
-
"slack": $SLACK,
|
|
120
|
-
"imports": $IMPORTS,
|
|
121
|
-
"handlers": {
|
|
122
|
-
"M": {
|
|
123
|
-
"404": {"M": {"mentions": {"M": {"slack": $MENTIONS_404_SLACK}}}},
|
|
124
|
-
"broken-backlinks": {"M": {"mentions": {"M": {"slack": $MENTIONS_BROKEN_BACKLINKS_SLACK}}}}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
EOF
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
# Insert migrated organization data into the organization table
|
|
134
|
-
$AWS_CMD put-item --table-name $ORGANIZATION_TABLE --item "$MIGRATED_ORG"
|
|
135
|
-
done
|
|
136
|
-
|
|
137
|
-
echo "Migration completed successfully."
|