@adobe/spacecat-shared-data-access 3.46.0 → 3.48.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -3
  3. package/package.json +4 -4
  4. package/src/models/api-key/api-key.schema.js +0 -6
  5. package/src/models/audit/audit.schema.js +1 -7
  6. package/src/models/audit-url/audit-url.model.js +1 -1
  7. package/src/models/audit-url/audit-url.schema.js +0 -4
  8. package/src/models/base/entity.registry.js +2 -2
  9. package/src/models/base/index.d.ts +1 -1
  10. package/src/models/base/schema.builder.js +1 -3
  11. package/src/models/base/schema.js +3 -3
  12. package/src/models/configuration/configuration.collection.js +1 -1
  13. package/src/models/configuration/configuration.model.js +1 -1
  14. package/src/models/configuration/configuration.schema.js +1 -1
  15. package/src/models/consumer/consumer.schema.js +0 -6
  16. package/src/models/entitlement/entitlement.model.js +1 -0
  17. package/src/models/entitlement/entitlement.schema.js +0 -6
  18. package/src/models/entitlement/index.d.ts +1 -1
  19. package/src/models/experiment/experiment.schema.js +0 -6
  20. package/src/models/fix-entity/fix-entity.schema.js +0 -6
  21. package/src/models/fix-entity-suggestion/fix-entity-suggestion.schema.js +0 -6
  22. package/src/models/geo-experiment/geo-experiment.collection.js +22 -0
  23. package/src/models/geo-experiment/geo-experiment.model.js +37 -3
  24. package/src/models/geo-experiment/geo-experiment.schema.js +2 -1
  25. package/src/models/geo-experiment/index.d.ts +1 -0
  26. package/src/models/import-job/import-job.schema.js +0 -6
  27. package/src/models/import-url/import-url.schema.js +0 -6
  28. package/src/models/key-event/key-event.schema.js +0 -6
  29. package/src/models/latest-audit/latest-audit.schema.js +1 -7
  30. package/src/models/opportunity/opportunity.schema.js +0 -6
  31. package/src/models/organization/organization.schema.js +0 -6
  32. package/src/models/page-citability/page-citability.schema.js +0 -6
  33. package/src/models/page-intent/README.md +1 -1
  34. package/src/models/page-intent/page-intent.schema.js +0 -6
  35. package/src/models/plg-onboarding/index.d.ts +14 -1
  36. package/src/models/plg-onboarding/plg-onboarding.model.js +6 -0
  37. package/src/models/plg-onboarding/plg-onboarding.schema.js +19 -6
  38. package/src/models/project/project.schema.js +0 -6
  39. package/src/models/report/report.schema.js +0 -6
  40. package/src/models/scrape-job/scrape-job.schema.js +0 -6
  41. package/src/models/scrape-url/scrape-url.schema.js +0 -6
  42. package/src/models/sentiment-guideline/sentiment-guideline.schema.js +0 -4
  43. package/src/models/sentiment-topic/sentiment-topic.schema.js +0 -4
  44. package/src/models/site/site.schema.js +0 -6
  45. package/src/models/site-candidate/site-candidate.schema.js +0 -6
  46. package/src/models/site-enrollment/site-enrollment.schema.js +0 -6
  47. package/src/models/site-top-form/site-top-form.schema.js +0 -6
  48. package/src/models/site-top-page/site-top-page.schema.js +0 -6
  49. package/src/models/suggestion/suggestion.schema.js +0 -6
  50. package/src/models/trial-user/trial-user.schema.js +0 -6
  51. package/src/models/trial-user-activity/trial-user-activity.schema.js +0 -6
  52. package/migration.sh +0 -137
  53. package/src/readme.md +0 -463
@@ -18,12 +18,6 @@ import SchemaBuilder from '../base/schema.builder.js';
18
18
  import Project from './project.model.js';
19
19
  import ProjectCollection from './project.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(Project, ProjectCollection)
28
22
  .addReference('belongs_to', 'Organization')
29
23
  .addReference('has_many', 'Sites')
@@ -17,12 +17,6 @@ import SchemaBuilder from '../base/schema.builder.js';
17
17
  import Report from './report.model.js';
18
18
  import ReportCollection from './report.collection.js';
19
19
 
20
- /*
21
- Schema Doc: https://electrodb.dev/en/modeling/schema/
22
- Attribute Doc: https://electrodb.dev/en/modeling/attributes/
23
- Indexes Doc: https://electrodb.dev/en/modeling/indexes/
24
- */
25
-
26
20
  const schema = new SchemaBuilder(Report, ReportCollection)
27
21
  .addReference('belongs_to', 'Site')
28
22
  .addAllIndex(['reportType'])
@@ -25,12 +25,6 @@ import SchemaBuilder from '../base/schema.builder.js';
25
25
  import ScrapeJob from './scrape-job.model.js';
26
26
  import ScrapeJobCollection from './scrape-job.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(ScrapeJob, ScrapeJobCollection)
35
29
  .withRecordExpiry(ScrapeJob.SCRAPE_JOB_EXPIRES_IN_DAYS)
36
30
  .addReference('has_many', 'ScrapeUrls')
@@ -19,12 +19,6 @@ import ScrapeUrl from './scrape-url.model.js';
19
19
  import ScrapeUrlCollection from './scrape-url.collection.js';
20
20
  import { ScrapeJob } from '../scrape-job/index.js';
21
21
 
22
- /*
23
- Schema Doc: https://electrodb.dev/en/modeling/schema/
24
- Attribute Doc: https://electrodb.dev/en/modeling/attributes/
25
- Indexes Doc: https://electrodb.dev/en/modeling/indexes/
26
- */
27
-
28
22
  const schema = new SchemaBuilder(ScrapeUrl, ScrapeUrlCollection)
29
23
  .withRecordExpiry(ScrapeUrl.SCRAPE_URL_EXPIRES_IN_DAYS)
30
24
  .addReference('belongs_to', 'ScrapeJob', ['status'])
@@ -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)
@@ -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')
@@ -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."