@adobe/spacecat-shared-tier-client 1.3.6 → 1.3.8

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,17 @@
1
+ # [@adobe/spacecat-shared-tier-client-v1.3.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.7...@adobe/spacecat-shared-tier-client-v1.3.8) (2025-11-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove instanceof check ([#1191](https://github.com/adobe/spacecat-shared/issues/1191)) ([c2bf75d](https://github.com/adobe/spacecat-shared/commit/c2bf75d44003e1d0c25bea75640559cd46794301))
7
+
8
+ # [@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)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * using entity name instead of instanceof ([#1190](https://github.com/adobe/spacecat-shared/issues/1190)) ([eccda60](https://github.com/adobe/spacecat-shared/commit/eccda60d02f1df7d251957430cb7fcef4041f89c))
14
+
1
15
  # [@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
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-tier-client",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Shared modules of the Spacecat Services - Tier Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -12,9 +12,7 @@
12
12
 
13
13
  import { isNonEmptyObject, hasText } from '@adobe/spacecat-shared-utils';
14
14
  import {
15
- Site,
16
15
  Entitlement as EntitlementModel,
17
- Organization,
18
16
  } from '@adobe/spacecat-shared-data-access';
19
17
  /**
20
18
  * TierClient provides methods to manage entitlements and site enrollments.
@@ -28,9 +26,6 @@ class TierClient {
28
26
  * @returns {TierClient} TierClient instance for organization operations.
29
27
  */
30
28
  static createForOrg(context, organization, productCode) {
31
- if (!(organization instanceof Organization)) {
32
- throw new Error('Entity must be an instance of Organization');
33
- }
34
29
  if (!hasText(productCode)) {
35
30
  throw new Error('Product code is required');
36
31
  }
@@ -48,9 +43,6 @@ class TierClient {
48
43
  * @returns {TierClient} TierClient instance for site operations.
49
44
  */
50
45
  static async createForSite(context, site, productCode) {
51
- if (!(site instanceof Site)) {
52
- throw new Error('Entity must be an instance of Site');
53
- }
54
46
  if (!hasText(productCode)) {
55
47
  throw new Error('Product code is required');
56
48
  }
@@ -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(organizationInstance, mockOrganization);
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
  });
@@ -142,13 +147,16 @@ describe('TierClient', () => {
142
147
  expect(client.createEntitlement).to.be.a('function');
143
148
  });
144
149
 
145
- it('should throw error when organization is not provided', () => {
146
- expect(() => TierClient.createForOrg(mockContext, null, productCode)).to.throw('Entity must be an instance of Organization');
150
+ it('should allow null organization (validation removed)', () => {
151
+ const client = TierClient.createForOrg(mockContext, null, productCode);
152
+ expect(client).to.be.an('object');
153
+ expect(client.createEntitlement).to.be.a('function');
147
154
  });
148
155
 
149
- it('should throw error when organization has no getId method', () => {
156
+ it('should allow organization without getId (validation removed)', () => {
150
157
  const invalidOrg = { name: 'test' };
151
- expect(() => TierClient.createForOrg(mockContext, invalidOrg, productCode)).to.throw('Entity must be an instance of Organization');
158
+ const client = TierClient.createForOrg(mockContext, invalidOrg, productCode);
159
+ expect(client).to.be.an('object');
152
160
  });
153
161
 
154
162
  it('should throw error when context is invalid', () => {
@@ -194,12 +202,12 @@ describe('TierClient', () => {
194
202
  });
195
203
 
196
204
  it('should throw error when site is not provided', async () => {
197
- await expect(TierClient.createForSite(mockContext, null, productCode)).to.be.rejectedWith('Entity must be an instance of Site');
205
+ await expect(TierClient.createForSite(mockContext, null, productCode)).to.be.rejectedWith('Cannot read properties of null');
198
206
  });
199
207
 
200
208
  it('should throw error when site has no getId method', async () => {
201
209
  const invalidSite = { name: 'test' };
202
- await expect(TierClient.createForSite(mockContext, invalidSite, productCode)).to.be.rejectedWith('Entity must be an instance of Site');
210
+ await expect(TierClient.createForSite(mockContext, invalidSite, productCode)).to.be.rejectedWith('site.getOrganizationId is not a function');
203
211
  });
204
212
 
205
213
  it('should throw error when context is invalid', async () => {