@adobe/spacecat-shared-data-access 2.88.0 → 2.88.2
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 +14 -0
- package/package.json +1 -1
- package/src/models/api-key/api-key.model.js +2 -0
- package/src/models/async-job/async-job.model.js +2 -0
- package/src/models/audit/audit.model.js +2 -0
- package/src/models/base/base.model.js +8 -0
- package/src/models/base/schema.builder.js +5 -1
- package/src/models/configuration/configuration.model.js +2 -0
- package/src/models/entitlement/entitlement.model.js +2 -0
- package/src/models/entitlement/entitlement.schema.js +1 -1
- package/src/models/experiment/experiment.model.js +2 -0
- package/src/models/fix-entity/fix-entity.model.js +2 -0
- package/src/models/fix-entity-suggestion/fix-entity-suggestion.model.js +2 -0
- package/src/models/import-job/import-job.model.js +2 -0
- package/src/models/import-url/import-url.model.js +2 -0
- package/src/models/key-event/key-event.model.js +2 -0
- package/src/models/latest-audit/latest-audit.model.js +2 -0
- package/src/models/opportunity/opportunity.model.js +2 -0
- package/src/models/organization/organization.model.js +2 -0
- package/src/models/page-citability/page-citability.model.js +2 -0
- package/src/models/page-intent/page-intent.model.js +2 -0
- package/src/models/project/project.model.js +2 -0
- package/src/models/report/report.model.js +2 -0
- package/src/models/scrape-job/scrape-job.model.js +2 -0
- package/src/models/scrape-url/scrape-url.model.js +2 -0
- package/src/models/site/site.model.js +2 -0
- package/src/models/site-candidate/site-candidate.model.js +2 -0
- package/src/models/site-enrollment/site-enrollment.model.js +2 -0
- package/src/models/site-top-form/site-top-form.model.js +2 -0
- package/src/models/site-top-page/site-top-page.model.js +2 -0
- package/src/models/suggestion/suggestion.model.js +2 -0
- package/src/models/trial-user/trial-user.model.js +2 -0
- package/src/models/trial-user-activity/trial-user-activity.model.js +2 -0
- package/src/readme.md +23 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.88.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.88.1...@adobe/spacecat-shared-data-access-v2.88.2) (2025-11-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Make Entity Naming Bundler-Agnostic with Explicit ENTITY_NAME ([#1173](https://github.com/adobe/spacecat-shared/issues/1173)) ([c6cb69c](https://github.com/adobe/spacecat-shared/commit/c6cb69c6114db686f911afafe8d477b4556d9d49))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v2.88.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.88.0...@adobe/spacecat-shared-data-access-v2.88.1) (2025-11-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove enrollments when entitlment are removed ([#1161](https://github.com/adobe/spacecat-shared/issues/1161)) ([b82e6c4](https://github.com/adobe/spacecat-shared/commit/b82e6c4c259543bd0d3e3a3ad2d3e2702956d85c))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v2.88.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.87.1...@adobe/spacecat-shared-data-access-v2.88.0) (2025-11-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class AsyncJob extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'AsyncJob';
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* Async Job Status types.
|
|
25
27
|
* Any changes to this object needs to be reflected in the index.d.ts file as well.
|
|
@@ -39,6 +39,14 @@ import Reference from './reference.js';
|
|
|
39
39
|
* @class BaseModel
|
|
40
40
|
*/
|
|
41
41
|
class BaseModel {
|
|
42
|
+
/**
|
|
43
|
+
* The entity name for this model. Must be overridden by subclasses.
|
|
44
|
+
* This ensures the entity name is explicit and not dependent on class names
|
|
45
|
+
* which can be mangled by bundlers.
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
static ENTITY_NAME = undefined;
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
* Constructs an instance of BaseModel.
|
|
44
52
|
* @constructor
|
|
@@ -111,10 +111,14 @@ class SchemaBuilder {
|
|
|
111
111
|
throw new SchemaBuilderError(this, 'schemaVersion is required and must be a positive integer.');
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
if (!hasText(modelClass.ENTITY_NAME)) {
|
|
115
|
+
throw new SchemaBuilderError(this, `Model class ${modelClass.name} must define a static ENTITY_NAME property.`);
|
|
116
|
+
}
|
|
117
|
+
|
|
114
118
|
this.modelClass = modelClass;
|
|
115
119
|
this.collectionClass = collectionClass;
|
|
116
120
|
this.schemaVersion = schemaVersion;
|
|
117
|
-
this.entityName = modelClass.
|
|
121
|
+
this.entityName = modelClass.ENTITY_NAME;
|
|
118
122
|
this.serviceName = DEFAULT_SERVICE_NAME;
|
|
119
123
|
|
|
120
124
|
this.idName = entityNameToIdName(this.entityName);
|
|
@@ -24,7 +24,7 @@ const schema = new SchemaBuilder(Entitlement, EntitlementCollection)
|
|
|
24
24
|
// Reference to Organization (many-to-one relationship)
|
|
25
25
|
.addReference('belongs_to', 'Organization')
|
|
26
26
|
// Reference to SiteEnrollments (one-to-many relationship)
|
|
27
|
-
.addReference('has_many', 'SiteEnrollments')
|
|
27
|
+
.addReference('has_many', 'SiteEnrollments', [], { removeDependents: true })
|
|
28
28
|
.addReference('has_many', 'TrialUserActivities')
|
|
29
29
|
.addAttribute('productCode', {
|
|
30
30
|
type: Object.values(Entitlement.PRODUCT_CODES),
|
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class ImportJob extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'ImportJob';
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* Import Job Status types.
|
|
25
27
|
* Any changes to this object needs to be reflected in the index.d.ts file as well.
|
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class Organization extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'Organization';
|
|
24
|
+
|
|
23
25
|
static IMS_ORG_ID_REGEX = /[a-z0-9]{24}@AdobeOrg/i;
|
|
24
26
|
|
|
25
27
|
// add your custom methods or overrides here
|
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class Project extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'Project';
|
|
24
|
+
|
|
23
25
|
async getPrimaryLocaleSites() {
|
|
24
26
|
const sites = await this.getSites();
|
|
25
27
|
return sites.filter((site) => site.getIsPrimaryLocale());
|
|
@@ -70,6 +70,8 @@ export const getAuthoringType = (hostname, authoringTypes) => {
|
|
|
70
70
|
* @extends BaseModel
|
|
71
71
|
*/
|
|
72
72
|
class Site extends BaseModel {
|
|
73
|
+
static ENTITY_NAME = 'Site';
|
|
74
|
+
|
|
73
75
|
static DELIVERY_TYPES = DELIVERY_TYPES;
|
|
74
76
|
|
|
75
77
|
static DEFAULT_DELIVERY_TYPE = DELIVERY_TYPES.AEM_EDGE;
|
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class TrialUser extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'TrialUser';
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* Trial user status types.
|
|
25
27
|
* Any change to this object needs to be reflected in the index.d.ts file as well.
|
|
@@ -20,6 +20,8 @@ import BaseModel from '../base/base.model.js';
|
|
|
20
20
|
* @extends BaseModel
|
|
21
21
|
*/
|
|
22
22
|
class TrialUserActivity extends BaseModel {
|
|
23
|
+
static ENTITY_NAME = 'TrialUserActivity';
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* Trial user activity types.
|
|
25
27
|
* Any change to this object needs to be reflected in the index.d.ts file as well.
|
package/src/readme.md
CHANGED
|
@@ -20,6 +20,8 @@ A *Model* is a class representing a single instance of an entity. It provides:
|
|
|
20
20
|
|
|
21
21
|
Models extend `BaseModel`, which handles most of the common logic.
|
|
22
22
|
|
|
23
|
+
**Required:** All model classes must define a `static ENTITY_NAME` property to ensure bundler-agnostic operation.
|
|
24
|
+
|
|
23
25
|
### Collections
|
|
24
26
|
A *Collection* operates on sets of entities. While `Model` focuses on individual records, `Collection` is for batch and query-level operations:
|
|
25
27
|
|
|
@@ -40,6 +42,21 @@ The `SchemaBuilder` enforces naming conventions and sets defaults, reducing repe
|
|
|
40
42
|
|
|
41
43
|
**Note on Indexes:** Add indexes thoughtfully. Every extra index adds cost and complexity. Only create indexes for well-understood, frequently-needed query patterns.
|
|
42
44
|
|
|
45
|
+
### Entity Naming (ENTITY_NAME)
|
|
46
|
+
|
|
47
|
+
All model classes **must** define a static `ENTITY_NAME` property:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
class User extends BaseModel {
|
|
51
|
+
static ENTITY_NAME = 'User';
|
|
52
|
+
// ...
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This requirement ensures entity names remain consistent regardless of build tool transformations. Modern JavaScript bundlers (webpack, esbuild) may mangle class names during the build process (e.g., `Configuration` → `_Configuration`), which would break ElectroDB's key generation. By explicitly declaring the entity name, the framework operates correctly in all bundling scenarios.
|
|
57
|
+
|
|
58
|
+
The `SchemaBuilder` validates that `ENTITY_NAME` is defined and will throw a descriptive error if it's missing.
|
|
59
|
+
|
|
43
60
|
### Entity Registry
|
|
44
61
|
The `EntityRegistry` aggregates all entities, their schemas, and their collections. It ensures consistent lookup and retrieval of any registered entity’s collection. When you add a new entity, you must register it with the `EntityRegistry` so the rest of the application can discover it.
|
|
45
62
|
|
|
@@ -348,20 +365,22 @@ Create `user.model.js`:
|
|
|
348
365
|
```js
|
|
349
366
|
import BaseModel from '../base/base.model.js';
|
|
350
367
|
|
|
351
|
-
class
|
|
368
|
+
class User extends BaseModel {
|
|
369
|
+
static ENTITY_NAME = 'User';
|
|
370
|
+
|
|
352
371
|
// Additional domain logic methods can be added here if needed.
|
|
353
372
|
}
|
|
354
373
|
|
|
355
|
-
export default
|
|
374
|
+
export default User;
|
|
356
375
|
```
|
|
357
376
|
|
|
377
|
+
**Important:** Every model class **must** define a `static ENTITY_NAME` property. This ensures the entity name is explicit and not affected by bundler transformations (like class name mangling in webpack/esbuild). The `SchemaBuilder` will throw an error if this property is missing.
|
|
378
|
+
|
|
358
379
|
### 3. Implement the Collection
|
|
359
380
|
Create `user.collection.js`:
|
|
360
381
|
|
|
361
382
|
```js
|
|
362
383
|
import BaseCollection from '../base/base.collection.js';
|
|
363
|
-
import UserModel from './user.model.js';
|
|
364
|
-
import userSchema from './user.schema.js';
|
|
365
384
|
|
|
366
385
|
class UserCollection extends BaseCollection {
|
|
367
386
|
// Additional domain logic collection methods can be added here if needed.
|