@adobe/spacecat-shared-tier-client 1.1.0 → 1.1.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 +3 -3
- package/src/tier-client.js +0 -22
- package/test/tier-client.test.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-tier-client-v1.1.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.1.1...@adobe/spacecat-shared-tier-client-v1.1.2) (2025-09-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* move logs to debug ([#982](https://github.com/adobe/spacecat-shared/issues/982)) ([7a78c6e](https://github.com/adobe/spacecat-shared/commit/7a78c6ee011bbc8adf162644153170d3ebf29c83))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-tier-client-v1.1.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.1.0...@adobe/spacecat-shared-tier-client-v1.1.1) (2025-09-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update external major (major) ([#974](https://github.com/adobe/spacecat-shared/issues/974)) ([994e488](https://github.com/adobe/spacecat-shared/commit/994e488e04fa44585b8d41a6daa9c7f86f1cee37))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-tier-client-v1.1.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-tier-client-v1.0.1...@adobe/spacecat-shared-tier-client-v1.1.0) (2025-09-22)
|
|
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.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Tier Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"c8": "10.1.3",
|
|
43
|
-
"chai": "
|
|
43
|
+
"chai": "6.0.1",
|
|
44
44
|
"chai-as-promised": "8.0.2",
|
|
45
45
|
"mocha": "11.7.2",
|
|
46
46
|
"mocha-multi-reporters": "1.5.1",
|
|
47
|
-
"sinon": "
|
|
47
|
+
"sinon": "21.0.0",
|
|
48
48
|
"sinon-chai": "4.0.1",
|
|
49
49
|
"typescript": "5.9.2"
|
|
50
50
|
}
|
package/src/tier-client.js
CHANGED
|
@@ -104,41 +104,28 @@ class TierClient {
|
|
|
104
104
|
async checkValidEntitlement() {
|
|
105
105
|
try {
|
|
106
106
|
const orgId = this.organization.getId();
|
|
107
|
-
this.log.info(`Checking for valid entitlement for org ${orgId} and product ${this.productCode}`);
|
|
108
|
-
|
|
109
107
|
const entitlement = await this.Entitlement
|
|
110
108
|
.findByOrganizationIdAndProductCode(orgId, this.productCode);
|
|
111
109
|
|
|
112
110
|
if (!entitlement) {
|
|
113
|
-
this.log.info(`No valid entitlement found for org ${orgId} and product ${this.productCode}`);
|
|
114
111
|
return {};
|
|
115
112
|
}
|
|
116
|
-
|
|
117
|
-
this.log.info(`Found valid entitlement: ${entitlement.getId()}`);
|
|
118
|
-
|
|
119
113
|
// Only check for site enrollment if site is provided
|
|
120
114
|
if (this.site) {
|
|
121
115
|
const siteId = this.site.getId();
|
|
122
|
-
this.log.info(`Checking for valid site enrollment for site ${siteId} and entitlement ${entitlement.getId()}`);
|
|
123
|
-
|
|
124
116
|
const siteEnrollments = await this.SiteEnrollment.allBySiteId(siteId);
|
|
125
117
|
const validSiteEnrollment = siteEnrollments.find(
|
|
126
118
|
(se) => se.getEntitlementId() === entitlement.getId(),
|
|
127
119
|
);
|
|
128
120
|
|
|
129
121
|
if (!validSiteEnrollment) {
|
|
130
|
-
this.log.info(`No valid site enrollment found for site ${siteId} and entitlement ${entitlement.getId()}`);
|
|
131
122
|
return { entitlement };
|
|
132
123
|
}
|
|
133
|
-
|
|
134
|
-
this.log.info(`Found valid site enrollment: ${validSiteEnrollment.getId()}`);
|
|
135
|
-
|
|
136
124
|
return {
|
|
137
125
|
entitlement,
|
|
138
126
|
siteEnrollment: validSiteEnrollment,
|
|
139
127
|
};
|
|
140
128
|
} else {
|
|
141
|
-
this.log.info(`No site provided, returning entitlement only for org ${orgId}`);
|
|
142
129
|
return { entitlement };
|
|
143
130
|
}
|
|
144
131
|
} catch (error) {
|
|
@@ -159,10 +146,7 @@ class TierClient {
|
|
|
159
146
|
if (!Object.values(EntitlementModel.TIERS).includes(tier)) {
|
|
160
147
|
throw new Error(`Invalid tier: ${tier}. Valid tiers: ${Object.values(EntitlementModel.TIERS).join(', ')}`);
|
|
161
148
|
}
|
|
162
|
-
|
|
163
149
|
const orgId = this.organization.getId();
|
|
164
|
-
this.log.info(`Creating/updating entitlement for org ${orgId}, product ${this.productCode}, tier ${tier}`);
|
|
165
|
-
|
|
166
150
|
// Check what already exists
|
|
167
151
|
const existing = await this.checkValidEntitlement();
|
|
168
152
|
|
|
@@ -172,7 +156,6 @@ class TierClient {
|
|
|
172
156
|
|
|
173
157
|
// If tier doesn't match, update it
|
|
174
158
|
if (currentTier !== tier) {
|
|
175
|
-
this.log.info(`Updating entitlement tier from ${currentTier} to ${tier} for org ${orgId}`);
|
|
176
159
|
existing.entitlement.setTier(tier);
|
|
177
160
|
await existing.entitlement.save();
|
|
178
161
|
}
|
|
@@ -184,7 +167,6 @@ class TierClient {
|
|
|
184
167
|
siteId,
|
|
185
168
|
entitlementId: existing.entitlement.getId(),
|
|
186
169
|
});
|
|
187
|
-
this.log.info(`Created site enrollment: ${siteEnrollment.getId()}`);
|
|
188
170
|
return {
|
|
189
171
|
entitlement: existing.entitlement,
|
|
190
172
|
siteEnrollment,
|
|
@@ -205,8 +187,6 @@ class TierClient {
|
|
|
205
187
|
},
|
|
206
188
|
});
|
|
207
189
|
|
|
208
|
-
this.log.info(`Created new entitlement: ${entitlement.getId()}`);
|
|
209
|
-
|
|
210
190
|
// If no site provided, return entitlement only
|
|
211
191
|
if (!this.site) {
|
|
212
192
|
return { entitlement };
|
|
@@ -219,8 +199,6 @@ class TierClient {
|
|
|
219
199
|
entitlementId: entitlement.getId(),
|
|
220
200
|
});
|
|
221
201
|
|
|
222
|
-
this.log.info(`Created site enrollment: ${siteEnrollment.getId()}`);
|
|
223
|
-
|
|
224
202
|
return {
|
|
225
203
|
entitlement,
|
|
226
204
|
siteEnrollment,
|