@i4e/invest4edu-access-core 0.17.0 → 0.17.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/package.json +1 -1
- package/src/entitlement.js +14 -1
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.1",
|
|
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.js
CHANGED
|
@@ -93,7 +93,20 @@ export function resolveEntitlementRow(rows = [], featureCode, now = new Date())
|
|
|
93
93
|
|
|
94
94
|
/** Apply a per-firm override on top of the plan row. Concessions live on the subscription. */
|
|
95
95
|
function withOverride(row, overrides = [], featureCode) {
|
|
96
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Two shapes in the wild, and getting this wrong is silent AND total.
|
|
98
|
+
*
|
|
99
|
+
* Everything that WRITES an override — the model, the admin API, the Subscribers view — uses an
|
|
100
|
+
* object map keyed by feature code. This function only understood an array, so `.find` on the
|
|
101
|
+
* object threw, `resolveEntitlement` failed open, and the subscriber stopped being metered
|
|
102
|
+
* altogether. Setting a per-customer allowance therefore disabled that customer's counting —
|
|
103
|
+
* the opposite of the intent, with no error anywhere.
|
|
104
|
+
*
|
|
105
|
+
* Both shapes are accepted now. The map is the canonical one.
|
|
106
|
+
*/
|
|
107
|
+
const o = Array.isArray(overrides)
|
|
108
|
+
? overrides.find((x) => x && x.feature_code === featureCode)
|
|
109
|
+
: (overrides && typeof overrides === "object" ? overrides[featureCode] : null);
|
|
97
110
|
if (!o) return row;
|
|
98
111
|
const merged = { ...row };
|
|
99
112
|
for (const k of ["unlocked", "quota", "period_granularity", "quota_scope", "overage_policy", "single_usage_price"]) {
|