@adobe/spacecat-shared-data-access 1.61.0 → 1.61.1

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,10 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.61.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.0...@adobe/spacecat-shared-data-access-v1.61.1) (2024-12-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * schema and db init ([#505](https://github.com/adobe/spacecat-shared/issues/505)) ([9b67b9a](https://github.com/adobe/spacecat-shared/commit/9b67b9a9f40f643c648cc5043018bfbc1d2a9c12))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v1.61.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.60.3...@adobe/spacecat-shared-data-access-v1.61.0) (2024-12-23)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "1.61.0",
3
+ "version": "1.61.1",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -31,8 +31,8 @@ import { importUrlFunctions } from './import-url/index.js';
31
31
  import { experimentFunctions } from './experiments/index.js';
32
32
  import { apiKeyFunctions } from './api-key/index.js';
33
33
 
34
- const createRawClient = () => {
35
- const dbClient = AWSXray.captureAWSv3Client(new DynamoDB());
34
+ const createRawClient = (client = undefined) => {
35
+ const dbClient = client || AWSXray.captureAWSv3Client(new DynamoDB());
36
36
  return DynamoDBDocument.from(dbClient, {
37
37
  marshallOptions: {
38
38
  convertEmptyValues: true,
@@ -70,6 +70,7 @@ const createElectroService = (client, config, log) => {
70
70
  * tableNameSiteTopPages: string, indexNameAllOrganizations: string,
71
71
  * indexNameAllOrganizationsByImsOrgId: string, pkAllOrganizations: string}} config configuration
72
72
  * @param {Logger} log log
73
+ * @param client custom dynamo client
73
74
  * @returns {object} data access object
74
75
  */
75
76
  export const createDataAccess = (config, log = console, client = undefined) => {
@@ -88,7 +89,7 @@ export const createDataAccess = (config, log = console, client = undefined) => {
88
89
  const apiKeyFuncs = apiKeyFunctions(dynamoClient, config, log);
89
90
 
90
91
  // electro-based data access objects
91
- const rawClient = createRawClient();
92
+ const rawClient = createRawClient(client);
92
93
  const electroService = createElectroService(rawClient, config, log);
93
94
  const entityRegistry = new EntityRegistry(electroService, log);
94
95
  const collections = entityRegistry.getCollections();
@@ -31,9 +31,11 @@ const schema = new SchemaBuilder(ApiKey, ApiKeyCollection)
31
31
  })
32
32
  .addAttribute('imsUserId', {
33
33
  type: 'string',
34
+ default: 'default',
34
35
  })
35
36
  .addAttribute('imsOrgId', {
36
37
  type: 'string',
38
+ default: 'default',
37
39
  })
38
40
  .addAttribute('name', {
39
41
  type: 'string',
@@ -78,9 +78,9 @@ const schema = new SchemaBuilder(Configuration, ConfigurationCollection)
78
78
  items: {
79
79
  type: 'map',
80
80
  properties: {
81
- group: { type: ['audits', 'imports', 'reports'] },
81
+ group: { type: ['audits', 'imports', 'reports', 'scrapes'] },
82
82
  type: { type: 'string', required: true },
83
- interval: { type: ['daily', 'weekly'] },
83
+ interval: { type: ['daily', 'weekly', 'every-saturday', 'every-sunday', 'fortnightly', 'monthly'] },
84
84
  },
85
85
  },
86
86
  })
@@ -12,7 +12,9 @@
12
12
 
13
13
  /* c8 ignore start */
14
14
 
15
- import { isIsoDate, isNonEmptyObject, isValidUrl } from '@adobe/spacecat-shared-utils';
15
+ import {
16
+ isIsoDate, isNonEmptyObject, isString, isValidUrl,
17
+ } from '@adobe/spacecat-shared-utils';
16
18
 
17
19
  import SchemaBuilder from '../base/schema.builder.js';
18
20
  import Experiment, { DEFAULT_UPDATED_BY } from './experiment.model.js';
@@ -28,8 +30,12 @@ const schema = new SchemaBuilder(Experiment, ExperimentCollection)
28
30
  .addReference('belongs_to', 'Site', ['expId', 'url', 'updatedAt'])
29
31
  .addAttribute('conversionEventName', {
30
32
  type: 'string',
33
+ validate: (value) => !value || isString(value),
34
+ })
35
+ .addAttribute('conversionEventValue', {
36
+ type: 'string',
37
+ validate: (value) => !value || isString(value),
31
38
  })
32
- .addAttribute('conversionEventValue', { type: 'string' })
33
39
  .addAttribute('endDate', {
34
40
  type: 'string',
35
41
  validate: (value) => !value || isIsoDate(value),
@@ -47,7 +53,10 @@ const schema = new SchemaBuilder(Experiment, ExperimentCollection)
47
53
  type: ['ACTIVE', 'INACTIVE'],
48
54
  required: true,
49
55
  })
50
- .addAttribute('type', { type: 'string' })
56
+ .addAttribute('type', {
57
+ type: 'string',
58
+ validate: (value) => !value || isString(value),
59
+ })
51
60
  .addAttribute('url', {
52
61
  type: 'string',
53
62
  required: true,