@adobe/spacecat-shared-tier-client 1.3.11 → 1.3.12
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/.releaserc.cjs +6 -2
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/tier-client.js +7 -7
- package/test/tier-client.test.js +7 -18
package/.releaserc.cjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
extends: "semantic-release-monorepo",
|
|
3
3
|
plugins: [
|
|
4
|
-
"@semantic-release/commit-analyzer",
|
|
5
|
-
|
|
4
|
+
["@semantic-release/commit-analyzer", {
|
|
5
|
+
"preset": "conventionalcommits",
|
|
6
|
+
}],
|
|
7
|
+
["@semantic-release/release-notes-generator", {
|
|
8
|
+
"preset": "conventionalcommits",
|
|
9
|
+
}],
|
|
6
10
|
["@semantic-release/changelog", {
|
|
7
11
|
"changelogFile": "CHANGELOG.md",
|
|
8
12
|
}],
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [@adobe/spacecat-shared-tier-client-v1.3.12](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.11...@adobe/spacecat-shared-tier-client-v1.3.12) (2026-02-17)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **data-access:** decouple shared packages for v2/v3 alias wrapper rollout ([#1355](https://github.com/adobe/spacecat-shared/issues/1355)) ([ba48df7](https://github.com/adobe/spacecat-shared/commit/ba48df710e0030c1cb3ef4f90661cff1b548d42f))
|
|
6
|
+
|
|
1
7
|
# [@adobe/spacecat-shared-tier-client-v1.3.11](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.3.10...@adobe/spacecat-shared-tier-client-v1.3.11) (2026-02-06)
|
|
2
8
|
|
|
3
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-tier-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Tier Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@adobe/spacecat-shared-utils": "1.81.1",
|
|
39
|
-
"@
|
|
39
|
+
"@mysticat/data-service-types": "git+https://github.com/adobe/mysticat-data-service.git#types-ts-v1.11.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"c8": "10.1.3",
|
package/src/tier-client.js
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { isNonEmptyObject, hasText } from '@adobe/spacecat-shared-utils';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import { MYSTICAT_ENUMS_BY_TYPE } from '@mysticat/data-service-types';
|
|
15
|
+
|
|
16
|
+
const ENTITLEMENT_TIERS = MYSTICAT_ENUMS_BY_TYPE.ENTITLEMENT_TIER;
|
|
17
17
|
/**
|
|
18
18
|
* TierClient provides methods to manage entitlements and site enrollments.
|
|
19
19
|
*/
|
|
@@ -137,8 +137,8 @@ class TierClient {
|
|
|
137
137
|
*/
|
|
138
138
|
async createEntitlement(tier) {
|
|
139
139
|
try {
|
|
140
|
-
if (!Object.values(
|
|
141
|
-
throw new Error(`Invalid tier: ${tier}. Valid tiers: ${Object.values(
|
|
140
|
+
if (!Object.values(ENTITLEMENT_TIERS).includes(tier)) {
|
|
141
|
+
throw new Error(`Invalid tier: ${tier}. Valid tiers: ${Object.values(ENTITLEMENT_TIERS).join(', ')}`);
|
|
142
142
|
}
|
|
143
143
|
const orgId = this.organization.getId();
|
|
144
144
|
// Check what already exists
|
|
@@ -149,7 +149,7 @@ class TierClient {
|
|
|
149
149
|
const currentTier = existing.entitlement.getTier();
|
|
150
150
|
|
|
151
151
|
// If currentTier doesn't match with given tier and is not PAID, update it
|
|
152
|
-
if (currentTier !== tier && currentTier !==
|
|
152
|
+
if (currentTier !== tier && currentTier !== ENTITLEMENT_TIERS.PAID) {
|
|
153
153
|
existing.entitlement.setTier(tier);
|
|
154
154
|
await existing.entitlement.save();
|
|
155
155
|
}
|
|
@@ -314,7 +314,7 @@ class TierClient {
|
|
|
314
314
|
async revokeEntitlement() {
|
|
315
315
|
const existing = await this.checkValidEntitlement();
|
|
316
316
|
if (existing.entitlement) {
|
|
317
|
-
if (existing.entitlement.getTier() ===
|
|
317
|
+
if (existing.entitlement.getTier() === ENTITLEMENT_TIERS.PAID) {
|
|
318
318
|
throw new Error('Paid entitlement cannot be revoked');
|
|
319
319
|
}
|
|
320
320
|
await existing.entitlement.remove();
|
package/test/tier-client.test.js
CHANGED
|
@@ -17,7 +17,6 @@ import chaiAsPromised from 'chai-as-promised';
|
|
|
17
17
|
import sinonChai from 'sinon-chai';
|
|
18
18
|
import sinon from 'sinon';
|
|
19
19
|
|
|
20
|
-
import { Organization, Site } from '@adobe/spacecat-shared-data-access';
|
|
21
20
|
import TierClient from '../src/tier-client.js';
|
|
22
21
|
|
|
23
22
|
use(chaiAsPromised);
|
|
@@ -49,11 +48,7 @@ describe('TierClient', () => {
|
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
// Create actual Organization instance for instanceof checks
|
|
52
|
-
const organizationInstance =
|
|
53
|
-
Object.assign(
|
|
54
|
-
organizationInstance,
|
|
55
|
-
{ entityName: Organization.ENTITY_NAME, ...mockOrganization },
|
|
56
|
-
);
|
|
51
|
+
const organizationInstance = { ...mockOrganization };
|
|
57
52
|
|
|
58
53
|
const mockSite = {
|
|
59
54
|
getId: () => siteId,
|
|
@@ -62,8 +57,7 @@ describe('TierClient', () => {
|
|
|
62
57
|
};
|
|
63
58
|
|
|
64
59
|
// Create actual Site instance for instanceof checks
|
|
65
|
-
const siteInstance =
|
|
66
|
-
Object.assign(siteInstance, { entityName: Site.ENTITY_NAME, ...mockSite });
|
|
60
|
+
const siteInstance = { ...mockSite };
|
|
67
61
|
|
|
68
62
|
const mockDataAccess = {
|
|
69
63
|
Entitlement: {
|
|
@@ -121,23 +115,18 @@ describe('TierClient', () => {
|
|
|
121
115
|
});
|
|
122
116
|
|
|
123
117
|
describe('Static Factory Methods', () => {
|
|
124
|
-
const testOrganization =
|
|
125
|
-
Object.assign(testOrganization, { entityName: Organization.ENTITY_NAME, getId: () => orgId });
|
|
118
|
+
const testOrganization = { getId: () => orgId };
|
|
126
119
|
|
|
127
|
-
const testSite =
|
|
128
|
-
Object.assign(testSite, {
|
|
129
|
-
entityName: Site.ENTITY_NAME,
|
|
120
|
+
const testSite = {
|
|
130
121
|
getId: () => siteId,
|
|
131
122
|
getOrganizationId: () => orgId,
|
|
132
123
|
getOrganization: () => testOrganization,
|
|
133
|
-
}
|
|
124
|
+
};
|
|
134
125
|
|
|
135
|
-
const testSiteWithOrgRef =
|
|
136
|
-
Object.assign(testSiteWithOrgRef, {
|
|
137
|
-
entityName: Site.ENTITY_NAME,
|
|
126
|
+
const testSiteWithOrgRef = {
|
|
138
127
|
getId: () => siteId,
|
|
139
128
|
getOrganizationId: () => orgId,
|
|
140
|
-
}
|
|
129
|
+
};
|
|
141
130
|
|
|
142
131
|
describe('createForOrg', () => {
|
|
143
132
|
it('should create TierClient for organization', () => {
|