mnfst 0.5.143 → 0.5.144

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.
@@ -5525,29 +5525,43 @@ function initializeTeamsConvenience() {
5525
5525
  return userRoles.includes('owner');
5526
5526
  };
5527
5527
 
5528
- // Synchronous version for Alpine.js bindings (uses permission cache)
5528
+ // Synchronous version for Alpine.js bindings (x-show / :disabled).
5529
+ // Resolves from the cached role definitions (allTeamRoles) so it matches
5530
+ // the async hasTeamPermission() — including custom permission keys, not
5531
+ // just the six built-ins the permission cache pre-computes.
5529
5532
  store.hasTeamPermissionSync = function (permission) {
5530
5533
  if (!this.currentTeam || !this.currentTeamMemberships || !this.user) {
5531
5534
  return false;
5532
5535
  }
5533
5536
 
5534
- // Use cached permissions if available (updated by updatePermissionCache)
5535
- if (this._permissionCache && typeof this._permissionCache[permission] === 'boolean') {
5536
- return this._permissionCache[permission];
5537
+ const userRoles = this.getCurrentTeamRoles();
5538
+ if (!Array.isArray(userRoles)) {
5539
+ return false;
5537
5540
  }
5538
5541
 
5539
- // Fallback: check if user has no custom roles (should have all permissions)
5540
- // This matches the logic in hasPermission: if customRoles.length === 0, return true
5541
- const userRoles = this.getCurrentTeamRoles();
5542
- const customRoles = userRoles.filter(role => role !== 'owner');
5542
+ // The merged config + user-generated role map for the current team
5543
+ // (same map the async path resolves against), available synchronously.
5544
+ const allRoles = (this.allTeamRoles && this.allTeamRoles(this.currentTeam)) || {};
5543
5545
 
5544
- // If user has no custom roles (only "owner" or empty), grant all permissions
5545
- // This handles users with "No Role" who should have all owner permissions
5546
+ // No custom roles defined owner has every permission.
5547
+ if (!allRoles || Object.keys(allRoles).length === 0) {
5548
+ return userRoles.includes('owner');
5549
+ }
5550
+
5551
+ // User holds no custom role (only "owner" / empty) → all permissions.
5552
+ const customRoles = userRoles.filter(role => role !== 'owner');
5546
5553
  if (customRoles.length === 0) {
5547
5554
  return true;
5548
5555
  }
5549
5556
 
5550
- // If user has custom roles but cache is missing, return false (shouldn't happen if cache is working)
5557
+ // Granted if any of the user's custom roles includes this permission
5558
+ // (built-in or custom key).
5559
+ for (const roleName of customRoles) {
5560
+ const rolePermissions = allRoles[roleName];
5561
+ if (Array.isArray(rolePermissions) && rolePermissions.includes(permission)) {
5562
+ return true;
5563
+ }
5564
+ }
5551
5565
  return false;
5552
5566
  };
5553
5567
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "manifest.appwrite.auth.js": "sha384-9XC7lR7xBSDktRSQ2OVjcDOZ5NT3IPzdfmGO3Rv4x37uAvrzfi20xER0Renn5MTj",
2
+ "manifest.appwrite.auth.js": "sha384-/IbcczrhhYWlsQFvFmHkulV1JPIBBFvMH513PwsnJo+D0F+YKhGJ1ig/UmJbGSe/",
3
3
  "manifest.appwrite.data.js": "sha384-00ulLT+GAIuPHA/rRT9p98vYlsyDzkyKXtg86BDQ6FGQa5vVVN+W6kuforniBAsz",
4
4
  "manifest.appwrite.presence.js": "sha384-uxRpx9/Jj0kGtklH5QmUlAzD3zdSvFRfK6bcJQqxl+Bsf5tOo4zgwqJTQgtZoHQP",
5
5
  "manifest.charts.js": "sha384-RuV7gWXt3s+JegxWgDieR/P5U99sbOYWiYHdJGe2uCJjDFU1cPp0mJ1QT55ec9uz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.143",
3
+ "version": "0.5.144",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",