refactor: rename duplicate AdminRole interface, type sellerId as UUID
AdminRole was defined twice with unrelated shapes (core/auth's real JWT role union vs. the Users admin page's display interface), flagged in BACKEND-API-REFERENCE.md \u00a72b as needing a rename. Renamed the Users-page one to AdminUserRoleRecord. sellerId was bare string in admin-order/admin-product/item models while core/sellers/models/seller-scope.model.ts already used the shared UUID alias. Aligned all three to UUID for consistency (UUID is currently just = string, so this is a documentation-level type change, not a behavior change). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { UUID } from '../../../../shared/types/primitive.types';
|
||||
|
||||
export type AdminOrderStatus = 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
|
||||
export type AdminOrderPaymentStatus = 'unpaid' | 'paid' | 'refund_requested' | 'refunded';
|
||||
|
||||
@@ -57,7 +59,7 @@ export interface AdminOrder {
|
||||
* Absent means marketplace-owned, exactly like every order today -
|
||||
* nothing reads this field yet, no behavior change.
|
||||
*/
|
||||
sellerId?: string;
|
||||
sellerId?: UUID;
|
||||
}
|
||||
|
||||
export interface AdminOrderListFilters {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { UUID } from '../../../../shared/types/primitive.types';
|
||||
|
||||
export type AdminProductStockStatus = 'in_stock' | 'low_stock' | 'out_of_stock';
|
||||
export type AdminProductSort = 'title' | 'price' | 'priority' | 'stock' | 'updated';
|
||||
export type AdminProductEditorMode = 'create' | 'edit' | 'duplicate';
|
||||
@@ -117,7 +119,7 @@ export interface AdminProduct {
|
||||
* Absent means marketplace-owned, exactly like every product today -
|
||||
* nothing reads this field yet, nothing breaks by it being undefined.
|
||||
*/
|
||||
sellerId?: string;
|
||||
sellerId?: UUID;
|
||||
}
|
||||
|
||||
export interface AdminProductListFilters {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable, inject, signal } from '@angular/core';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { AdminInvitation, AdminRole, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
import { AdminInvitation, AdminUserRoleRecord, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
import { AdminUsersLocalGateway } from '../services/admin-users-local.gateway';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -8,7 +8,7 @@ export class AdminUsersFacade {
|
||||
private readonly gateway = inject(AdminUsersLocalGateway);
|
||||
|
||||
readonly users = signal<AdminUser[]>([]);
|
||||
readonly roles = signal<AdminRole[]>([]);
|
||||
readonly roles = signal<AdminUserRoleRecord[]>([]);
|
||||
readonly invitations = signal<AdminInvitation[]>([]);
|
||||
readonly loading = signal(false);
|
||||
readonly error = signal(false);
|
||||
|
||||
@@ -2,7 +2,8 @@ export type AdminUserScope = 'marketplace' | 'office';
|
||||
export type AdminUserStatus = 'active' | 'invited' | 'suspended';
|
||||
export type AdminInvitationStatus = 'pending' | 'accepted' | 'expired' | 'revoked';
|
||||
|
||||
export interface AdminRole {
|
||||
/** Users-admin display/permissions shape - unrelated to core/auth/models/permission.model.ts's AdminRole (the real JWT/auth role union). */
|
||||
export interface AdminUserRoleRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
permissions: string[];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { AdminInvitation, AdminRole, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
import { AdminInvitation, AdminUserRoleRecord, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
|
||||
export interface AdminUsersGateway {
|
||||
loadUsers(): Observable<AdminUser[]>;
|
||||
loadRoles(): Observable<AdminRole[]>;
|
||||
loadRoles(): Observable<AdminUserRoleRecord[]>;
|
||||
loadInvitations(): Observable<AdminInvitation[]>;
|
||||
loadSessions(userId: string): Observable<AdminSession[]>;
|
||||
loadAudit(userId: string): Observable<AdminUserAuditEntry[]>;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
import { AdminInvitation, AdminRole, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
import { AdminInvitation, AdminUserRoleRecord, AdminSession, AdminUser, AdminUserAuditEntry, AdminUserScope, AdminUserStatus } from '../models/admin-user.model';
|
||||
import { AdminUsersGateway } from './admin-users-gateway.interface';
|
||||
import { AdminAuthService } from '../../../../core/admin-auth/admin-auth.service';
|
||||
|
||||
const BUILT_IN_ROLES: AdminRole[] = [
|
||||
const BUILT_IN_ROLES: AdminUserRoleRecord[] = [
|
||||
{ id: 'owner', name: 'Owner', permissions: ['*'], builtIn: true },
|
||||
{ id: 'admin', name: 'Admin', permissions: ['products.manage', 'categories.manage', 'orders.manage', 'media.manage', 'users.manage'], builtIn: true },
|
||||
{ id: 'editor', name: 'Editor', permissions: ['products.manage', 'categories.manage', 'media.manage'], builtIn: true },
|
||||
@@ -16,7 +16,7 @@ const BUILT_IN_ROLES: AdminRole[] = [
|
||||
export class AdminUsersLocalGateway implements AdminUsersGateway {
|
||||
private readonly adminAuth = inject(AdminAuthService);
|
||||
private users: AdminUser[] | null = null;
|
||||
private roles: AdminRole[] = [...BUILT_IN_ROLES];
|
||||
private roles: AdminUserRoleRecord[] = [...BUILT_IN_ROLES];
|
||||
private invitations: AdminInvitation[] = [];
|
||||
private sessions: Record<string, AdminSession[]> = {};
|
||||
private audit: Record<string, AdminUserAuditEntry[]> = {};
|
||||
@@ -25,7 +25,7 @@ export class AdminUsersLocalGateway implements AdminUsersGateway {
|
||||
return of(this.ensureUsers()).pipe(delay(50));
|
||||
}
|
||||
|
||||
loadRoles(): Observable<AdminRole[]> {
|
||||
loadRoles(): Observable<AdminUserRoleRecord[]> {
|
||||
return of(this.roles).pipe(delay(50));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user