@adobe/spacecat-shared-tier-client 1.0.0 → 1.0.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-tier-client-v1.0.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.0.0...@adobe/spacecat-shared-tier-client-v1.0.1) (2025-09-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix in create org entity ([#965](https://github.com/adobe/spacecat-shared/issues/965)) ([406cbf3](https://github.com/adobe/spacecat-shared/commit/406cbf3cd214f3ec3b332ca48d8a743c123a2ddd))
7
+
1
8
  # @adobe/spacecat-shared-tier-client-v1.0.0 (2025-09-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-tier-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared modules of the Spacecat Services - Tier Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -58,7 +58,8 @@ class TierClient {
58
58
  if (!isNonEmptyObject(context)) {
59
59
  throw new Error('Context is required');
60
60
  }
61
- const organization = await site.getOrganization();
61
+ const organizationId = await site.getOrganizationId();
62
+ const organization = await context.dataAccess.Organization.findById(organizationId);
62
63
  return new TierClient(context, organization, site, productCode);
63
64
  }
64
65
 
@@ -128,7 +128,7 @@ describe('TierClient', () => {
128
128
  const testSiteWithOrgRef = Object.create(Site.prototype);
129
129
  Object.assign(testSiteWithOrgRef, {
130
130
  getId: () => siteId,
131
- getOrganization: () => testOrganization,
131
+ getOrganizationId: () => orgId,
132
132
  });
133
133
 
134
134
  describe('createForOrg', () => {
@@ -165,19 +165,23 @@ describe('TierClient', () => {
165
165
 
166
166
  describe('createForSite', () => {
167
167
  it('should create TierClient for site with getOrganizationId', async () => {
168
+ mockDataAccess.Organization.findById.resolves(testOrganization);
168
169
  const client = await TierClient.createForSite(mockContext, testSite, productCode);
169
170
 
170
171
  expect(client).to.be.an('object');
171
172
  expect(client.checkValidEntitlement).to.be.a('function');
172
173
  expect(client.createEntitlement).to.be.a('function');
174
+ expect(mockDataAccess.Organization.findById).to.have.been.calledWith(orgId);
173
175
  });
174
176
 
175
- it('should create TierClient for site with getOrganization', async () => {
177
+ it('should create TierClient for site with getOrganizationId (alternative)', async () => {
178
+ mockDataAccess.Organization.findById.resolves(testOrganization);
176
179
  const client = await TierClient.createForSite(mockContext, testSiteWithOrgRef, productCode);
177
180
 
178
181
  expect(client).to.be.an('object');
179
182
  expect(client.checkValidEntitlement).to.be.a('function');
180
183
  expect(client.createEntitlement).to.be.a('function');
184
+ expect(mockDataAccess.Organization.findById).to.have.been.calledWith(orgId);
181
185
  });
182
186
 
183
187
  it('should throw error when site is not provided', async () => {
@@ -199,7 +203,7 @@ describe('TierClient', () => {
199
203
 
200
204
  it('should throw error when dataAccess is missing', async () => {
201
205
  const invalidContext = { log: {} };
202
- await expect(TierClient.createForSite(invalidContext, testSite, productCode)).to.be.rejectedWith('Cannot destructure property');
206
+ await expect(TierClient.createForSite(invalidContext, testSite, productCode)).to.be.rejectedWith('Cannot read properties of undefined');
203
207
  });
204
208
  });
205
209
  });