@i4e/invest4edu-access-core 0.17.1 → 0.17.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i4e/invest4edu-access-core",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"description": "Shared access-control primitives for NeoFindesk: tenant keystone, role capabilities, reportee tree, feature flags, and the unified access engine (registry schema, snapshot resolver, visibleWhen).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/entitlement-store.js
CHANGED
|
@@ -155,8 +155,20 @@ export function createEntitlementStore({ getDb, toObjectId = (v) => v, logger =
|
|
|
155
155
|
subscription, entitlementRows: rows, featureCode, feature, used, credits, identity, bypass, now,
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Carry what consume() needs, so it cannot recompute the period key and count against a
|
|
160
|
+
* different bucket than the one that was just checked.
|
|
161
|
+
*
|
|
162
|
+
* The carried row takes its ceiling from the RESOLVED result, not from the raw plan row —
|
|
163
|
+
* because a per-subject override changes the decision without changing the row it came
|
|
164
|
+
* from. Carrying the raw row meant consume guarded on the plan's quota while the check had
|
|
165
|
+
* already passed on the overridden one: a subject granted 5 was refused at 2, and it
|
|
166
|
+
* surfaced as a counter that had simply stopped moving.
|
|
167
|
+
*/
|
|
168
|
+
const effectiveRow = row
|
|
169
|
+
? { ...row, quota: result.quota, overage_policy: result.overage_policy || row.overage_policy }
|
|
170
|
+
: null;
|
|
171
|
+
|
|
160
172
|
return {
|
|
161
173
|
...result,
|
|
162
174
|
carriedSubjectType: subjectType,
|
|
@@ -164,7 +176,7 @@ export function createEntitlementStore({ getDb, toObjectId = (v) => v, logger =
|
|
|
164
176
|
carriedSubscriptionId: subscription._id,
|
|
165
177
|
carriedPeriodStart: subscription.period_start || null,
|
|
166
178
|
carriedIdentity: identity,
|
|
167
|
-
carriedRow:
|
|
179
|
+
carriedRow: effectiveRow,
|
|
168
180
|
};
|
|
169
181
|
} catch (e) {
|
|
170
182
|
logger.warn(`[entitlement] resolve failed for ${featureCode}, allowing through: ${e.message}`);
|
|
@@ -67,6 +67,9 @@ export const SUBSCRIPTION_EVENT_TYPES = Object.freeze([
|
|
|
67
67
|
"status_changed", "cancelled", "blocked", "expired",
|
|
68
68
|
"payment_captured", "payment_failed",
|
|
69
69
|
"quota_exceeded",
|
|
70
|
+
// Consumption that happened outside the software — a webinar attended, a VPD session held.
|
|
71
|
+
// There is no request behind it, so this event is the only record of who said it happened.
|
|
72
|
+
"usage_recorded",
|
|
70
73
|
]);
|
|
71
74
|
|
|
72
75
|
export default { SUBSCRIPTION_STATUSES, LIVE_STATUSES, TRANSITIONS, canTransition, SUBSCRIPTION_EVENT_TYPES };
|