@happyvertical/smrt-users 0.36.0 → 0.36.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.
Files changed (46) hide show
  1. package/dist/chunks/{TerminalAuthService-D5VVPG9e.js → TerminalAuthService-bY1oWeAh.js} +18 -33
  2. package/dist/chunks/TerminalAuthService-bY1oWeAh.js.map +1 -0
  3. package/dist/chunks/{index-CitgZk-4.js → index-DBpq-WMK.js} +3 -3
  4. package/dist/chunks/{index-CitgZk-4.js.map → index-DBpq-WMK.js.map} +1 -1
  5. package/dist/collections/GroupMemberCollection.d.ts.map +1 -1
  6. package/dist/collections/TenantCollection.d.ts +5 -4
  7. package/dist/collections/TenantCollection.d.ts.map +1 -1
  8. package/dist/index.js +7 -13
  9. package/dist/index.js.map +1 -1
  10. package/dist/manifest.json +3 -3
  11. package/dist/models/Group.d.ts +10 -2
  12. package/dist/models/Group.d.ts.map +1 -1
  13. package/dist/models/GroupMember.d.ts +9 -2
  14. package/dist/models/GroupMember.d.ts.map +1 -1
  15. package/dist/models/GroupRole.d.ts +9 -2
  16. package/dist/models/GroupRole.d.ts.map +1 -1
  17. package/dist/models/MagicLinkToken.d.ts +12 -2
  18. package/dist/models/MagicLinkToken.d.ts.map +1 -1
  19. package/dist/models/Membership.d.ts +11 -2
  20. package/dist/models/Membership.d.ts.map +1 -1
  21. package/dist/models/MembershipOverride.d.ts +10 -2
  22. package/dist/models/MembershipOverride.d.ts.map +1 -1
  23. package/dist/models/Permission.d.ts +10 -2
  24. package/dist/models/Permission.d.ts.map +1 -1
  25. package/dist/models/Role.d.ts +11 -2
  26. package/dist/models/Role.d.ts.map +1 -1
  27. package/dist/models/RolePermission.d.ts +9 -2
  28. package/dist/models/RolePermission.d.ts.map +1 -1
  29. package/dist/models/Session.d.ts +17 -2
  30. package/dist/models/Session.d.ts.map +1 -1
  31. package/dist/models/Tenant.d.ts +15 -2
  32. package/dist/models/Tenant.d.ts.map +1 -1
  33. package/dist/models/TenantPermissionOverride.d.ts +10 -2
  34. package/dist/models/TenantPermissionOverride.d.ts.map +1 -1
  35. package/dist/models/User.d.ts +11 -2
  36. package/dist/models/User.d.ts.map +1 -1
  37. package/dist/services/MagicLinkService.d.ts.map +1 -1
  38. package/dist/services/PermissionResolver.d.ts +2 -6
  39. package/dist/services/PermissionResolver.d.ts.map +1 -1
  40. package/dist/services/SessionService.d.ts.map +1 -1
  41. package/dist/services/TenantService.d.ts.map +1 -1
  42. package/dist/services/TerminalAuthService.d.ts.map +1 -1
  43. package/dist/smrt-knowledge.json +4 -4
  44. package/dist/sveltekit.js +1 -1
  45. package/package.json +8 -8
  46. package/dist/chunks/TerminalAuthService-D5VVPG9e.js.map +0 -1
@@ -289,7 +289,9 @@ class GroupMemberCollection extends SmrtCollection {
289
289
  WHERE gm.user_id = ? AND g.tenant_id = ?
290
290
  `;
291
291
  const result = await this.db.query(sql, userId, tenantId);
292
- return result.rows.map((r) => r.group_id);
292
+ return result.rows.map(
293
+ (r) => r.group_id
294
+ );
293
295
  }
294
296
  /**
295
297
  * Get user IDs in a group
@@ -1551,7 +1553,7 @@ class TenantCollection extends SmrtCollection {
1551
1553
  */
1552
1554
  async createChild(parentTenantId, options) {
1553
1555
  const parent = await this.get({ id: parentTenantId });
1554
- if (!parent) {
1556
+ if (!parent?.id) {
1555
1557
  throw new TenantHierarchyError(
1556
1558
  `Parent tenant not found: ${parentTenantId}`,
1557
1559
  "PARENT_NOT_FOUND"
@@ -1733,15 +1735,16 @@ class TenantCollection extends SmrtCollection {
1733
1735
  // ============= Override create to handle hierarchy =============
1734
1736
  /**
1735
1737
  * Override create to automatically set hierarchy fields for new tenants.
1736
- * Only calculates hierarchy fields if not already provided (preserves
1737
- * database values during hydration via get()).
1738
+ * Only calculates them when the caller hasn't already supplied
1739
+ * `hierarchyLevel`/`hierarchyPath` in the create input — an explicitly
1740
+ * provided value is preserved as-is.
1738
1741
  */
1739
1742
  async create(options) {
1740
1743
  if (options.parentTenantId) {
1741
1744
  const needsHierarchyCalc = options.hierarchyLevel === void 0 || options.hierarchyPath === void 0;
1742
1745
  if (needsHierarchyCalc) {
1743
1746
  const parent = await this.get({ id: options.parentTenantId });
1744
- if (!parent) {
1747
+ if (!parent?.id) {
1745
1748
  throw new TenantHierarchyError(
1746
1749
  `Parent tenant not found: ${options.parentTenantId}`,
1747
1750
  "PARENT_NOT_FOUND"
@@ -4250,31 +4253,17 @@ class PermissionResolver {
4250
4253
  /**
4251
4254
  * Initialize collections
4252
4255
  *
4253
- * Note: The `as any` casts are required because `SmrtCollection.create()` is
4254
- * declared with a protected constructor and a static factory. TypeScript
4255
- * cannot infer that the static `create()` returns the concrete subclass type
4256
- * when invoked through a subclass reference, so the cast is needed to call
4257
- * `create(options)` on each collection. This is a known SMRT framework
4258
- * limitation around the protected-constructor + static-factory pattern.
4256
+ * Each collection is created via the inherited static `SmrtCollection.create()`
4257
+ * factory, which is generically typed to return the concrete subclass instance.
4259
4258
  */
4260
4259
  async initialize() {
4261
- this.membershipCollection = await MembershipCollection.create(
4262
- this.options
4263
- );
4260
+ this.membershipCollection = await MembershipCollection.create(this.options);
4264
4261
  this.rolePermissionCollection = await RolePermissionCollection.create(this.options);
4265
4262
  this.membershipOverrideCollection = await MembershipOverrideCollection.create(this.options);
4266
- this.groupMemberCollection = await GroupMemberCollection.create(
4267
- this.options
4268
- );
4269
- this.groupRoleCollection = await GroupRoleCollection.create(
4270
- this.options
4271
- );
4272
- this.permissionCollection = await PermissionCollection.create(
4273
- this.options
4274
- );
4275
- this.tenantCollection = await TenantCollection.create(
4276
- this.options
4277
- );
4263
+ this.groupMemberCollection = await GroupMemberCollection.create(this.options);
4264
+ this.groupRoleCollection = await GroupRoleCollection.create(this.options);
4265
+ this.permissionCollection = await PermissionCollection.create(this.options);
4266
+ this.tenantCollection = await TenantCollection.create(this.options);
4278
4267
  this.tenantPermissionOverrideCollection = await TenantPermissionOverrideCollection.create(this.options);
4279
4268
  }
4280
4269
  // ============= Tenant Hierarchy Permission Resolution =============
@@ -4570,13 +4559,9 @@ class SessionService {
4570
4559
  * Initialize collections
4571
4560
  */
4572
4561
  async initialize() {
4573
- this.sessionCollection = await SessionCollection.create(
4574
- this.options
4575
- );
4562
+ this.sessionCollection = await SessionCollection.create(this.options);
4576
4563
  this.userCollection = await UserCollection.create(this.options);
4577
- this.membershipCollection = await MembershipCollection.create(
4578
- this.options
4579
- );
4564
+ this.membershipCollection = await MembershipCollection.create(this.options);
4580
4565
  this.permissionResolver = await PermissionResolver.create(this.options);
4581
4566
  }
4582
4567
  /**
@@ -5273,4 +5258,4 @@ export {
5273
5258
  SessionCollection as y,
5274
5259
  SessionService as z
5275
5260
  };
5276
- //# sourceMappingURL=TerminalAuthService-D5VVPG9e.js.map
5261
+ //# sourceMappingURL=TerminalAuthService-bY1oWeAh.js.map