@happyvertical/smrt-users 0.60.18 → 0.61.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.
@@ -115,6 +115,15 @@ STI base's), so an STI subtype resolves its STI base's collection
115
115
  bundle decorated before its manifest loads (#3125). Hand-written mutations in form
116
116
  handlers, endpoints, CLI and jobs use assertOperationPermission(). It requires
117
117
  catalog presence then resolves permissions, throwing fail-closed by default.
118
+ Shared STI CRUD catalog entries name the effective base model, independent of
119
+ registration order. Subtypes cannot overwrite `profiles.create` (formerly Bot
120
+ when Bot registered last). An explicit child collection keeps its own CRUD,
121
+ and deeper descendants sharing that namespace cannot replace its owner;
122
+ child custom actions and field permissions are still catalogued. Same-name app
123
+ replacements supply the effective base identity through the public registry.
124
+ `sti-create-dispatch.test.ts` exercises real Profile/Bot and a generic family
125
+ through REST, MCP, CLI's create handler and assistant manifest dispatch on SQLite;
126
+ `permission-catalog.test.ts` checks reversed order and app replacement metadata.
118
127
  Use onDeny: 'return', checkOperationPermission or hasOperationPermission only
119
128
  when the caller handles a structured/boolean denial.
120
129
 
@@ -230,3 +239,13 @@ introduced. Metadata registration and catalog sync do not grant a user, role,
230
239
  tenant or resource permission. Existing persisted grants/current authority checks
231
240
  remain required. Use the public portable entry rather than private service paths
232
241
  when a model package needs declarations without the server runtime.
242
+
243
+ ### Runtime resource discovery imports
244
+
245
+ `src/sveltekit/resource-list-handler.ts` imports shared action/name policy from
246
+ `@happyvertical/smrt-core/api-actions`, not the Vite-plugin barrel. This is the
247
+ same implementation re-exported by the route generator; permissions, wireability,
248
+ custom-action receiver resolution and paths are unchanged. The existing resource
249
+ handler suite retains positive and refusal coverage, and its fresh-Node published
250
+ entry guard rejects Vite route-emitter/activation-generator loads. No SQL executor,
251
+ transaction, authentication or tenant-boundary behavior changes in this import fix.
@@ -2715,8 +2715,14 @@ var PermissionCatalogService = class PermissionCatalogService {
2715
2715
  const qualifiedName = registered.qualifiedName;
2716
2716
  const objectConfig = manifestEntry?.decoratorConfig ?? registered.config;
2717
2717
  const collection = resolveCatalogCollectionName(registered, manifestEntry);
2718
+ const registryKey = qualifiedName ?? className;
2719
+ const ownsCrud = !ObjectRegistry.getSTIBase(registryKey) || !ObjectRegistry.getInheritanceChain(registryKey).some((ancestor) => {
2720
+ const parent = ObjectRegistry.getClass(ancestor);
2721
+ return parent && parent !== registered && resolveCatalogCollectionName(parent, manifestEntryFor(parent)) === collection;
2722
+ });
2718
2723
  const catalogCliConfig = qualifiedName && USERS_AUTHORITY_CATALOG_MODELS.has(qualifiedName) ? true : objectConfig.cli;
2719
- if (isOperationEnabled(objectConfig.api, "list") || isOperationEnabled(objectConfig.api, "get") || isOperationEnabled(catalogCliConfig, "list") || isOperationEnabled(catalogCliConfig, "get") || isOperationEnabled(objectConfig.mcp, "list") || isOperationEnabled(objectConfig.mcp, "get")) definitions.set(`${collection}.read`, {
2724
+ const readExposed = isOperationEnabled(objectConfig.api, "list") || isOperationEnabled(objectConfig.api, "get") || isOperationEnabled(catalogCliConfig, "list") || isOperationEnabled(catalogCliConfig, "get") || isOperationEnabled(objectConfig.mcp, "list") || isOperationEnabled(objectConfig.mcp, "get");
2725
+ if (ownsCrud && readExposed) definitions.set(`${collection}.read`, {
2720
2726
  ...definitions.get(`${collection}.read`),
2721
2727
  className,
2722
2728
  collection,
@@ -2742,7 +2748,8 @@ var PermissionCatalogService = class PermissionCatalogService {
2742
2748
  "update",
2743
2749
  "delete"
2744
2750
  ]) {
2745
- if (!(isOperationEnabled(objectConfig.api, action) || isOperationEnabled(catalogCliConfig, action) || isOperationEnabled(objectConfig.mcp, action))) continue;
2751
+ const exposed = isOperationEnabled(objectConfig.api, action) || isOperationEnabled(catalogCliConfig, action) || isOperationEnabled(objectConfig.mcp, action);
2752
+ if (!ownsCrud || !exposed) continue;
2746
2753
  definitions.set(`${collection}.${action}`, {
2747
2754
  ...definitions.get(`${collection}.${action}`),
2748
2755
  className,
@@ -3047,6 +3054,38 @@ var RolePermissionCollection = class RolePermissionCollection extends SmrtCollec
3047
3054
  return result;
3048
3055
  }
3049
3056
  /**
3057
+ * Upgrade path for permissions registered after a role was seeded: grant
3058
+ * each catalog slug that has NO Permission row yet to the named system
3059
+ * roles (default: `owner`), per the default matrix. A slug already in the
3060
+ * Permission table is never touched, so a grant an operator removed from a
3061
+ * role is not re-added, and no other role changes. Idempotent: once the new
3062
+ * slugs have rows, a rerun finds nothing and writes nothing.
3063
+ *
3064
+ * Returns the slugs it introduced (empty when the catalog is unchanged).
3065
+ */
3066
+ async seedNewCatalogPermissions(options = {}) {
3067
+ const roleSlugs = options.roleSlugs ?? [DEFAULT_ROLE_SLUGS.OWNER];
3068
+ const catalog = PermissionCatalogService.create(this.options).getCatalog();
3069
+ const permissions = await PermissionCollection.create(withoutListBounds(this.options));
3070
+ const known = new Set((await permissions.list({})).map((permission) => permission.slug));
3071
+ const fresh = catalog.permissions.filter((permission) => !known.has(permission.slug));
3072
+ if (fresh.length === 0) return [];
3073
+ const matrix = {};
3074
+ for (const slug of roleSlugs) {
3075
+ const patterns = DEFAULT_ROLE_PERMISSION_PATTERNS[slug];
3076
+ if (patterns) matrix[slug] = [...patterns];
3077
+ }
3078
+ await this.seedRolePermissions(matrix, {
3079
+ catalog: {
3080
+ ...catalog,
3081
+ permissions: fresh
3082
+ },
3083
+ syncCatalog: true,
3084
+ systemRolesOnly: true
3085
+ });
3086
+ return fresh.map((permission) => permission.slug);
3087
+ }
3088
+ /**
3050
3089
  * Add the catalog-registered self-personalization grant to existing built-in
3051
3090
  * roles. This is the explicit, idempotent upgrade path for applications
3052
3091
  * whose roles predate the Fields permission; custom role matrices are never
@@ -6321,4 +6360,4 @@ var PasswordCredentialService = class PasswordCredentialService {
6321
6360
  //#endregion
6322
6361
  export { PermissionCatalogService as $, InvalidCredentialsError as A, STEP_UP_SIGN_IN_AUTH_METHODS as At, backfillUserEmailKeys as B, DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS as C, SessionCollection as Ct, DEFAULT_LOGIN_MAX_ATTEMPTS as D, normalizeUsername as Dt, DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS as E, normalizeEmail as Et, OidcProvisioningError as F, Membership as Ft, MAX_TENANT_HIERARCHY_DEPTH as G, TenantPermissionOverride as H, UserCollection as I, __exportAll as It, assertTenantTableName as J, TenantHierarchyError as K, requireExistingOwnedPerson as L, LoginRateLimitError as M, generateSessionId as Mt, hashSecret as N, Role as Nt, DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS as O, DEFAULT_SESSION_TTL as Ot, verifySecretHash as P, Permission as Pt, RolePermissionCollection as Q, USER_EMAIL_KEY_BACKFILL_NAME as R, normalizeAncestorReadPolicy as S, UsersLoginAttempt as St, DEFAULT_LOGIN_LOCKOUT_FACTOR as T, isValidEmail as Tt, TenantCollection as U, TenantPermissionOverrideCollection as V, Tenant as W, recordTenantHierarchyChanges as X, planTenantHierarchy as Y, DEFAULT_ROLE_PERMISSION_PATTERNS as Z, PermissionResolver as _, GroupCollection as _t, DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS as a, RolePermission as at, getConfiguredAncestorReadPolicy as b, UsersLoginAuditEvent as bt, PASSWORD_PERMISSION_DEFINITIONS as c, UsersPasswordCredentialCollection as ct, PasswordCredentialForbiddenError as d, MembershipOverride as dt, deriveOperationPermissionCollectionName as et, PasswordCredentialService as f, MembershipCollection as ft, SessionService as g, GroupMember as gt, outOfBandProofSessionData as h, GroupMemberCollection as ht, DEFAULT_PASSWORD_MIN_LENGTH as i, withoutListBounds as it, LoginAttemptLimiter as j, Session as jt, DurableLoginAuditSink as k, SESSION_DATA_KEYS as kt, PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS as l, UsersPasswordCredential as lt, ensurePasswordPermissionsRegistered as m, GroupRole as mt, DEFAULT_PASSWORD_MANAGE_PERMISSION as n, normalizeOperationPermissionAction as nt, PASSWORD_LOGIN_KIND as o, RoleCollection as ot, PasswordPolicyError as p, GroupRoleCollection as pt, applyTenantHierarchyUpdates as q, DEFAULT_PASSWORD_MAX_LENGTH as r, syncPermissionCatalog as rt, PASSWORD_MAX_LENGTH_CEILING as s, PermissionCollection as st, DEFAULT_PASSWORD_DENYLIST as t, deriveOperationPermissionSlug as tt, PasswordCredentialError as u, MembershipOverrideCollection as ut, ANCESTOR_READ_ACTION as v, Group as vt, DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS as w, User as wt, isAncestorReadableSlug as x, UsersLoginAttemptCollection as xt, DEFAULT_ANCESTOR_READ_MAX_DEPTH as y, UsersLoginAuditEventCollection as yt, UserEmailKeyBackfillError as z };
6323
6362
 
6324
- //# sourceMappingURL=PasswordCredentialService-D_evcc-I.js.map
6363
+ //# sourceMappingURL=PasswordCredentialService-CYBl9GAn.js.map