@adobe/spacecat-shared-tier-client 1.3.6 → 1.3.7
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 +7 -0
- package/package.json +1 -1
- package/src/tier-client.js +2 -2
- package/test/tier-client.test.js +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-tier-client-v1.3.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.6...@adobe/spacecat-shared-tier-client-v1.3.7) (2025-11-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* using entity name instead of instanceof ([#1190](https://github.com/adobe/spacecat-shared/issues/1190)) ([eccda60](https://github.com/adobe/spacecat-shared/commit/eccda60d02f1df7d251957430cb7fcef4041f89c))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-tier-client-v1.3.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.5...@adobe/spacecat-shared-tier-client-v1.3.6) (2025-11-28)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/tier-client.js
CHANGED
|
@@ -28,7 +28,7 @@ class TierClient {
|
|
|
28
28
|
* @returns {TierClient} TierClient instance for organization operations.
|
|
29
29
|
*/
|
|
30
30
|
static createForOrg(context, organization, productCode) {
|
|
31
|
-
if (!(organization
|
|
31
|
+
if (!(organization.entityName === Organization.ENTITY_NAME)) {
|
|
32
32
|
throw new Error('Entity must be an instance of Organization');
|
|
33
33
|
}
|
|
34
34
|
if (!hasText(productCode)) {
|
|
@@ -48,7 +48,7 @@ class TierClient {
|
|
|
48
48
|
* @returns {TierClient} TierClient instance for site operations.
|
|
49
49
|
*/
|
|
50
50
|
static async createForSite(context, site, productCode) {
|
|
51
|
-
if (!(site
|
|
51
|
+
if (!(site.entityName === Site.ENTITY_NAME)) {
|
|
52
52
|
throw new Error('Entity must be an instance of Site');
|
|
53
53
|
}
|
|
54
54
|
if (!hasText(productCode)) {
|
package/test/tier-client.test.js
CHANGED
|
@@ -50,7 +50,10 @@ describe('TierClient', () => {
|
|
|
50
50
|
|
|
51
51
|
// Create actual Organization instance for instanceof checks
|
|
52
52
|
const organizationInstance = Object.create(Organization.prototype);
|
|
53
|
-
Object.assign(
|
|
53
|
+
Object.assign(
|
|
54
|
+
organizationInstance,
|
|
55
|
+
{ entityName: Organization.ENTITY_NAME, ...mockOrganization },
|
|
56
|
+
);
|
|
54
57
|
|
|
55
58
|
const mockSite = {
|
|
56
59
|
getId: () => siteId,
|
|
@@ -60,7 +63,7 @@ describe('TierClient', () => {
|
|
|
60
63
|
|
|
61
64
|
// Create actual Site instance for instanceof checks
|
|
62
65
|
const siteInstance = Object.create(Site.prototype);
|
|
63
|
-
Object.assign(siteInstance, mockSite);
|
|
66
|
+
Object.assign(siteInstance, { entityName: Site.ENTITY_NAME, ...mockSite });
|
|
64
67
|
|
|
65
68
|
const mockDataAccess = {
|
|
66
69
|
Entitlement: {
|
|
@@ -118,10 +121,11 @@ describe('TierClient', () => {
|
|
|
118
121
|
|
|
119
122
|
describe('Static Factory Methods', () => {
|
|
120
123
|
const testOrganization = Object.create(Organization.prototype);
|
|
121
|
-
Object.assign(testOrganization, { getId: () => orgId });
|
|
124
|
+
Object.assign(testOrganization, { entityName: Organization.ENTITY_NAME, getId: () => orgId });
|
|
122
125
|
|
|
123
126
|
const testSite = Object.create(Site.prototype);
|
|
124
127
|
Object.assign(testSite, {
|
|
128
|
+
entityName: Site.ENTITY_NAME,
|
|
125
129
|
getId: () => siteId,
|
|
126
130
|
getOrganizationId: () => orgId,
|
|
127
131
|
getOrganization: () => testOrganization,
|
|
@@ -129,6 +133,7 @@ describe('TierClient', () => {
|
|
|
129
133
|
|
|
130
134
|
const testSiteWithOrgRef = Object.create(Site.prototype);
|
|
131
135
|
Object.assign(testSiteWithOrgRef, {
|
|
136
|
+
entityName: Site.ENTITY_NAME,
|
|
132
137
|
getId: () => siteId,
|
|
133
138
|
getOrganizationId: () => orgId,
|
|
134
139
|
});
|
|
@@ -143,7 +148,7 @@ describe('TierClient', () => {
|
|
|
143
148
|
});
|
|
144
149
|
|
|
145
150
|
it('should throw error when organization is not provided', () => {
|
|
146
|
-
expect(() => TierClient.createForOrg(mockContext, null, productCode)).to.throw('
|
|
151
|
+
expect(() => TierClient.createForOrg(mockContext, null, productCode)).to.throw('Cannot read properties of null');
|
|
147
152
|
});
|
|
148
153
|
|
|
149
154
|
it('should throw error when organization has no getId method', () => {
|
|
@@ -194,7 +199,7 @@ describe('TierClient', () => {
|
|
|
194
199
|
});
|
|
195
200
|
|
|
196
201
|
it('should throw error when site is not provided', async () => {
|
|
197
|
-
await expect(TierClient.createForSite(mockContext, null, productCode)).to.be.rejectedWith('
|
|
202
|
+
await expect(TierClient.createForSite(mockContext, null, productCode)).to.be.rejectedWith('Cannot read properties of null');
|
|
198
203
|
});
|
|
199
204
|
|
|
200
205
|
it('should throw error when site has no getId method', async () => {
|